【发布时间】:2020-03-18 12:32:16
【问题描述】:
我正在尝试使用以下命令将deployment.yaml 文件应用到我的 Kubernetes 集群:kubectl apply -f .\deployment.yaml
但我收到此错误:error: error parsing .\deployment.yaml: error converting YAML to JSON: yaml: line 27: could not find expected ':'
yaml 文件与github 的原始文件完全相同:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
replicas: 1
template:
metadata:
labels:
app: {{ template "fullname" . }}
annotations:
# Include a hash of the config in the pod template
# This means that if the config changes, the deployment will be rolled
checksum/config: {{ include (print .Template.BasePath "/config.yaml") . | sha256sum }}
spec:
containers:
- name: {{ template "fullname" . }}
image: "{{ .Values.image.repo }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
resources:
{{ toYaml .Values.resources | indent 10 }}
ports:
- name: api
containerPort: {{ .Values.config.http.bind_address }}
{{- if .Values.config.graphite.enabled }}
- name: graphite
containerPort: {{ .Values.config.graphite.bind_address }}
{{- end }}
{{- if .Values.config.collectd.enabled }}
- name: collectd
containerPort: {{ .Values.config.collectd.bind_address }}
{{- end }}
{{- if .Values.config.udp.enabled }}
- name: udp
containerPort: {{ .Values.config.udp.bind_address }}
{{- end }}
{{- if .Values.config.opentsdb.enabled }}
- name: opentsdb
containerPort: {{ .Values.config.opentsdb.bind_address }}
{{- end }}
livenessProbe:
httpGet:
path: /ping
port: api
initialDelaySeconds: 30
timeoutSeconds: 5
readinessProbe:
httpGet:
path: /ping
port: api
initialDelaySeconds: 5
timeoutSeconds: 1
volumeMounts:
- name: data
mountPath: {{ .Values.config.storage_directory }}
- name: config
mountPath: /etc/influxdb
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
volumes:
- name: data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ template "fullname" . }}
{{- else }}
emptyDir: {}
{{- end }}
- name: config
configMap:
name: {{ template "fullname" . }}
所以根据错误信息,第 27 行:
26 {{ toYaml .Values.resources | indent 10 }}
27 ports:
28 - name: api
缺少一个 : ,据我所见,它就在那里。
为什么我会收到此错误?
【问题讨论】:
标签: kubernetes yaml indentation kubectl