错误:Deployment.apps“ geared-marsupi-buildachart”无效:

问题描述

helm install geared-marsupi ./buildachart/ 错误:Deployment.apps“ geared-marsupi-buildachart”无效:spec.template.spec.containers [1] .volumeMounts [0] .name:找不到:“ postgres_sql”

它看起来更像是一个缩进问题,但是以某种方式不起作用并且失败了。 我有两个容器,一个是drupal,不需要任何卷,第二个是postgresql,我已经添加了卷。




apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "buildachart.fullname" . }}
  labels:
    {{- include "buildachart.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
{{- end }}
  selector:
    matchLabels:
      {{- include "buildachart.selectorLabels" . | nindent 6 }}
  template:
    metadata:
    {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
    {{- end }}
      labels:
        {{- include "buildachart.selectorLabels" . | nindent 8 }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ include "buildachart.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
          livenessProbe:
            httpGet:
              path: /
              port: http
          readinessProbe:
            httpGet:
              path: /
              port: http
        - name: postgres #{{ .Chart.Name }}
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: postgres #"{{ .Values.image.repository1 }}:{{ .Values.image.tag }}" #| default .Chart.AppVersion
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          env:
          - name: POSTGRES_USER
            value: "{{ .Values.user }}" #"user"
          - name: POSTGRES_PASSWORD
            value: "{{ .Values.password }}" #"password"
          - name: POSTGRES_DB
            value: "{{ .Values.db }}" #"test"
          volumeMounts:
          - name: postgres_sql
            mountPath: /var/lib/postgresql/data
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
      {{- with .Values.nodeSelector }}
      volumes:
      - name: postgres_sql
        hostPath:
          path: /data/postgresdb_path
          type: Directory
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}

我尝试将卷直接放在容器选项卡下,然后在第二个postgre容器的“名称”选项卡下,但是结果相同。

有效的Yaml文件

apiVersion: apps/v1
kind: Deployment
metadata:
  name: drupal
spec:
  selector:
    matchLabels:
      app: drupal
  template:
    metadata:
      labels:
        app: drupal
    spec:
      containers:
      - name: drupal
        image: drupal
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"
      - name: postgres
        image: postgres
        env:
        - name: POSTGRES_USER
          value: test
        - name: POSTGRES_PASSWORD
          value: passwd
        volumeMounts:
        - name: postgres_vol
          mountPath: /var/lib/postgresql/data
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"
        ports:
        - containerPort: 80
      volumes: 
      - name: test-volume
        hostPath:
        - path: /data
          type: Directory

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...