Score:3

Change container ports in Kubernetes in production

in flag
cis

I have an nginx Dockerimage listening on some port as defined int its nginx.conf. That image is deployed as a workload in Kubernetes (GKE) and an ingress points to it. The image's port is - both as port and targetPort - set in the workload config Yaml file.

That set-up is running in a production environment.

Now I want to change the port, i.e. nginx should listen to a different port.

How do I do that without risking downtime? I'm afraid that I cannot change

  1. the deployed container itself
  2. the workload config
  3. the ingress config

at the very same moment. And if any of those are not in sync I would get downtime.

What is best practice in such cases? It would be nice if the ingress could point both to the old and the new port, but that's obviously not possible.

Score:4
nl flag

Create a new deployment using the new image and then create a new service pointing to that deployment, then create a new ingress with a different hostname, do your app test and if everything is working fine, change the reference to the service in the old ingress

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.