我正在尝试通过 configmap 安装 nginx 部署和 store 所有 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 }}
我错过了什么?
回答1
看起来您在节点选择器 with
语句中插入了卷部分,您需要更改 {{- with .Values.nodeSelector }}
行的位置,使其刚好位于 nodeSelector:
行上方