简体   繁体   中英

nginx ingress controller not reading configmap

I have a nginx ingress controller on aks which I configured using official guide . I also wanted to configure the nginx to allow underscores in the header so I wrote down the following configmap

apiVersion: v1
kind: ConfigMap
data:
   enable-underscores-in-headers: "true"
metadata:
   name: nginx-configuration

Note that I am using default namespace for nginx. However applying the configmap nothing seem to be happening. I see no events. What am I doing wrong here?

Name:         nginx-configuration
Namespace:    default
Labels:       <none>
Annotations:  kubectl.kubernetes.io/last-applied-configuration:
                {"apiVersion":"v1","data":{"enable-underscores-in-headers":"true"},"kind":"ConfigMap","metadata":{"annotations":{},"name":"nginx-configura...

Data
====
enable-underscores-in-headers:
----
true
Events:  <none>

The nginx ingress controller deployment refer to a ConfigMap which can be checked by describing the deployment.

          args:
            - /nginx-ingress-controller
            - --configmap=$(POD_NAMESPACE)/nginx-configuration

You need to edit that configMap and add that parameter rather than creating new one.

kubectl edit cm nginx-configuration -n namespacename

Solution was to correctly name the configmap, firstly I did kubectl describe deploy nginx-ingress-controller which contained the configmap this deployment is looking for. In my case it was something like this --configmap=default/nginx-ingress-controller . I changed name of my configmap to nginx-ingress-controller . As soon I did that controller picked up the data from my configmap and changed the configuration inside my nginx pod.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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