How do I dynamically assign a targetPort?

10/3/2019

In defining a service, can I somehow hook up a value, eg. TargetPort so that if I change the configmap, it will automatically update my service? I don't think so, but maybe I am unclear if I can fully psrameterize my application port. I can do this with a manual script but w wondering what other solutions there are.

-- ergonaut
kubernetes

1 Answer

10/3/2019

This is not something you do directly in Kubernetes. You would use a higher-level system like Kustomize or Helm to put the correct value in both places. That said, why would you? It's not like you ever need things to coexist so just pick a port and roll with it.

-- coderanger
Source: StackOverflow