Search code examples
kuberneteskubernetes-helm

Override values.yaml in helm chart using nexus


Helm Chart Structure

web-service
  |_ _ _ templates
  |_ _ _ Chart.yaml
  |_ _ _ values.yaml

I have helm chart setup in which my helm charts for my application are packaged .tgz and pushed to nexus repo consider https://localhost:50714/#browse/browse:helm

Which is added to helm repositories.yaml using

helm repo add nexus https://localhost:50714/

Once Repo is added I can see the chart

helm search
NAME                                    CHART VERSION   APP VERSION     DESCRIPTION
nexus/web-service                   1.0.0-k8s                       Custom microservice Helm chart

To Install I Fire the below command

helm install nexus/ioc-web-service --version 1.0.0-k8s 

and application get deployed. So the application is deployed using default values.yaml I need to make this configurable so that my default values.yaml is overridden by another file lets say values-override.yaml

web-service
  |_ _ _ templates
  |_ _ _ Chart.yaml
  |_ _ _ values.yaml
  |_ _ _ values-override.yaml

I used helm provision of passing extra file using -f command but it gives values-override.yaml file not found

helm install nexus/web-service -f values-override.yaml --version 1.0.0-k8s 

Need Some input on how to get the pass the override values in file format. As the override values can be dynamic. On one environment it can be 1 variable in another there are be 10 variable which needs to be overridden


Solution

  • Here are the docs for Customizing the Chart Before Installing and you can use two ways of passing config data during installation:

    • --values (or -f): Specify a YAML file with overrides. This can be specified multiple times and the rightmost file will take precedence
    • --set: Specify overrides on the command line.

    You have to remember you need to run helm install from the directory where your YAML file is sitting.

    If you are still seeing the Error: open values-override.yaml: no such file or directory, this means that Helm is probably installed as a docker container. This happens if you use Kubespray to install Helm in this case can should check which folder is being mounted to the docker by: $ cat /usr/local/bin/helm You might see something like this:

    cat /usr/local/bin/helm
    
    #!/bin/bash
    /usr/bin/docker run --rm \
      --net=host \
      --name=helm \
      -v /etc/ssl:/etc/ssl:ro \
      -v /root/.helm:/root/.helm:rw \
      -v /usr/share/ca-certificates:/usr/share/ca-certificates:ro \
      lachlanevenson/k8s-helm:2.7.0 \
      "$@"
    

    Which will mean you need to copy values-override.yaml to /root/.helm directory. You can also check the directory by $ helm init:

    $ helm init
    $HELM_HOME has been configured at /root/.helm.
    Warning: Tiller is already installed in the cluster.
    (Use --client-only to suppress this message, or --upgrade to upgrade Tiller to the current version.)
    Happy Helming!