简体   繁体   English

将 Helm 图表 nginx-ingress 与自定义 nginx 模板一起使用

[英]Using Helm chart nginx-ingress with custom nginx template

I am trying to install the nginx-ingress controller through Helm but I would like to use a custom nginx template.我正在尝试通过 Helm 安装 nginx-ingress 控制器,但我想使用自定义 nginx 模板。 However, I am having trouble understanding how that works.但是,我无法理解它是如何工作的。 According to thedocs I can use a parameter called controller.customTemplate.configMapName .根据文档,我可以使用一个名为controller.customTemplate.configMapName的参数。 The description of the parameter is.参数的描述是。

configMap containing a custom nginx template包含自定义 nginx 模板的 configMap

I created a ConfigMap containing the nginx template as follows我创建了一个包含 nginx 模板的 ConfigMap,如下所示

apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-template
data:
  nginx.tmpl: nginx.tmpl

The nginx.tmpl contains the nginx configuration + plus a custom header on every server block. nginx.tmpl包含 nginx 配置 + 以及每个服务器块上的自定义标头。 I install the chart as follows:我按如下方式安装图表:

helm install stable/nginx-ingress --namespace kube-system --set controller.customTemplate.configMapName="nginx-template"

However, I'm getting the following error when running above command.但是,运行上述命令时出现以下错误。

Error: release listless-ant failed: Deployment.apps "listless-ant-nginx-ingress-controller" is invalid: [spec.template.spec.volumes[0].configMap.items[0].key: Required value, spec.template.spec.containers[0].volumeMounts[0].name: Not found: "nginx-template-volume"]

My question is, what am I doing wrong?我的问题是,我做错了什么?

我认为您还需要将controller.customTemplate.configMapKey设置为nginx.tmpl

The default location of nginx configuration template is /etc/nginx/template/nginx.tmpl And you will have to configure this as a volume mount. nginx 配置模板的默认位置是/etc/nginx/template/nginx.tmpl并且您必须将其配置为卷安装。

You can follow the steps mentioned in the official docs in-case if you are using a custom nginx.conf https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/custom-template/如果您使用自定义 nginx.conf https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/custom-template/,您可以按照官方文档中提到的步骤进行操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM