How to update a Deployment via editing yml file

1/10/2018

The official kubernetes guidelines, instruct 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?
-- pkaramol
kubernetes

1 Answer

1/10/2018

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.

-- Arora20
Source: StackOverflow