Patching nginx controller deployment on minikube results in rollback to former config

3/21/2019

I'm trying to patch the nginx ingress controller that follows the minikube vm.

Patching is successful using this command:

$ kubectl patch deployment nginx-ingress-controller --type 'json' --namespace kube-system -p '[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--profiling"}]'

#-> deployment.extensions/nginx-ingress-controller patched

After patching, the previous state is rolled back automatically. I can see the configuration persisted if I check just after deployment (Like below)

$ kubectl describe deployment/nginx-ingress-controller --namespace kube-system
#--- snip
    Args:
      /nginx-ingress-controller
      --default-backend-service=$(POD_NAMESPACE)/default-http-backend
      --configmap=$(POD_NAMESPACE)/nginx-load-balancer-conf
      --tcp-services-configmap=$(POD_NAMESPACE)/tcp-services
      --udp-services-configmap=$(POD_NAMESPACE)/udp-services
      --annotations-prefix=nginx.ingress.kubernetes.io
      --report-node-internal-ip-address
      --profiling

#---

After rollback the config is reset:

$ kubectl describe deployment/nginx-ingress-controller --namespace kube-system
#--- snip
    Args:
      /nginx-ingress-controller
      --default-backend-service=$(POD_NAMESPACE)/default-http-backend
      --configmap=$(POD_NAMESPACE)/nginx-load-balancer-conf
      --tcp-services-configmap=$(POD_NAMESPACE)/tcp-services
      --udp-services-configmap=$(POD_NAMESPACE)/udp-services
      --annotations-prefix=nginx.ingress.kubernetes.io
      --report-node-internal-ip-address

#---

I cannot see any errors in logs, which should trigger the rollback. The only I can see before the rollback is the deployment triggering shutdown on the pods due to configuration change.

-- leifcr
kubernetes
minikube
nginx-ingress

1 Answer

3/22/2019

Due to minikube running only 1 node, and the ingress using the hostPort, rolling updates will not work for the ingress deployment.

After patching the ingress to use recreate instead, patching the ingress config works as expected.

Command to set the ingress controller to 'recreate':

kubectl patch deployment nginx-ingress-controller --type 'json' --namespace kube-system -p '[{"op": "replace", "path": "/spec/strategy/type", "value": "Recreate"}, {"op": "replace", "path": "/spec/strategy/rollingUpdate", "value": null }]'

Command to set debug output logging on the nginx-ingress-controller:

kubectl patch deployment nginx-ingress-controller --type 'json' --namespace kube-system -p '[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "-v=5"}]'

The ingress controller now has debug log output, and is set to recreate if the config or image changes.

-- leifcr
Source: StackOverflow