Files
helm-gitea/templates/cluster.yaml
T
volker.raschekandCopilot 6d68d44894
Bash / shellcheck (push) Successful in 7s
Bash / bash-unittest (push) Successful in 25s
changelog / changelog (push) Successful in 15s
Helm / helm-lint (push) Successful in 13s
Helm / helm-unittest (push) Successful in 20s
Markdown linter / markdown-lint (push) Successful in 18s
Markdown linter / markdown-link-checker (push) Successful in 52s
feat(cloudnativePG): support topologySpreadConstraints
A HA `Cluster` is only actually highly available if its instances end up in different failure domains. Pod
anti-affinity alone cannot express that: it only keeps the instances off the same node, not off the same zone,
and `cloudnativePG.affinity` has no way to encode a skew budget. Without `topologySpreadConstraints` a three
instance cluster can legitimately be scheduled into a single availability zone, where a zone outage takes down
the primary and both replicas at once.

Both `affinity` and `topologySpreadConstraints` are rendered only when they are set. The CloudNativePG API
declares them as `omitempty`, so an empty `{}` or `[]` in the manifest would show up as a permanent diff against
the state the operator writes back.

Tolerations deliberately do not get a dedicated value. CloudNativePG has no `spec.tolerations`, it nests them
below `spec.affinity.tolerations`, so they are configured through `cloudnativePG.affinity` like `nodeSelector`
and the anti-affinity settings. A separate top-level value would only have to be folded back into the same place
and would silently conflict with a tolerations list set via `cloudnativePG.affinity`.

Co-authored-by: Copilot <copilot@github.com>
2026-10-04 00:39:08 +02:00

52 lines
1.9 KiB
YAML

{{- if .Values.cloudnativePG.enabled -}}
{{- $registry := .Values.global.imageRegistry | default .Values.cloudnativePG.image.registry -}}
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
{{- with (include "gitea.cluster.cloudnativePG.annotations" .) }}
annotations:
{{- . | nindent 4 }}
{{- end }}
labels:
{{- include "gitea.cluster.cloudnativePG.labels" . | nindent 4 }}
name: {{ include "gitea.cluster.cloudnativePG.name" . }}
namespace: {{ .Values.namespace | default .Release.Namespace }}
spec:
{{- with .Values.cloudnativePG.affinity }}
affinity:
{{- toYaml . | nindent 4 }}
{{- end }}
bootstrap:
initdb:
database: {{ .Values.cloudnativePG.credentials.database | quote }}
owner: {{ .Values.cloudnativePG.credentials.username | quote }}
secret:
name: {{ include "gitea.secret.cloudnativePG.name" . }}
imageName: {{ printf "%s/%s:%s" $registry .Values.cloudnativePG.image.repository (.Values.cloudnativePG.image.tag | toString) | quote }}
instances: {{ .Values.cloudnativePG.instances }}
monitoring:
enablePodMonitor: {{ .Values.cloudnativePG.monitoring.enablePodMonitor }}
postgresql:
parameters:
{{- toYaml .Values.cloudnativePG.postgresql.parameters | nindent 6 }}
priorityClassName: {{ .Values.cloudnativePG.priorityClassName | quote }}
resources:
{{- toYaml .Values.cloudnativePG.resources | nindent 4 }}
storage:
size: {{ .Values.cloudnativePG.storage.size | quote }}
{{- with .Values.cloudnativePG.storage.storageClass }}
storageClass: {{ . | quote }}
{{- end }}
{{- with .Values.cloudnativePG.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.cloudnativePG.walStorage.enabled }}
walStorage:
size: {{ .Values.cloudnativePG.walStorage.size | quote }}
{{- with .Values.cloudnativePG.walStorage.storageClass }}
storageClass: {{ . | quote }}
{{- end }}
{{- end }}
{{- end -}}