'I have created a helm chart using helm create <chart-name>
In values.yaml I added the following map and array
nodeSelector:
instance-type: "re"
tolerations:
- key: "re"
operator: "Equal"
value: "true"
effect: "NoSchedule"
I am trying to import these in templates/deployment.yaml The config over there looks like with the right indentation
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ include "dummy-app.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "dummy-app.name" . }}
helm.sh/chart: {{ include "dummy-app.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "dummy-app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "dummy-app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
log_group_name: {{ .Values.logging.log_group_name }}
annotations:
jitsi.io/metrics_path: {{.Values.service.metricsPath | default "/actuator/prometheus" | quote }}
jitsi.io/scrape_port: {{.Values.service.actuatorPort | default "8083" | quote }}
jitsi.io/should_be_scraped: {{.Values.service.shouldScrapp | default "true" | quote}}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{.Values.service.targetPort}}
protocol: TCP
- name: http-actuator
containerPort: {{.Values.service.actuatorPort}}
protocol: TCP
livenessProbe:
httpGet:
path: /actuator/health
port: http-actuator
initialDelaySeconds: 30
readinessProbe:
httpGet:
path: /actuator/health
port: http-actuator
initialDelaySeconds: 30
env:
- name: PROFILES
value: {{ required "Environment name is required." .Values.env.environment | quote }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
when I run this I get:
Error: validation failed: error validating "": error validating data: [ValidationError(Deployment.spec.template): unknown field "nodeSelector" in io.k8s.api.core.v1.PodTemplateSpec, ValidationError(Deployment.spec.template): unknown field "tolerations" in io.k8s.api.core.v1.PodTemplateSpec]
I tried many other ways but none seems to work. My guess is the array and map there is something I need to change in deployment.yaml but I can't figure out how
It seems you're indenting wrongly affinity
, nodeSelector
and tolerations
:
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ include "dummy-app.fullname" . }}
labels:
...
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
...
template:
metadata:
labels:
...
annotations:
...
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
...
livenessProbe:
...
readinessProbe:
...
env:
...
resources:
...
nodeSelector: # <<< this are at the same level of `spec`
...
affinity: # <<< this are at the same level of `spec`
...
tolerations: # <<< this are at the same level of `spec`
...
The following keys must be at the same level of containers, so indenting with additional two blank spaces should fix your issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.