Change parameter values while implementing helm chart

+2 votes

I am trying to implement helm chart. I need to pass value via CLI to values.yaml file. 

values.yaml

  internalPort: 8081
volumeMounts:
  name: ebs-pvc
ingress:# Default values for miqp-ui-dep.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
##################Names of files and Applications################
Depname: miqp-server-dep
Appname: miqp-server
Svcname: miqp-server-svc
Ingname: miqp-ing
#################################################################
replicaCount: 2
strategy:
  type: RollingUpdate
  rollingUpdate:
     maxSurge: 1
     maxUnavailable: 1
minReadySeconds: 5
nodeSelector:
       role: nginxplus
image:
  repository: xxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/miqp-devops
  tag: miqpserver_2sep
  pullPolicy: IfNotPresent
service:
  name: miqp-ui-svc
  externalPort: 80
  enabled: true
  hosts:
    - kubernetes-miq.xxxxxx.com
  tls:
    - secretName: default-token-k33w6
      hosts:
        - kubernetes-xxxxxx.com
persistence:
  enabled: true
  volume:
    accessModes: ReadWriteOnce
    pvcName: ebs-pvc
    storageClass: standard
    storageSize: 20G

ingress.yaml

{{- if .Values.ingress.enabled -}}
{{- $serviceName := .Values.service.name -}}
{{- $servicePort := .Values.service.externalPort -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: {{ .Values.Ingname }}
  namespace: {{ .Release.Namespace }}
spec:
  rules:
    {{- range $host := .Values.ingress.hosts }}
    - host: {{ $host }}
      http:
        paths:
          - path:
            backend:
              serviceName: {{ $serviceName }}
              servicePort: {{ $servicePort }}
          - path: /api/
            backend:
              serviceName: {{ $serviceName }}
              servicePort: {{ $servicePort }}
     {{- end -}}
  {{- if .Values.ingress.tls}}
  tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
  {{- end -}}
{{- end -}}

How do I replace parameter values in the bellow example?

ingress:
  enabled: true
  hosts:
    - kubernetes-miq.xxxxxx.com
  tls:
    - secretName: default-token-k33w6
      hosts:
        - kubernetes-miq.xxxxxx.com

For example, I need to replace the value of the parameters sectretName and hosts.

How do I do it?

Jul 25, 2018 in Kubernetes by Hannah
• 18,520 points
8,585 views

5 answers to this question.

+1 vote
Best answer

You can use

helm upgrade --reuse-values --set ingress.enabled=false

or for more complex ones

helm upgrade --reuse-values -f <filename>

set via –set in more complex structures

--set key={a,b,c}

Or

--set name.key1=a,name.key2=b

I hope this helps..

answered Jul 25, 2018 by Kalgi
• 52,350 points

selected May 3, 2019 by Vardhan
Is there any provision in helm to provide the above values without using --set?

Say, I want to use --set release-namespace={.Values.releaseNamespace} to be picked up dynamically but without use of using --set.

Please let me know.

Thanks in advance.

Hey @Tushar, you can add a release directly in your yaml file instead of using -set flag.

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Release.Name }}-configmap
  namespace: {{ .Release.Namespace }}
data:
  myvalue: "Hello World"
Hi @Ashok, I got it resolved the same way only.

Thanks for the comment though :)
No problem @Tushar! :)

May I ask what are you trying to do(what project you're working on)?
+2 votes

Array Indexing is available for helm. You can do something like this:

autoscalingGroups:
  - name: my-asg-name
    maxSize: 50
    minSize: 2
answered May 3, 2019 by Tao
+1 vote

Array values can be specified using curly braces: --set foo={a,b,c}. This will translate to the YAML:

foo:
  - a
  - b
  - c
answered May 3, 2019 by Vaishu
+1 vote
The array indexing is available but only after version 2.5. Make sure you upgrade your helm.
answered May 3, 2019 by Haseeb
+1 vote

I think when you have complicated modifications, it's better to put these in a file instead of using --set.

answered May 3, 2019 by Gargi

Related Questions In Kubernetes

0 votes
2 answers

Error while installing MiniKube

Check if it's properly enabled for the ...READ MORE

answered Aug 30, 2018 in Kubernetes by Kalgi
• 52,350 points
1,569 views
0 votes
1 answer

Permission Error while GKE clusterrolebinding for cluster-admin

If your kubeconfig was created automatically by gcloud then ...READ MORE

answered Sep 3, 2018 in Kubernetes by ajs3033
• 7,300 points
4,329 views
0 votes
3 answers

Error while setting up kubernetes

echo "1" > /proc/sys/net/bridge/bridge-nf-call-iptables READ MORE

answered May 16, 2019 in Kubernetes by sivashankar
17,005 views
0 votes
3 answers

Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) while setting up kubernetes

Execute these three commands: sudo rm /var/lib/apt/lists/lock sudo rm ...READ MORE

answered Nov 27, 2018 in Kubernetes by Maverick
• 10,840 points
1,897 views
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
15,577 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,062 views
0 votes
1 answer

Error while creating kubernetes dashboard

The installation fails because there is no ...READ MORE

answered Aug 27, 2018 in Kubernetes by Kalgi
• 52,350 points
1,916 views
0 votes
1 answer

“403 Insufficient Permission” while creating a Kubernetes Cluster on Google Cloud instance

To run ./cluster/kube-up.sh, you most likely need compute scope ...READ MORE

answered Aug 28, 2018 in Kubernetes by Kalgi
• 52,350 points
1,345 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP