Files
cozystack/packages/system/flux-plunger/templates/deployment.yaml
T
Alexey Artamonov 8bcb709ce8 fix(fluxcd): refuse a flux-plunger drain deadline that leaves no time
A drain deadline of zero or less is already spent when the drain
starts, so flux-plunger would exit holding every uninstall fence
without listing one. The chart could produce one: its 40-second floor
was a literal, so raising the manager's stop bound or the margin before
SIGKILL, which the drain subtraction is already tied to, would leave the
floor rendering a non-positive deadline. The binary now refuses such a
flag at startup, before it reaches for a cluster, and the chart's floor
and the timings the README and the values comment state are held to
the same constants.

A whole number of a million seconds or more printed in exponent form
and was refused as a fraction; the range is now checked first, so it
gets the range message.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-10-13 15:09:00 +03:00

87 lines
3.2 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
name: flux-plunger
labels:
app.kubernetes.io/name: flux-plunger
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
{{- /*
flux-plunger treats a suspension its own field manager owns, seen in a fresh
reconcile, as its own interrupted run, so exactly one process may act on a
HelmRelease at a time. No rollout strategy gives that: the next pod starts as
soon as the old one is terminating, and an eviction or a node drain replaces a
pod the same way, while the old one stops its manager and drains its fences
(cmd/flux-plunger/main.go). What keeps a single writer is the leader Lease
(--leader-elect), which the old pod holds through the drain and which outlasts
it, so the next pod waits for it before it acts. maxSurge 0 only keeps a rollout
from starting the next pod before the old one is told to stop. This stays
RollingUpdate rather than Recreate because existing installs carry the
apiserver-defaulted rollingUpdate block (the chart shipped without a strategy),
and helm-controller applies server-side, where type Recreate over that block is
rejected on upgrade.
*/}}
{{- $grace := int .Values.shutdownGracePeriodSeconds }}
{{- if or (lt $grace 40) (gt $grace 140) }}
{{- fail "shutdownGracePeriodSeconds must be between 40 and 140: below, the drain gets no time after the manager's 10s stop; above, the pre-delete hook cannot wait the pod out inside its deadline" }}
{{- end }}
{{- if ne (toString .Values.shutdownGracePeriodSeconds) (toString $grace) }}
{{- fail "shutdownGracePeriodSeconds must be a whole number of seconds: terminationGracePeriodSeconds takes an integer" }}
{{- end }}
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
selector:
matchLabels:
app.kubernetes.io/name: flux-plunger
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: flux-plunger
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
serviceAccountName: flux-plunger
terminationGracePeriodSeconds: {{ .Values.shutdownGracePeriodSeconds }}
containers:
- name: flux-plunger
image: "{{ .Values.image }}"
args:
{{- if .Values.debug }}
- --zap-log-level=debug
{{- else }}
- --zap-log-level=info
{{- end }}
- --metrics-bind-address=:8080
- --metrics-secure=false
- --leader-elect
# The manager's stop takes up to 10s; the rest leaves 15s before SIGKILL.
- --shutdown-drain-timeout={{ sub .Values.shutdownGracePeriodSeconds 25 }}s
ports:
- name: metrics
containerPort: 8080
- name: health
containerPort: 8081
livenessProbe:
httpGet:
path: /healthz
port: health
initialDelaySeconds: 15
periodSeconds: 20
readinessProbe:
httpGet:
path: /readyz
port: health
initialDelaySeconds: 5
periodSeconds: 10
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 10m
memory: 64Mi