Zero-Downtime Deployment with Kubernetes

2/28/2019

I am trying to obtain zero downtime deployment with Kubernetes. What I have read is that we can obtain this using readiness-probe and RollingUpdate strategy for Deployments. I have tried these two things in my Deployment.yml file but everytime I am getting downtime, which I want to avoid. The service is an HTTP based service so I have used HTTP-Get probe.

I am using Helm charts for the deployment. And I am testing the 0-downtime by redeploying the same code and and same K8s configs.

Given below is the YAML file.

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: depName
  labels:
    app: appName
    chart: chart
    release: relName
    heritage: relService
spec:
  selector:
    matchLabels:
     app: appName
  replicas: 2
  strategy:
    type: RollingUpdate
    rollingUpdate: 
      maxUnavailable: 0
      maxSurge: 1    
  template:
    metadata:
      labels:
        app: appName
    spec:
      containers:
        - name: chartName
          resources:
            limits:
              cpu: 2000m
            requests:
              cpu: 1000m
          image: "repsitoryImage:tag"
          imagePullPolicy: always
          env:
           - name: GET_HOSTS_FROM
             value: dns
           - name: SOME_OTHER_VAR
             value: yasssd
          ports:
           - containerPort: internalPort
             name: someName
          readinessProbe:
            httpGet:
              path: /config
              port: 8080
            initialDelaySeconds: 15
            periodSeconds: 15  
            successThreshold: 1

Apart from this I have an HPA configured. I want the downtime to be zero- which I am not able to achieve.

Thanks in Advance !

-- mohd shoaib
kubernetes

0 Answers