Refresh Deployment Image in Kubernet

I am very new to Kubernetes and use k8s v1.4, Minikube v0.15.0 and Spotify maven Docker.
The build process of my project creates a Docker image and directs it directly to the Docker Minikube engine.

Containers are created using the deployment I created (using a set of replicas), and the strategy was set to type: RollingUpdate .

I saw this in the documentation:

Note : Deployment deployment is launched if and only if the deployment item template has been changed (i.e., spec.template).


I am looking for a simple way / workaround for stream automation: Build triggered> pressing the Docker button again (with changing the sound version)> Deployment will update the pod service>, open a new module.

+5
source share
1 answer

when you do not change the name or image tag of the container, you simply scale your application to 0 and return to its original size with sth, for example:

 kubectl scale --replicas=0 deployment application kubectl scale --replicas=1 deployment application 

As mentioned in the comments, ImagePullPolicy: Always is required in your configuration.

When changing the image, I found that this is the most direct way to update

 kubectl set image deployment/application app-container=$IMAGE 

Without changing the image, you have a website that you do not have to return to in case of problems. Therefore, I do not propose using this outside the development environment.


Edit: a small bonus - keeping the scale in sync before and after may look sth. as:

 replica_spec=$(kubectl get deployment/applicatiom -o jsonpath='{.spec.replicas}') kubectl scale --replicas=0 deployment application kubectl scale --replicas=$replica_spec deployment application 

Greetings

+5
source

Source: https://habr.com/ru/post/1263036/


All Articles