Why doesn't nginx wait until my connection during graceful shutdown?

Solution 1:

The only obvious thing I can think of is that nginx is PID 1 inside the container, but not on your desktop. There's nothing particular to kubernetes here - it's just plain Docker in this regard.

I tried to reproduce this, but it worked correctly for me. Here is the pod I used:

apiVersion: v1
kind: Pod 
metadata:
  namespace: demos
  name: pods-demo
  labels:
    demo: pods
spec:
  containers:
  - name: busybox
    image: busybox
    command:
    - sh
    - -c
    - dd if=/dev/zero of=/data/index.html bs=1024 count=10240; sleep 1000000
    volumeMounts:
    - name: content
      mountPath: /data
  - name: nginx
    image: nginx
    volumeMounts:
      - name: content
        mountPath: /usr/share/nginx/html
        readOnly: true
  volumes:
  - name: content