I’m trying to customize the cpu utilization of different env’s into one helm chart by conditional based. I have my deployment.yaml and values.yaml files configured like below to do conditional cpu utilization based on env, but deployment is failing with the error. I’ve tried using yaml lint but unable to figure out how to resolve the issue.
Below is my values.yaml file
nonprod:
limits:
cpu: 500m
memory: 300Mi
requests:
cpu: 400m
memory: 200Mi
prod:
limits:
cpu: 800m
memory: 1000Mi
requests:
cpu: 800m
memory: 1000Mi
Below is my deployment.yaml file and the error I see in the deployment is templates/deployment.yaml: error converting YAML to JSON: yaml: line 42: mapping values are not allowed in this context. Any help on this is really helpful.
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.metadata.name }}
namespace: {{ .Values.metadata.namespace }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.deployment.replicaCount }}
{{- end }}
selector:
matchLabels:
app: {{ .Values.service.name}}
template:
metadata:
labels:
app: {{ .Values.service.name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.internalPort }}
livenessProbe:
httpGet:
path: /health
port: {{ .Values.service.internalPort }}
initialDelaySeconds: 2
periodSeconds: 30
readinessProbe:
httpGet:
path: /health
port: {{ .Values.service.internalPort }}
initialDelaySeconds: 2
periodSeconds: 30
resources:
{{- if .Values.nonprod }}
limits:
cpu: {{ .Values.resources.nonprod.limits.cpu }}
memory: {{ .Values.resources.nonprod.limits.memory }}
requests:
cpu: {{ .Values.resources.nonprod.requests.cpu }}
memory: {{ .Values.resources.nonprod.requests.memory }}
{{else}}
limits:
cpu: {{ .Values.resources.prod.limits.cpu }}
memory: {{ .Values.resources.prod.limits.memory }}
requests:
cpu: {{ .Values.resources.prod.requests.cpu }}
memory: {{ .Values.resources.prod.requests.memory }}
{{- end }}
volumeMounts:
- mountPath: /root/tls.crt
name: config
subPath: tls.crt
- mountPath: /root/tls.key
name: config
subPath: tls.key
volumes:
- name: config
secret:
secretName: config
imagePullSecrets:
- name: default-image-pull-secret
I’ve tried https://www.yamllint.com/ to link the file but the issues seem to be still there even after removing some spaces and indentation. I’m new to Kubernetes and devops stuff and kind of stuck.
Sree Tummala is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.