[英]Helm Chart YAML error converting YAML to JSON: YAML: line 93: did not find expected key
I am trying to include cloudsqlproxy in the same pod has my GHOST container.我正在尝试将 cloudsqlproxy 包含在具有我的 GHOST 容器的同一个 pod 中。 However, I am having problems when adding cloudsqlproxy to the pod related to the YAML file linting.
但是,在将 cloudsqlproxy 添加到与 YAML 文件 linting 相关的 pod 时遇到问题。
The error it gives me is quite misleading has the problem most likely is not related to the line he is saying.它给我的错误非常具有误导性,问题很可能与他所说的路线无关。
{{- if include "ghost.host" . -}}
apiVersion: {{ template "ghost.deployment.apiVersion" . }}
kind: Deployment
metadata:
name: {{ template "ghost.fullname" . }}
labels:
app: "{{ template "ghost.fullname" . }}"
chart: "{{ template "ghost.chart" . }}"
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
spec:
selector:
matchLabels:
app: "{{ template "ghost.fullname" . }}"
release: {{ .Release.Name | quote }}
replicas: 3
template:
metadata:
labels:
app: "{{ template "ghost.fullname" . }}"
chart: "{{ template "ghost.chart" . }}"
release: {{ .Release.Name | quote }}
spec:
{{- if .Values.securityContext.enabled }}
securityContext:
fsGroup: {{ .Values.securityContext.fsGroup }}
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- else }}
initContainers:
- name: volume-permissions
image: {{ template "ghost.volumePermissions.image" . }}
imagePullPolicy: "{{ .Values.volumePermissions.image.pullPolicy }}"
command: ['sh', '-c', 'chmod -R g+rwX {{ .Values.persistence.path }}']
volumeMounts:
- mountPath: {{ .Values.persistence.path }}
name: ghost-data
{{- end }}
{{- include "ghost.imagePullSecrets" . | indent 6 }}
containers:
- name : cloudsql-proxy
image: gcr.io/cloudsql-docker/gce-proxy:1.16
command:
- -/cloudsql_sql_proxy
- --dir=/cloudsql
- -instances=infrastructure-0000:europe-west4:blablabla=tcp:3306
{{- if or .Values.serviceAccountKey .Values.existingSecret -}}
- -credential_file=/secrets/cloudsql/{{- if .Values.existingSecret -}} {{ .Values.existingSecretKey }} {{- else -}} credentials.json {{- end }}
{{end}}
securityContext:
runAsUser: 2
AllowPrivilegeEscalation: false
volumeMounts:
- name: cloudsql-instance-credentials
mountPath: /secrets/cloudsql
- name: {{ template "ghost.fullname" . }}
image: {{ template "ghost.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
env:
- name: ALLOW_EMPTY_PASSWORD
{{- if .Values.allowEmptyPassword }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
- name: MARIADB_HOST
{{- if .Values.mariadb.enabled }}
value: {{ template "ghost.mariadb.fullname" . }}
{{- else }}
value: {{ .Values.externalDatabase.host | quote }}
{{- end }}
- name: MARIADB_PORT_NUMBER
{{- if .Values.mariadb.enabled }}
value: "3306"
{{- else }}
value: {{ .Values.externalDatabase.port | quote }}
{{- end }}
- name: GHOST_DATABASE_NAME
{{- if .Values.mariadb.enabled }}
value: {{ .Values.mariadb.db.name | quote }}
{{- else }}
value: {{ .Values.externalDatabase.database | quote }}
{{- end }}
- name: GHOST_DATABASE_USER
{{- if .Values.mariadb.enabled }}
value: {{ .Values.mariadb.db.user | quote }}
{{- else }}
value: {{ .Values.externalDatabase.user | quote }}
{{- end }}
- name: GHOST_DATABASE_PASSWORD
{{- if .Values.mariadb.enabled }}
valueFrom:
secretKeyRef:
name: {{ template "ghost.mariadb.fullname" . }}
key: mariadb-password
{{- else }}
value: {{ .Values.externalDatabase.password | quote }}
{{- end }}
- name: GHOST_HOST
value: {{ include "ghost.host" . | quote }}
- name: GHOST_PROTOCOL
value: {{ .Values.ghostProtocol | quote }}
- name: GHOST_PORT_NUMBER
{{- if .Values.ghostPort }}
value: {{ .Values.ghostPort | quote }}
{{- else }}
value: {{ .Values.service.port | quote }}
{{- end }}
- name: GHOST_USERNAME
value: {{ .Values.ghostUsername | quote }}
- name: GHOST_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "ghost.fullname" . }}
key: ghost-password
- name: GHOST_EMAIL
value: {{ .Values.ghostEmail | quote }}
- name: BLOG_TITLE
value: {{ .Values.ghostBlogTitle | quote }}
{{- if .Values.smtpHost }}
- name: SMTP_HOST
value: {{ .Values.smtpHost | quote }}
{{- end }}
{{- if .Values.smtpPort }}
- name: SMTP_PORT
value: {{ .Values.smtpPort | quote }}
{{- end }}
{{- if .Values.smtpUser }}
- name: SMTP_USER
value: {{ .Values.smtpUser | quote }}
{{- end }}
{{- if .Values.smtpPassword }}
- name: SMTP_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "ghost.fullname" . }}
key: smtp-password
{{- end }}
{{- if .Values.smtpFromAddress }}
- name: SMTP_FROM_ADDRESS
value: {{ .Values.smtpFromAddress | quote }}
{{- end }}
{{- if .Values.smtpService }}
- name: SMTP_SERVICE
value: {{ .Values.smtpService | quote }}
{{- end }}
ports:
- name: http
containerPort: 2368
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.ghostPath }}
port: http
httpHeaders:
- name: Host
value: {{ include "ghost.host" . | quote }}
{{- if eq .Values.ghostProtocol "https" }}
- name: X-Forwarded-Proto
value: https
{{- end }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: {{ .Values.ghostPath }}
port: http
httpHeaders:
- name: Host
value: {{ include "ghost.host" . | quote }}
{{- if eq .Values.ghostProtocol "https" }}
- name: X-Forwarded-Proto
value: https
{{- end }}zshzs
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- end }}
{{- if .Values.resources }}
resources: {{- toYaml .Values.resources | nindent 10 }}
{{- end }}
volumeMounts:
- name: ghost-data
mountPath: /bitnami/ghost
volumes:
- name: cloudsql-instance-credentials
secret:
secretName: "calm-com-tls"
- name: ghost-data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ template "ghost.fullname" . }}
{{- else }}
emptyDir: {}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}
Simple way to resolve this kind of issues is to use tools.解决此类问题的简单方法是使用工具。 These are mostly indentation issues
这些主要是缩进问题
npm install -g yaml-lint
yaml-lint is one such tool yaml-lint 就是这样一种工具
PS E:\vsc-workspaces\grafana-1> yamllint .\grafana.yaml
× YAML Lint failed for C:/Users/mnadeem6/vsc-workspaces/grafana-1/grafana.yaml
× bad indentation of a mapping entry at line 137, column 11:
restartPolicy: Always
^
PS E:\vsc-workspaces\grafana-1> yamllint .\grafana.yaml
√ YAML Lint successful.
I would change section GHOST_DATABASE_PASSWORD
to look like:我会将
GHOST_DATABASE_PASSWORD
部分GHOST_DATABASE_PASSWORD
为:
- name: GHOST_DATABASE_PASSWORD
valueFrom:
secretKeyRef:
{{- if .Values.mariadb.enabled }}
name: {{ template "ghost.mariadb.fullname" . }}
key: mariadb-password
{{- else }}
name: {{ printf "%s-%s" .Release.Name "externaldb" }}
key: db-password
{{- end }}
where:在哪里:
data:
db-password: {{ .Values.externalDatabase.password | b64enc | quote }}
Example: helm-chart-secret .示例: helm-chart-secret 。
请检查 init 容器中的 volumeMounts 部分我猜缩进不正确。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.