Using Helm chart nginx-ingress with custom nginx template

8/10/2018

I am trying to install the nginx-ingress controller through Helm but I would like to use a custom nginx template. However, I am having trouble understanding how that works. According to the docs I can use a parameter called controller.customTemplate.configMapName. The description of the parameter is.

configMap containing a custom nginx template

I created a ConfigMap containing the nginx template as follows

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. 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?

-- Frank Levering
kubernetes
kubernetes-ingress
nginx

2 Answers

8/10/2018

I think you also need to set controller.customTemplate.configMapKey to nginx.tmpl.

-- Ryan Dawson
Source: StackOverflow

1/17/2020

The default location of nginx configuration template is /etc/nginx/template/nginx.tmpl And you will have to configure this as a volume mount.

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/

-- Isuru Dilhan
Source: StackOverflow