加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

将nginx.conf添加到Kubernetes集群

发布时间:2020-12-13 21:07:02 所属栏目:Nginx 来源:网络整理
导读:将配置文件传递到k8s群集内的NGINX的最佳做法是什么? 您可以创建ConfigMap对象,然后将值作为文件挂载到您需要的位置: apiVersion: v1kind: ConfigMapmetadata: name: nginx-configdata: nginx.conf: | your config comes here like this other.conf: | sec

将配置文件传递到k8s群集内的NGINX的最佳做法是什么?

您可以创建ConfigMap对象,然后将值作为文件挂载到您需要的位置:

apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-config
data:
  nginx.conf: |
    your config
    comes here
    like this
  other.conf: |
    second file
    contents

在你的pod规格:

spec:
  containers:
    - name: nginx
      image: nginx
      volumeMounts:
        - name: nginx-config
          mountPath: /etc/nginx/nginx.conf
          subPath: nginx.conf
        - name: nginx-config
          mountPath: /etc/nginx/other.conf
          subPath: other.conf
  volumes:
    - name: nginx-config
      configMap:
        name: nginx-config

(注意mountPath中文件名的重复,并使用完全相同的子路径;与bind装入文件相同.)

有关ConfigMap的更多信息,请参阅:
https://kubernetes.io/docs/user-guide/configmap/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读