How to Update Kubernetes Deployments + Services

8/31/2016

I have put together a simple cluster with several deploys that interact nicely, dns works, etc. However, as I'm using Deployments, and I have a few questions that I could not find answered in the docs.

  • How do I non-destructively update a deployment with a new copy of the deploy file? I've got edit and replace, but I'd really like to just pass in the file proper with it's changed fields (version, image, ports, etc.)

  • What's the preferred way of exposing a deployment as a service? There's a standalone file, there's an expose command... anything else I should consider? Is it possible to bundle the service into the deployment file?

-- nflacco
deployment
kubernetes

1 Answer

8/31/2016

How do I non-destructively update a deployment

You can use kubectl replace or kubectl apply. Replace is a full replacement. Apply tries to do a selective patch operation.

What's the preferred way of exposing a deployment as a service?

All of your suggestions are valid. Some people prefer a script, and for that kubectl expose is great. Some people want more control and versioning, so YAML files + kubectl apply or kubectl replace are appropriate. You can bundle multiple YAML "documents" into a single file, just join the blocks with "---" on a line by itself.

-- Tim Hockin
Source: StackOverflow