EMC
EMC

Reputation: 1940

Is there a good way to set dynamic labels for k8s resources?

I'm attempting to add some recommended labels to several k8s resources, and I can't see a good way to add labels for things that would change frequently, in this case "app.kubernetes.io/instance" and "app.kubernetes.io/version". Instance seems like a label that should change every time a resource is deployed, and version seems like it should change when a new version is released, by git release or similar. I know that I could write a script to generate these values and interpolate them, but that's a lot of overhead for what seems like a common task. I'm stuck using Kustomize, so I can't just use Helm and have whatever variables I want. Is there a more straightforward way to apply labels like these?

Upvotes: 1

Views: 829

Answers (1)

coderanger
coderanger

Reputation: 54267

Kustomize's commonLabels transformer is a common way to handle this, sometimes via a component. It really depends on your overall layout.

Upvotes: 1

Related Questions