Helm mapping override .values.yaml with other resources

1/16/2020

It might be a simple question but how should I map the different values.yaml with other resources such as Deployment, Service and Ingress.

I have four values.yaml for different environments and I am trying to use Jenkins to deploy my application. For instance, I would like to set different replicacount value for each values.yaml. My confusion is , should I change anything else in deployment.yaml? Because it is refers to .Values.replicacount or the command in Jenkins will cover this already?

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "road-dashboard.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "road-dashboard.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    helm.sh/chart: {{ include "road-dashboard.chart" . }}
spec:
  replicas: {{ .Values.replicaCount }}

In jenkins I will use below command for test stage

sh "helm upgrade --install a-service . -f values.test.yaml 

and will use below command for prod

sh "helm upgrade --install a-service . -f values.prod.yaml
-- semural
jenkins
kubernetes-helm

1 Answer

1/16/2020

".Values.replicaCount" means it will look in values.yaml for a variable name "replicaCount" to get the value of it; so you need to set the desired value in that file (in your case - values.test.yaml and values.prod.yaml ) if you want to change it like -

replicaCount: 1  #no of replicas
-- Pankaj
Source: StackOverflow