refactor(deploy): use envFrom with configMapRef for all deployments

Replace individual configMapKeyRef env vars with envFrom + configMapRef
to inject the full ConfigMap, plus minimal env blocks for static values.
Also remove resources block from operator deployment (K8s schema validation).
This commit is contained in:
ZhenYi 2026-04-15 13:48:13 +08:00
parent f1388a6ae2
commit ad2cb7255f
6 changed files with 18 additions and 185 deletions

View File

@ -35,91 +35,9 @@ spec:
- name: http
containerPort: {{ .Values.app.service.port }}
protocol: TCP
env:
- name: APP_DATABASE_URL
valueFrom:
configMapKeyRef:
envFrom:
- configMapRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_DATABASE_URL
optional: true
- name: APP_REDIS_URL
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_REDIS_URL
optional: true
- name: NATS_URL
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: NATS_URL
optional: true
- name: HOOK_POOL_REDIS_LIST_PREFIX
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: HOOK_POOL_REDIS_LIST_PREFIX
optional: true
- name: HOOK_POOL_REDIS_LOG_CHANNEL
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: HOOK_POOL_REDIS_LOG_CHANNEL
optional: true
- name: APP_QDRANT_URL
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_QDRANT_URL
optional: true
- name: APP_QDRANT_API_KEY
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_QDRANT_API_KEY
optional: true
- name: APP_AVATAR_PATH
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_AVATAR_PATH
optional: true
- name: APP_SMTP_HOST
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_SMTP_HOST
optional: true
- name: APP_SMTP_PORT
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_SMTP_PORT
optional: true
- name: APP_SMTP_USERNAME
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_SMTP_USERNAME
optional: true
- name: APP_SMTP_PASSWORD
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_SMTP_PASSWORD
optional: true
- name: APP_SMTP_FROM
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_SMTP_FROM
optional: true
- name: APP_SMTP_TLS
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_SMTP_TLS
optional: true
{{- range .Values.app.env }}
- name: {{ .name }}
value: {{ .value | quote }}

View File

@ -30,55 +30,9 @@ spec:
- name: email-worker
image: "{{ .Values.image.registry }}/{{ .Values.emailWorker.image.repository }}:{{ .Values.emailWorker.image.tag }}"
imagePullPolicy: {{ .Values.emailWorker.image.pullPolicy | default .Values.image.pullPolicy }}
env:
- name: APP_DATABASE_URL
valueFrom:
configMapKeyRef:
envFrom:
- configMapRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_DATABASE_URL
optional: true
- name: APP_REDIS_URL
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_REDIS_URL
optional: true
- name: APP_SMTP_HOST
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_SMTP_HOST
optional: true
- name: APP_SMTP_PORT
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_SMTP_PORT
optional: true
- name: APP_SMTP_USERNAME
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_SMTP_USERNAME
optional: true
- name: APP_SMTP_PASSWORD
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_SMTP_PASSWORD
optional: true
- name: APP_SMTP_FROM
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_SMTP_FROM
optional: true
- name: APP_SMTP_TLS
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_SMTP_TLS
optional: true
{{- range .Values.emailWorker.env }}
- name: {{ .name }}
value: {{ .value | quote }}

View File

@ -30,31 +30,9 @@ spec:
- name: git-hook
image: "{{ .Values.image.registry }}/{{ .Values.gitHook.image.repository }}:{{ .Values.gitHook.image.tag }}"
imagePullPolicy: {{ .Values.gitHook.image.pullPolicy | default .Values.image.pullPolicy }}
env:
- name: APP_DATABASE_URL
valueFrom:
configMapKeyRef:
envFrom:
- configMapRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_DATABASE_URL
optional: true
- name: APP_REDIS_URL
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: APP_REDIS_URL
optional: true
- name: HOOK_POOL_REDIS_LIST_PREFIX
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: HOOK_POOL_REDIS_LIST_PREFIX
optional: true
- name: HOOK_POOL_REDIS_LOG_CHANNEL
valueFrom:
configMapKeyRef:
name: {{ include "gitdata.fullname" . }}-config
key: HOOK_POOL_REDIS_LOG_CHANNEL
optional: true
{{- range .Values.gitHook.env }}
- name: {{ .name }}
value: {{ .value | quote }}

View File

@ -44,33 +44,12 @@ spec:
- name: ssh
containerPort: {{ $svc.service.ssh.port }}
protocol: TCP
envFrom:
- configMapRef:
name: {{ $fullName }}-config
env:
- name: APP_REPOS_ROOT
value: /data/repos
- name: APP_DATABASE_URL
valueFrom:
configMapKeyRef:
name: {{ $fullName }}-config
key: APP_DATABASE_URL
optional: true
- name: APP_REDIS_URL
valueFrom:
configMapKeyRef:
name: {{ $fullName }}-config
key: APP_REDIS_URL
optional: true
- name: APP_SSH_DOMAIN
valueFrom:
configMapKeyRef:
name: {{ $fullName }}-config
key: APP_SSH_DOMAIN
optional: true
- name: APP_SSH_PORT
valueFrom:
configMapKeyRef:
name: {{ $fullName }}-config
key: APP_SSH_PORT
optional: true
{{- range $svc.env }}
- name: {{ .name }}
value: {{ .value | quote }}

View File

@ -29,6 +29,9 @@ spec:
- name: operator
image: "{{ .Values.image.registry }}/{{ .Values.operator.image.repository }}:{{ .Values.operator.image.tag }}"
imagePullPolicy: {{ .Values.operator.image.pullPolicy | default .Values.image.pullPolicy }}
envFrom:
- configMapRef:
name: {{ include "gitdata.fullname" . }}-config
env:
- name: OPERATOR_IMAGE_PREFIX
value: {{ .Values.operator.imagePrefix | default (printf "%s/" (include "gitdata.fullname" .)) | quote }}
@ -38,8 +41,6 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
resources:
{{- toYaml .Values.operator.resources | nindent 10 }}
volumeMounts:
- name: tmp
mountPath: /tmp

View File

@ -40,6 +40,9 @@ spec:
- name: http
containerPort: {{ $svc.service.port }}
protocol: TCP
envFrom:
- configMapRef:
name: {{ $fullName }}-config
env:
- name: STATIC_ROOT
value: /data