Files
gitks/charts/templates/statefulset.yaml
T
zhenyi c2487ec0b6 feat(charts): add Helm chart for gitks Git bare repository service
- Create Chart.yaml with application metadata and keywords
- Add _helpers.tpl with name, fullname, labels, and DNS template functions
- Generate ConfigMap with all gitks configuration environment variables
- Implement StatefulSet with persistent volume claims for repository data
- Create headless service for pod DNS and cluster communication
- Add gRPC service for client connections and metrics service
- Include HorizontalPodAutoscaler for dynamic scaling
- Add PodDisruptionBudget to maintain cluster availability
- Create ServiceAccount with proper security context
- Add test connection pod using grpcurl for health checks
- Generate NOTES.txt with installation instructions and quick start guide
- Create .helmignore file to exclude common development files
- Configure persistence, resource limits, and security settings
- Add support for cluster mode with etcd service discovery
2026-06-08 21:21:15 +08:00

132 lines
4.2 KiB
YAML

apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "gitks.fullname" . }}
labels:
{{- include "gitks.labels" . | nindent 4 }}
spec:
serviceName: {{ include "gitks.headlessServiceName" . }}
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
podManagementPolicy: Parallel
selector:
matchLabels:
{{- include "gitks.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "gitks.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "gitks.serviceAccountName" . }}
{{- with .Values.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: 30
containers:
- name: gitks
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["gitks"]
ports:
- name: grpc
containerPort: {{ .Values.gitks.grpc.port }}
protocol: TCP
- name: metrics
containerPort: {{ .Values.gitks.metrics.port }}
protocol: TCP
- name: cluster
containerPort: {{ .Values.gitks.cluster.port }}
protocol: TCP
envFrom:
- configMapRef:
name: {{ include "gitks.fullname" . }}
env:
# Pod identity — used as STORAGE_NAME and for cluster addressing
- name: STORAGE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
# Advertised gRPC address for remote clients (other nodes use this)
- name: GITKS_ADVERTISE_ADDR
value: "http://{{ include "gitks.podDnsTemplate" . }}:{{ .Values.gitks.grpc.port }}"
# Cluster hostname for ractor TCP connections
- name: GITKS_CLUSTER_HOSTNAME
value: {{ include "gitks.podDnsTemplate" . | quote }}
{{- with .Values.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
livenessProbe:
tcpSocket:
port: grpc
initialDelaySeconds: 10
periodSeconds: 10
failureThreshold: 3
readinessProbe:
tcpSocket:
port: grpc
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 3
startupProbe:
tcpSocket:
port: grpc
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 30
volumeMounts:
- name: repo-data
mountPath: {{ .Values.gitks.repoPrefixPath | quote }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.persistence.enabled }}
volumeClaimTemplates:
- metadata:
name: repo-data
labels:
{{- include "gitks.labels" . | nindent 10 }}
{{- with .Values.persistence.annotations }}
annotations:
{{- toYaml . | nindent 10 }}
{{- end }}
spec:
accessModes:
- {{ .Values.persistence.accessMode }}
{{- with .Values.persistence.storageClass }}
storageClassName: {{ . | quote }}
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- end }}