gitdataai/deploy/templates/gitserver-deployment.yaml
2026-04-14 19:02:01 +08:00

163 lines
4.8 KiB
YAML

{{- if .Values.gitserver.enabled -}}
{{- $fullName := include "c-----code.fullname" . -}}
{{- $ns := include "c-----code.namespace" . -}}
{{- $svc := .Values.gitserver -}}
{{/* PersistentVolumeClaim for git repositories */}}
{{- if $svc.persistence.enabled }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ $fullName }}-repos
namespace: {{ $ns }}
labels:
app.kubernetes.io/name: {{ $fullName }}-gitserver
app.kubernetes.io/instance: {{ $.Release.Name }}
spec:
accessModes:
- {{ $svc.persistence.accessMode | default "ReadWriteOnce" }}
resources:
requests:
storage: {{ $svc.persistence.size }}
{{- if $svc.persistence.storageClass }}
storageClassName: {{ $svc.persistence.storageClass }}
{{- end }}
{{- end }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $fullName }}-gitserver
namespace: {{ $ns }}
labels:
app.kubernetes.io/name: {{ $fullName }}-gitserver
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/version: {{ $.Chart.AppVersion }}
spec:
replicas: {{ $svc.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ $fullName }}-gitserver
app.kubernetes.io/instance: {{ $.Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ $fullName }}-gitserver
app.kubernetes.io/instance: {{ $.Release.Name }}
spec:
containers:
- name: gitserver
image: "{{ $.Values.image.registry }}/{{ $svc.image.repository }}:{{ $svc.image.tag }}"
imagePullPolicy: {{ $svc.image.pullPolicy | default $.Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ $svc.service.http.port }}
protocol: TCP
- name: ssh
containerPort: {{ $svc.ssh.port }}
protocol: TCP
env:
- name: APP_REPOS_ROOT
value: /data/repos
- name: APP_DATABASE_URL
valueFrom:
secretKeyRef:
name: {{ $.Values.database.existingSecret | default (printf "%s-secrets" $fullName) }}
key: {{ $.Values.database.secretKeys.url }}
optional: true
- name: APP_REDIS_URL
valueFrom:
secretKeyRef:
name: {{ $.Values.redis.existingSecret | default (printf "%s-secrets" $fullName) }}
key: {{ $.Values.redis.secretKeys.url }}
optional: true
{{- if $svc.ssh.domain }}
- name: APP_SSH_DOMAIN
value: {{ $svc.ssh.domain }}
{{- end }}
{{- if $svc.ssh.port }}
- name: APP_SSH_PORT
value: {{ $svc.ssh.port | quote }}
{{- end }}
{{- range $svc.env }}
- name: {{ .name }}
value: {{ .value | quote }}
{{- end }}
resources:
{{- toYaml $svc.resources | nindent 10 }}
volumeMounts:
{{- if $svc.persistence.enabled }}
- name: repos
mountPath: /data/repos
{{- end }}
volumes:
{{- if $svc.persistence.enabled }}
- name: repos
persistentVolumeClaim:
claimName: {{ $fullName }}-repos
{{- end }}
{{- with $svc.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $svc.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $svc.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
---
# HTTP service (git smart HTTP)
apiVersion: v1
kind: Service
metadata:
name: {{ $fullName }}-gitserver-http
namespace: {{ $ns }}
labels:
app.kubernetes.io/name: {{ $fullName }}-gitserver
app.kubernetes.io/instance: {{ $.Release.Name }}
spec:
type: {{ $svc.service.http.type }}
ports:
- name: http
port: {{ $svc.service.http.port }}
targetPort: http
protocol: TCP
selector:
app.kubernetes.io/name: {{ $fullName }}-gitserver
app.kubernetes.io/instance: {{ $.Release.Name }}
---
# SSH service (git over SSH)
apiVersion: v1
kind: Service
metadata:
name: {{ $fullName }}-gitserver-ssh
namespace: {{ $ns }}
labels:
app.kubernetes.io/name: {{ $fullName }}-gitserver
app.kubernetes.io/instance: {{ $.Release.Name }}
spec:
type: {{ $svc.service.ssh.type }}
{{- if eq $svc.service.ssh.type "NodePort" }}
ports:
- name: ssh
port: {{ $svc.ssh.port }}
targetPort: ssh
nodePort: {{ $svc.service.ssh.nodePort }}
{{- else }}
ports:
- name: ssh
port: {{ $svc.ssh.port }}
targetPort: ssh
{{- end }}
selector:
app.kubernetes.io/name: {{ $fullName }}-gitserver
app.kubernetes.io/instance: {{ $.Release.Name }}
{{- end }}