diff --git a/.github/workflows/ci-operator.yml b/.github/workflows/ci-operator.yml index 16cdb328..dc4e1a77 100644 --- a/.github/workflows/ci-operator.yml +++ b/.github/workflows/ci-operator.yml @@ -207,7 +207,7 @@ jobs: run: | kubectl get pods -A kubectl -n kates logs deploy/kates -c kates --tail=50 || true - kubectl -n kates-operator logs deploy/kates-operator --tail=50 || true + kubectl -n kates-operator logs -l app.kubernetes.io/name=kates-operator --prefix --tail=50 || true gate: name: Gate ยท Operator diff --git a/operator/chart/README.md b/operator/chart/README.md index 51bd8934..baf00416 100644 --- a/operator/chart/README.md +++ b/operator/chart/README.md @@ -298,4 +298,4 @@ The NetworkPolicy allows egress on 8080, 443 and 6443. A Kates URL on any other Metrics are on `:8080/metrics` under `kates_operator_`, and `monitoring.enabled` renders a PodMonitor. `/readyz` fails on an unreachable API server or a stale served CRD, and it reports the Lease and any refused Kafka namespace in its body without failing on them. -One pod holds the Lease `kates-operator` in the release namespace. `replicas: 2` only shortens the gap after a crash, to between 5 and 15 seconds. +One pod holds the Lease `kates-operator` in the release namespace. The chart runs two, on different nodes where it can (unless `affinity` is set), so the second takes the Lease over within 5 to 15 seconds when the first or its node is lost. With `replicas: 1`, a lost node holds everything until a new pod is scheduled and started. diff --git a/operator/chart/templates/deployment.yaml b/operator/chart/templates/deployment.yaml index 3e340cd1..bb256c36 100644 --- a/operator/chart/templates/deployment.yaml +++ b/operator/chart/templates/deployment.yaml @@ -36,6 +36,19 @@ spec: {{- with .Values.affinity }} affinity: {{- toYaml . | nindent 8 }} + {{- else }} + {{- if gt (int .Values.replicas) 1 }} + # Two on one node die with it, and the Lease waits out its node's loss. + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + topologyKey: kubernetes.io/hostname + labelSelector: + matchLabels: + {{- include "kates-operator.selectorLabels" . | nindent 20 }} + {{- end }} {{- end }} containers: - name: operator diff --git a/operator/chart/values.yaml b/operator/chart/values.yaml index 623e48b6..d98950dc 100644 --- a/operator/chart/values.yaml +++ b/operator/chart/values.yaml @@ -74,8 +74,9 @@ crdUpgrade: limits: memory: 64Mi -# -- 2 only shortens the gap after a crash: one pod holds the Lease. -replicas: 1 +# -- One pod holds the Lease; the second takes it over within seconds when the +# first or its node is lost. 1 waits for a new pod to be scheduled and started. +replicas: 2 resources: requests: @@ -107,4 +108,5 @@ podLabels: {} podAnnotations: {} nodeSelector: {} tolerations: [] +# -- Empty, with replicas above 1: the pods prefer one node each. affinity: {}