kubernetes set image and losing connection

3/16/2019

before update

brain NodePort 10.98.29.51 6282:30000/TCP 43m

brain 1/1 Running 0 3m8s 10.36.0.2 knode2

I ran this command to update image

kubectl set image -n nava deployment/brain brain=172.16.13.204:5000/brain:2.0.0

after update

brain NodePort 10.97.230.95 6282:30000/TCP 25m

brain 1/1 Running 0 32m 10.36.0.2 knode2

after update i lost connection to the service, after recreating SVC, the services came up. so what's the point of "set image" ?? i want update image without losing connection ..

any suggestion

-- hesaum saboury
kubernetes

1 Answer

3/18/2019

In order to avoid downtime, you have to explicitly mention rolling update strategy. i.e

spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 2        # how many pods we can add at a time
      maxUnavailable: 0  # maxUnavailable define how many pods can be unavailable
                         # during the rolling upd

Thus, secondary deployment is created with the new version of the image, then the number of replicas of the old version is decreased and the new version is increased until the correct number of replicas is reached.

-- A_Suh
Source: StackOverflow