Home > Back-end >  Add extra custom labels to existing helm chart
Add extra custom labels to existing helm chart

Time:07-15

I am using an existing helm chart repo https://github.com/kubecost/cost-analyzer-helm-chart

For deployment I am using custom helm chart, have created tgz of the repo and put it under my own charts/ directory and then i put my own certain templates which deploys some resources related to cost-analyzer.

I want to assign some custom labels to the resources which are coming from that tgz.

Is there something/someway that i can add custom labels to all the resources which are deployed using my custom helm chart including the resource which are from tgz.

CodePudding user response:

There is nothing built into Helm for doing that.

You can set the additionalLabels field in their Helm chart values.yaml file (there are multiple places this needs to be done).

A potential kludge could be to pull the manifests after deploying, get the name and type of every resource, and pump that into a kubectl command to label everything, for example:

HELM_RELEASE="???"
NAMESPACE="???"
LABEL="???"
helm get manifest $HELM_RELEASE -n $NAMESPACE \
  | kubectl get -n $NAMESPACE -f - \
  | grep -vE '^$|^NAME' \
  | cut -d' ' -f1 \
  | xargs -I {} kubectl label {} $LABEL 
  • Related