Igor Corradi
Igor Corradi

Reputation: 474

How to override a multi-line string with --set in helm install command?

I need to install a helm with a dynamic "project_id" flag on deploy time inside the rawConfig multi-line string

Example values.yaml

sinks:
  console:
    type: "console"
    inputs: ["kafka"]
    rawConfig: |
      target = "stdout"

      encoding.codec = "json"

  stackdriver:
    type: "gcp_stackdriver_logs"
    inputs: ["kafka"]
    rawConfig: |
      healthcheck = true
      log_id = "mirth-channels-log"
      project_id = "my_project"
      resource.type = "k8s_cluster"

How do I override this value of project_id in rawConfig? I'm trying to do this:

 helm install vector helm/vector --values helm/vector-agent/values.yaml -n my-namespace --set sinks.stackdriver.rawConfig='\nlog_id\ =\ "mirth-channels-log"\nproject_id\ =\ "my_project_test"\nresource.type\ =\ "k8s_cluster"\n'

But it does not work

Upvotes: 8

Views: 5844

Answers (3)

Derrick Petzold
Derrick Petzold

Reputation: 1148

I went with --set-file:

helm install vector helm/vector --values helm/vector-agent/values.yaml -n my-namespace \
--set-file sinks.stackdriver.rawConfig=raw.config

https://helm.sh/docs/helm/helm_install/

Upvotes: 0

edbighead
edbighead

Reputation: 6304

Maybe not the best way, but you can use a separate multiline variable for that:

export MULTILINE_VALUE=$(cat <<EOF                     
healthcheck = true 
log_id = "mirth-channels-log" 
project_id = "my_project_test"
resource.type = "k8s_cluster" 
EOF
)

helm install vector helm/vector --values helm/vector-agent/values.yaml -n my-namespace \
--set sinks.stackdriver.rawConfig=$MULTILINE_VALUE

Upvotes: 2

Matt
Matt

Reputation: 8132

Use second --values like following:

# values_patch.yaml
sinks:
  stackdriver:
    rawConfig: |
      healthcheck = true
      log_id = "mirth-channels-log"
      project_id = "SOME_OTHER_PROJECT_ID"
      resource.type = "k8s_cluster"
$ helm install [...] --values values_patch.yaml

Upvotes: 4

Related Questions