topfans/k8s/helm/topfans/templates/galleryservice/deployment.yaml
2026-07-06 13:26:46 +08:00

94 lines
3.3 KiB
YAML

# Gallery Service — 展厅
{{- $svc := .Values.services.galleryservice -}}
{{- if $svc.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "topfans.fullname" . }}-galleryservice
namespace: {{ .Values.namespace.name | default "topfans" }}
labels:
{{- include "topfans.labels" . | nindent 4 }}
app.kubernetes.io/component: galleryservice
spec:
{{- $hpaEnabled := false -}}
{{- if hasKey $svc "hpa" -}}
{{- if hasKey $svc.hpa "enabled" -}}
{{- $hpaEnabled = $svc.hpa.enabled -}}
{{- end -}}
{{- end -}}
{{- if not $hpaEnabled }}
replicas: {{ $svc.replicas | default 1 }}
{{- end }}
selector:
matchLabels:
{{- include "topfans.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: galleryservice
template:
metadata:
labels:
{{- include "topfans.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: galleryservice
spec:
serviceAccountName: {{ include "topfans.serviceAccountName" . }}
containers:
- name: galleryservice
image: {{ include "topfans.image" (dict "Values" .Values "service" $svc.image.repositoryName "tag" $svc.image.tag) }}
imagePullPolicy: {{ .Values.global.image.pullPolicy | default "IfNotPresent" }}
ports:
- name: dubbo
containerPort: {{ $svc.port }}
env:
{{- include "topfans.commonEnv" . | nindent 10 }}
{{- range $k, $v := $svc.env }}
{{- if not (hasSuffix "_SECRET_REF" $k) }}
- name: {{ $k }}
value: {{ $v | quote }}
{{- end }}
{{- end }}
# MQ_REDIS_PASSWORD 走 db-credentials secret, 不重复声明
- name: MQ_REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: db-credentials
key: REDIS_PASSWORD
envFrom:
- secretRef: { name: jwt-secret }
livenessProbe:
httpGet:
path: {{ $svc.healthPath | default "/health" }}
port: {{ $svc.port }}
initialDelaySeconds: {{ $.Values.probes.defaultLiveness.initialDelaySeconds }}
periodSeconds: {{ $.Values.probes.defaultLiveness.periodSeconds }}
timeoutSeconds: {{ $.Values.probes.defaultLiveness.timeoutSeconds }}
failureThreshold: {{ $.Values.probes.defaultLiveness.failureThreshold }}
readinessProbe:
httpGet:
path: {{ $svc.healthPath | default "/health" }}
port: {{ $svc.port }}
initialDelaySeconds: {{ $.Values.probes.defaultReadiness.initialDelaySeconds }}
periodSeconds: {{ $.Values.probes.defaultReadiness.periodSeconds }}
timeoutSeconds: {{ $.Values.probes.defaultReadiness.timeoutSeconds }}
failureThreshold: {{ $.Values.probes.defaultReadiness.failureThreshold }}
resources:
{{- toYaml $svc.resources | nindent 10 }}
---
apiVersion: v1
kind: Service
metadata:
name: galleryservice
namespace: {{ .Values.namespace.name | default "topfans" }}
labels:
{{- include "topfans.labels" . | nindent 4 }}
app.kubernetes.io/component: galleryservice
spec:
type: ClusterIP
selector:
{{- include "topfans.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: galleryservice
ports:
- name: dubbo
port: {{ $svc.port }}
targetPort: dubbo
protocol: TCP
{{- end }}