search by tags

for the user

adventures into the land of the command line

nginx ingress controller crazy config reloads

something you can do to prevent your nginx ingress controller from reloading configs like crazy

set this cli option in its deployment:

$ kubectl edit deploy cluster-ingress-nginx-ingress-controller -n my-groovy-namespace


.
.
.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  .
  .
  .
spec:
  .
  .
  .
  template:
    metadata:
      .
      .
      .
    spec:
      containers:
      - args:
        - /nginx-ingress-controller
        - --default-backend-service=mi-system/cluster-ingress-nginx-ingress-default-backend
        - --publish-service=mi-system/cluster-ingress-nginx-ingress-controller
        - --election-id=ingress-controller-leader
        - --ingress-class=nginx
        - --configmap=mi-system/cluster-ingress-nginx-ingress-controller
        - --sort-backends=True <----------- THIS GUY HERE
        env:
        .
        .
        .
        image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.21.0
        .
        .
        .

this will make sure that upstream configs have hosts added in order. without it, the NGINX ingress controller will repeatedly generate a different configuration file due to changes in the ordering of upstreams and server IPs. nginx will interpret a shuffled config as a different config, even if there are no actual changes in the contents of the upstreams, just the order in which they occur in the config file. this will trigger a config reload.

so include --sort-backends=True if you want to reduce reloads of this kind.