'Deployment failed due config map is not valid

I'm trying to install nginx deployment and store all the nginx configuration via configmap. All the nginx conf file are in a separate folder(outside of the template) in a new folder called "nginx.conf" Once I'm running the installation for the chart, I'm getting error:

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"

those are the configmap, deploymant yaml files:

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 }}

What am I missing?



Solution 1:[1]

it looks like you insert the volume section inside the node selector with statement, you need to change the location of the {{- with .Values.nodeSelector }} line, to be just above the nodeSelector: line

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mendi Neymark