I've followed http://rahmonov.me/posts/zero-downtime-deployment-with-kubernetes/ blog, created two docker images with index.html returning 'Version 1 of an app' and 'Version 2 of an app'. What I want to achieve is zero downtime release. I'm using
kubectl apply -f mydeployment.yaml
with image: mynamespace/nodowntime-test:v1
inside.
to deploy v1 version to k8s and then run:
while True
do
printf "\n---------------------------------------------\n"
curl "http://myhosthere"
sleep 1s
done
So far everything works. After short time curl returns 'Version 1 of an app'.
Then I'm applying same k8s deployment file with image: mynamespace/nodowntime-test:v2
. And well, it works, but there is one ( always one ) Gateway Timeout response between v1 and v2. So its not really no downtime release ; ) It is much better than without RollingUpdate but not perfect.
I'm using RollingUpdate
strategy and readinessProbe:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nodowntime-deployment
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
selector:
matchLabels:
app: nodowntime-test
template:
metadata:
labels:
app: nodowntime-test
spec:
containers:
...
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 5
successThreshold: 5
Can I do it better? Is it some issue with syncing all of that with ingress controller? I know I can tweak it by using minReadySeconds
so old and new pod overlaps for some time but is it the only solution?