Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ConfigMap configuration with Helm NginX Ingress controller - Kubernetes

Tags:

I've found a documentation about how to configure your NginX ingress controller using ConfigMap: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/

Unfortunately I've no idea and couldn't find it anywhere how to load that ConfigMap from my Ingress controller.

My ingress controller:

helm install --name ingress --namespace ingress-nginx --set rbac.create=true,controller.kind=DaemonSet,controller.service.type=ClusterIP,controller.hostNetwork=true stable/nginx-ingress 

My config map:

kind: ConfigMap apiVersion: v1 metadata:   name: ingress-configmap data:   proxy-read-timeout: "86400s"   client-max-body-size: "2g"   use-http2: "false" 

My ingress:

apiVersion: extensions/v1beta1 kind: Ingress metadata:   name: ingress   annotations:     nginx.ingress.kubernetes.io/backend-protocol: "HTTPS" spec:   tls:     - hosts:         - my.endpoint.net       secretName: ingress-tls   rules:     - host: my.endpoint.net       http:         paths:           - path: /             backend:               serviceName: web               servicePort: 443           - path: /api             backend:               serviceName: api               servicePort: 443 

How do I make my Ingress to load the configuration from the ConfigMap?

like image 515
Tomasz Raganowicz Avatar asked Feb 26 '19 11:02

Tomasz Raganowicz


People also ask

What is nginx ingress Kubernetes IO configuration snippet?

The configuration-snippet is to add configs to locations. If you want to add a custom location to the server context, you should use the server-snippet instead: Using the annotation nginx.ingress.kubernetes.io/server-snippet it is possible to add custom configuration in the server configuration block.

How does ingress controller work in Kubernetes?

An Ingress controller abstracts away the complexity of Kubernetes application traffic routing and provides a bridge between Kubernetes services and external ones. Kubernetes Ingress controllers: Accept traffic from outside the Kubernetes platform, and load balance it to pods (containers) running inside the platform.


2 Answers

I've managed to display what YAML gets executed by Helm using the: --dry-run --debug options at the end of helm install command. Then I've noticed that there controller is executed with the: --configmap={namespace-where-the-nginx-ingress-is-deployed}/{name-of-the-helm-chart}-nginx-ingress-controller. In order to load your ConfigMap you need to override it with your own (check out the namespace).

kind: ConfigMap apiVersion: v1 metadata:   name: {name-of-the-helm-chart}-nginx-ingress-controller   namespace: {namespace-where-the-nginx-ingress-is-deployed} data:   proxy-read-timeout: "86400"   proxy-body-size: "2g"   use-http2: "false" 

The list of config properties can be found here.

like image 81
Tomasz Raganowicz Avatar answered Sep 28 '22 06:09

Tomasz Raganowicz


One can pass config mag properties at the time of installation too:

helm install stable/nginx-ingress --name nginx-ingress --set controller.config.use-forwarded-headers='"true"' 

NOTE: for non-string values had to use single quotes around double quotes to get it working.

like image 41
adnan kamili Avatar answered Sep 28 '22 04:09

adnan kamili