由于配置映射无效而导致部署失败

问题描述 投票:0回答:1

我正在尝试安装 nginx 部署并通过 configmap 存储所有 nginx 配置。 所有 nginx conf 文件都位于名为“nginx.conf”的新文件夹中的单独文件夹(模板之外)中 一旦我运行图表的安装,我就会收到错误:

rromano-ltm1:eks-devops-nginx rromano$ helm install nginx-int nginx-int-chart
Error: INSTALLATION FAILED: Deployment.apps "nginx-int-nginx-int-chart" is invalid: spec.template.spec.containers[0].volumeMounts[0].name: Not found: "config"

这些是 configmap、deploymant yaml 文件:

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "nginx-int-chart.name" . }}-config
data:
  {{- (.Files.Glob "nginx.conf/*").AsConfig | nindent 2 }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "nginx-int-chart.fullname" . }}
  namespace: {{ .Values.namespace }}
  labels:
    {{- include "nginx-int-chart.labels" . | nindent 4 }}
spec:
  {{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
  {{- end }}
  selector:
    matchLabels:
      {{- include "nginx-int-chart.selectorLabels" . | nindent 6 }}
  strategy:
    rollingUpdate:
      maxSurge: {{ .Values.rollingUpdate.maxSurge }}
      maxUnavailable: {{ .Values.rollingUpdate.maxUnavailable }}
    type: RollingUpdate
  template:
    metadata:
      {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      labels:
        {{- include "nginx-int-chart.selectorLabels" . | nindent 8 }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ include "nginx-int-chart.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
          volumeMounts:
            - mountPath: /etc/nginx/conf.d
              name: config
              subPath: conf.d
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
      {{- with .Values.nodeSelector }}
      volumes:
        - name: config
          configMap:
            name: { { template "nginx-int-chart.name" . } }-config
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}

我错过了什么?

kubernetes nginx kubernetes-helm
1个回答
0
投票

看起来您在节点选择器

with
语句中插入了音量部分,您需要更改
{{- with .Values.nodeSelector }}
线的位置,使其位于
nodeSelector:
线的正上方

© www.soinside.com 2019 - 2024. All rights reserved.