<p>I have a configuration file like below. I deploy it to EKS cluster successfully. However, when I change the <code>nginx-conf</code> ConfigMap and run <code>kubectl apply</code> command, it doesn't seem to update the <code>nginx.config</code> in the pod. I tried to login to the pod and look at the file <code>/etc/nginx/nginx.config</code> but its content is still the old one.</p>
<p>I have tried to run <code>kubectl rollout status deployment sidecar-app</code> but it doesn't help.</p>
<p>And it shows the updated config map when I run <code>kubectl describe configmap nginx-conf</code>.</p>
<p>It seems the container doesn't take the config map change. How can I apply the changes without deleting the pod?</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-conf
data:
  nginx.conf: |
    user nginx;
    worker_processes  1;
    events {
      worker_connections  10240;
    }
    http {
      server {
          listen       8080;
          server_name  localhost;
          location / {
            proxy_pass  http://localhost:9200/;
          }
          location /health {
            proxy_pass  http://localhost:9200/_cluster/health;
          }
      }
    }
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sidecar-app
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      name: sidecar-app
  template:
    metadata:
      labels:
        name: sidecar-app
    spec:
      containers:
        - name: nginx
          image: nginx:latest
          ports:
            - name: http
              containerPort: 8080
          volumeMounts:
            - name: nginx-conf
              mountPath: /etc/nginx/nginx.conf
              subPath: nginx.conf
              readOnly: true
      volumes:
        - name: nginx-conf
          configMap:
            name: nginx-conf
            items:
              - key: nginx.conf
                path: nginx.conf

---
apiVersion: v1
kind: Service
metadata:
  name: sidecar-entrypoint
spec:
  selector:
    name: sidecar-app
  ports:
    - port: 8080
      targetPort: 8080
      protocol: TCP
  type: NodePort
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: sidecar-ingress-1
  namespace: default
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/group.name: sidecar-ingress
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: ip
    alb.ingress.kubernetes.io/group.order: '2'
    alb.ingress.kubernetes.io/healthcheck-path: /health
    # alb.ingress.kubernetes.io/healthcheck-port: '8080'
spec:
  rules:
    - http:
        paths:
          - path: /*
            backend:
              serviceName: sidecar-entrypoint
              servicePort: 8080
</code></pre>

Joey Yi Zhao
<p>Kubernetes treats POD and Configmap as a different/separate object and pods don't automatically restart on specific Configmap version.</p>
<p>There are few alternatives to achieve this.</p>
<p>1 ) Reloader: <code>https://github.com/stakater/Reloader</code></p>
<pre><code>kind: Deployment
metadata:
 annotations:
   reloader.stakater.com/auto: &quot;true&quot;
spec:
 template: metadata:
</code></pre>
<ol start="2">
<li>configHash annotation.
<code>https://blog.questionable.services/article/kubernetes-deployments-configmap-change/</code></li>
<li>Use wave.
<code>https://github.com/wave-k8s/wave</code></li>
<li>You can use <code>kubectl rollout restart deploy/sidecar-app</code> but this will restart the pods with zero downtime. Rolling updates allow Deployments' update to take place with zero downtime by incrementally updating Pods instances with new ones.</li>
</ol>
