【问题标题】:Error: YAML parse error on deployment.yaml: error converting YAML to JSON: yaml: line 50: mapping values are not allowed in this context错误:deployment.yaml 上的 YAML 解析错误:将 YAML 转换为 JSON 时出错:yaml:第 50 行:此上下文中不允许映射值
【发布时间】:2022-01-24 09:03:27
【问题描述】:

安装我创建的 helm chart 时出现错误。

helm install -f values.yaml --dry-run testbb ./

我更改缩进并使其像 yamls。我多次使用“kubectl get -o yaml”,但它不起作用。

yaml 文件中的第 50 行包含卷 name:frontend-http

请问有人知道怎么解决吗? 这是整个 yaml 模板文件:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "frontend-nginx.fullname" . }}
  labels:
    {{- include "frontend-nginx.labels" . | nindent 4 }}
spec:
  {{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
  {{- end }}
  selector:
    matchLabels:
      {{- include "frontend-nginx.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      labels:
        {{- include "frontend-nginx.selectorLabels" . | nindent 8 }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ include "frontend-nginx.serviceAccountName" . }}
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      containers:
      - name: {{ .Chart.Name }}
        securityContext:
          {{- toYaml .Values.securityContext | nindent 12 }}
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        ports:
        - name: http
          containerPort: 80
          protocol: TCP
        volumeMounts:
          - mountPath: /usr/local/nginx/conf/nginx.conf
            name: {{ .Values.nginxconfig.nginxcm }}-volume
            subPath: nginx.conf
          - mountPath: /usr/local/nginx/html/app
            name: data-storage
      volumes: 
      - configMap:
          defaultMode: 420
          name: frontend-http
        name: frontend-http-volume
      {{- if .Values.persistentVolume.enabled }}
      - name: data-storage
        persistentVolumeClaim:
          claimName: {{ .Values.persistentVolume.existingClaim | default (include "frontend-nginx.fullname" .) }}
      {{- else }}
      - name: data-storage
        emptyDir: {}
      {{- end }}            
{{- if .Values.persistentVolume.mountPaths }}
{{ toYaml .Values.persistentVolume.mountPaths | indent 12 }}
{{- end }}            
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}

【问题讨论】:

    标签: kubernetes kubernetes-helm helm3


    【解决方案1】:

    尝试交换“configMap”和“name”:

          volumes: 
          - name: frontend-http-volume
            configMap:
              defaultMode: 420
              name: frontend-http
          {{- if .Values.persistentVolume.enabled }}
          - name: data-storage
            persistentVolumeClaim:
              claimName: {{ .Values.persistentVolume.existingClaim | default (include "frontend-nginx.fullname" .) }}
          {{- else }}
          - name: data-storage
            emptyDir: {}
          {{- end }} 
    
    

    【讨论】:

      猜你喜欢
      • 2019-09-12
      • 1970-01-01
      • 1970-01-01
      • 2021-07-23
      • 2021-06-04
      • 2021-02-04
      • 2020-04-21
      • 2016-07-13
      • 2012-06-13
      相关资源
      最近更新 更多