Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update a Deployment via editing yml file

Tags:

kubernetes

The official kubernetes guidelines, instructs on updating the deployment either by performing a command line set:

kubectl set image deployment/nginx-deployment nginx=nginx:1.9.1

or by inline editing (that will launch the default editor I guess)

kubectl edit deployment/nginx-deployment

However both processes make consistency more difficult given that one needs to go and udpate offline the my-deployment.yml file, where the up & running deployment came from. (and this deprives one from the advantage of keeping their manifests version-controlled).

Is there a way to

  • launch a deployment via the file
  • perform (when needed) updates to the same file
  • update the deployment by pointing to the same, updated file?
like image 422
pkaramol Avatar asked Jan 10 '18 16:01

pkaramol


People also ask

How do I edit a Deployment?

You can edit a Deployment by changing the container image from one version to the other, decreasing or increasing the number of instances by changing the ReplicaSet value.

How do I update kubectl Deployment?

Updating an application You can use kubectl apply to update a resource by applying a new or updated configuration. Note: To update a resource with kubectl apply , the resource must be created using kubectl apply or kubectl create --save-config . Replace MANIFEST with the name of the manifest file.


1 Answers

You can do it simply by following steps -

  1. Edit the deployment.yaml file
  2. Run below command -

    kubectl apply -f deployment.yaml
    

This is what I usually follow. You can use a kubectl patch or edit also.

like image 158
Arora20 Avatar answered Sep 20 '22 22:09

Arora20