how to read docker image label on helm chart template

12/3/2018

My company it is using on their build process sbt-native-packager, which adds labels on docker images, those labels contains useful information (port number, service types, application name etc...).

I want to read those values and use them on Kubernetes Helm charts, is there any way to access those label values using go templates on helm charts?

-- gonzalesraul
docker
kubernetes-helm

1 Answer

12/4/2018

There are some steps you can do in order to get these variables to chart:

  1. Extract desired labels in separate environment variables

    PORT_NUMBER=$(command --to --extract --port)

  2. Set placeholders in your values.yaml file

values.yaml

image: 
  port: "$PORT_NUMBER"
  pullPolicy: IfNotPresent
  1. Use envsubst to replace values in values.yaml during build
-- edbighead
Source: StackOverflow