【问题标题】:How to set nginx.conf permanently in kuberenetes ingress?如何在 kubernetes 入口中永久设置 nginx.conf?
【发布时间】:2021-06-14 15:28:03
【问题描述】:

我们的 nginx 控制器不支持 Windows 7 系统的 SSL。我们更新了 Kubernetes Nginx pod 中 nginx.conf 文件中的密码套件,它开始工作了。

现在的问题是每当服务重新启动或 pod 重新启动时,nginx.conf 文件都会重置为默认文件。

如何永久设置nginx.conf 文件?

【问题讨论】:

  • 使用当前使用的相同 nginx 创建自定义 nginx 映像,然后将 nginx.conf 替换为进行更改的 nginx.conf。将自定义镜像保存到您的 docker 注册表并使用该镜像而不是默认的 nginx 镜像。

标签: kubernetes-ingress nginx-config nginx-ingress ingress-controller


【解决方案1】:

为您的 nginx.conf 创建一个配置映射并将其附加到您的 pod 的特定位置。

通过运行以下命令创建配置映射。

kubectl create configmap nginx-conf --from-file=nginx.conf

并将其附加在特定目录中。

apiVersion: v1
kind: Pod
metadata:
  name: test
spec:
  containers:
    - name: test-container
      image: k8s.gcr.io/busybox
      command: [ "/bin/sh", "-c", "ls /etc/config/" ]
      volumeMounts:
      - name: nginx-config
        mountPath: /etc/nginx/
  volumes:
    - name: nginx-config
      configMap:
        # Provide the name of the ConfigMap containing the files you want
        # to add to the container
        name: nginx-config //your config map name here
  restartPolicy: Never

【讨论】:

    猜你喜欢
    • 2013-01-20
    • 2015-07-15
    • 1970-01-01
    • 2019-11-20
    • 2018-10-07
    • 2020-09-07
    • 2014-05-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多