首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:deployment.yaml上的YAML解析错误:将YAML转换为JSON: yaml:第50行:在此上下文中不允许映射值

错误:deployment.yaml上的YAML解析错误:将YAML转换为JSON: yaml:第50行:在此上下文中不允许映射值
EN

Stack Overflow用户
提问于 2022-01-19 07:49:29
回答 1查看 4.7K关注 0票数 2

当我安装我创建的舵图时,我会得到一个错误。

头盔安装-f values.yaml

我改变了缩进,让它像山雀一样。我多次使用"kubectl -o yaml“,但它不起作用。

yaml文件中的第50行包含卷名称:前端-http

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

代码语言:javascript
复制
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 }}
EN

回答 1

Stack Overflow用户

发布于 2022-01-19 08:16:46

尝试交换"configMap“和”名称“:

代码语言:javascript
复制
      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 }} 
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70766965

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档