k8s使用yml文件部署

1.K8S可以使用yml部署资源

apiVersion: apps/v1
kind: Deployment
metadata:
  name: gateway-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gateway-app
  template:
    metadata:
      labels:
        app: gateway-app
    spec:
      containers:
      - name: gateway-app
        image: registry.cn-beijing.aliyuncs.com/205erp/gateway-app:2024-06-04-10-42-26
        ports:
        - containerPort: 8080

2.高级配置

1.添加容器环境变量
2.文件挂载

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80
        env: # 添加环境变量配置
        - name: MY_ENV_VAR
          value: "Hello Kubernetes"
        volumeMounts: # 添加日志挂载配置
        - name: nginx-logs
          mountPath: /var/log/nginx
      volumes: # 定义挂载卷
      - name: nginx-logs
        hostPath: # 使用HostPath类型挂载到主机
          path: /path/on/host/for/nginx/logs # 这里填写主机上的日志目录路径
          type: DirectoryOrCreate # 如果需要自动创建目录

FILE_CONTENT=$(cat k8s.yml | sed 's/$/\n/g')

curl -X POST \
-H 'Content-Type: application/json' \
-d '{"msgtype": "text", "text": {"content": "审核,黑米-最新镜像:'${FILE_CONTENT}'"}}' \
https://oapi.dingtalk.com/robot/send?access_token=ddaea71f9ed09a0cd0fe1a28e18fadb618a4e0cee829c0534d48b3273dd9e644

相关推荐

  1. k8s使用yml文件部署

    2024-06-06 10:18:03       8 阅读
  2. k8sYAML文件详解

    2024-06-06 10:18:03       31 阅读
  3. K8S 哲学 - yaml文件

    2024-06-06 10:18:03       11 阅读
  4. k8s&&如何写yaml文件

    2024-06-06 10:18:03       9 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-06-06 10:18:03       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-06 10:18:03       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-06 10:18:03       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-06 10:18:03       20 阅读

热门阅读

  1. debian常用命令

    2024-06-06 10:18:03       8 阅读
  2. Server did not offer supported security type!问题解决

    2024-06-06 10:18:03       8 阅读
  3. hnust 湖南科技大学 2022 软件测试报告+代码

    2024-06-06 10:18:03       9 阅读
  4. C#面:XML与 HTML 的主要区别是什么

    2024-06-06 10:18:03       9 阅读
  5. Django前端页面-模板继承

    2024-06-06 10:18:03       8 阅读
  6. Qt6弃用了QRegExp,改为QRegularExpression

    2024-06-06 10:18:03       10 阅读
  7. 在Web应用中如何处理会话跟踪

    2024-06-06 10:18:03       9 阅读
  8. 网络安全实战基础——实战工具与攻防环境介绍

    2024-06-06 10:18:03       9 阅读
  9. linux服务器配置openssl

    2024-06-06 10:18:03       9 阅读
  10. 面向小白的 Spark MLlib 入门教学

    2024-06-06 10:18:03       10 阅读