I am trying to script setup of Jenkins so that I can create and tear down Jenkins clusters programmatically with helm. I've hit an annoying snag where I cannot set a key with dots in the name. My helm values.yaml file looks like this:
--- rbac: install: true Master: HostName: jenkins.mycompany.com ServiceType: ClusterIP ImageTag: lts InstallPlugins: - kubernetes - workflow-aggregator - workflow-job - credentials-binding - git - blueocean - github - github-oauth ScriptApproval: - "method groovy.json.JsonSlurperClassic parseText java.lang.String" - "new groovy.json.JsonSlurperClassic" - "staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods leftShift java.util.Map java.util.Map" - "staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods split java.lang.String" - "method java.util.Collection toArray" - "staticMethod org.kohsuke.groovy.sandbox.impl.Checker checkedCall java.lang.Object boolean boolean java.lang.String java.lang.Object[]" - "staticMethod org.kohsuke.groovy.sandbox.impl.Checker checkedGetProperty java.lang.Object boolean boolean java.lang.Object" Ingress: Annotations: kubernetes.io/ingress.class: nginx kubernetes.io/tls-acme: "true" TLS: - secretName: jenkins-mycompany-com hosts: - jenkins.mycompany.com Memory: "2Gi" # This breaks the init container # RunAsUser: 1000 # FSGroup: 1000 Agent: Enabled: false ImageTag: latest
After installing cert-manager
, external-dns
, nginx-ingress
(for now via a bash script) I install it like so:
helm install --values helm/jenkins.yml stable/jenkins
I failed to read the letsencrypt docs at all, so throughout the course of testing I used my production quota. I want to be able to add an annotation to the Ingress
: certmanager.k8s.io/cluster-issuer: letsencrypt-staging
so that I can continue testing (and set this as the default in the future, overriding when I'm ready for production).
The trouble is... I can't figure out how to pass this via the --set
flag, since there are periods in the key name. I've tried:
helm install --values helm/jenkins.yml stable/jenkins --set Master.Ingress.Annotations.certmanager.k8s.io/cluster-issuer=letsencrypt-staging
and
helm install --values helm/jenkins.yml stable/jenkins --set Master.Ingress.Annotations.certmanager\.k8s\.io/cluster-issuer=letsencrypt-staging
I can of course solve this by adding a value that I use as a flag, but it's less explicit. Is there any way to set it directly?
You can use a --values flag in your Helm commands to override the values in a chart and pass in a new file. Specify the name of the new file after the --values flag in the Helm command. Example: helm upgrade --install <service> -f values.
The $_ is used to suppress undesired output as "set" returns the new dictionary. The above returns: - name: mongod-none.
Using the 'tpl' Function The tpl function allows developers to evaluate strings as templates inside a template. This is useful to pass a template string as a value to a chart or render external configuration files.
You need to enclose the key with quotations and then escape the dots
helm install --values helm/jenkins.yml stable/jenkins --set Master.Ingress.Annotations."certmanager\.k8s\.io/cluster-issuer"=letsencrypt-staging
Use \
to escape the dots in the key. Quotation marks are required to prevent shell interpreting the \
character.
helm install --values helm/jenkins.yml stable/jenkins --set 'Master.Ingress.Annotations.certmanager\.k8s\.io/cluster-issuer=letsencrypt-staging'
Helm requires these characters to be escaped: .
[
,
=
Source: https://paul-boone.medium.com/helm-chart-install-advanced-usage-of-the-set-argument-3e214b69c87a
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With