‘我已经用helm create <chart-name>创建了一个头盔图
在values.yaml中,我添加了以下映射和数组
nodeSelector:
instance-type: "re"
tolerations:
- key: "re"
operator: "Equal"
value: "true"
effect: "NoSchedule"我试图在模板/部署中导入这些内容。over在那里的配置与正确的缩进类似
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 }}当我运行这个时,我得到:
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]我尝试了许多其他的方法,但似乎都没有用。我猜是数组和地图,我需要在deployment.yaml中修改一些东西,但是我不知道怎么做
发布于 2020-06-03 06:47:52
你好像是错误地缩进了affinity,nodeSelector和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`
...以下键必须位于容器的同一级别,因此,使用额外的两个空格缩进可以解决您的问题。
https://stackoverflow.com/questions/62162964
复制相似问题