Skip to content

Agent Mesh

charts: disable surge when controlPlane.hostPort is set

Tomas Tormo678ea5f854d2
diff --git a/charts/sam-mesh/templates/control-plane-deployment.yaml b/charts/sam-mesh/templates/control-plane-deployment.yaml
index 2f371037..96d76d8d 100644
--- a/charts/sam-mesh/templates/control-plane-deployment.yaml
+++ b/charts/sam-mesh/templates/control-plane-deployment.yaml
@@ -6,6 +6,14 @@ metadata:
{{- include "sam-mesh.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.controlPlane.replicaCount }}
+ {{- if .Values.controlPlane.hostPort }}
+ # hostPort: a surged pod can't bind a port the old pod still holds, so the
+ # default maxSurge=1 deadlocks the rollout on port-saturated nodes.
+ strategy:
+ rollingUpdate:
+ maxSurge: 0
+ maxUnavailable: 1
+ {{- end }}
selector:
matchLabels:
app: {{ include "sam-mesh.fullname" . }}-control-plane
diff --git a/charts/sam-mesh/tests/control-plane-deployment_test.yaml b/charts/sam-mesh/tests/control-plane-deployment_test.yaml
index 7b9f34d4..238f010b 100644
--- a/charts/sam-mesh/tests/control-plane-deployment_test.yaml
+++ b/charts/sam-mesh/tests/control-plane-deployment_test.yaml
@@ -26,6 +26,24 @@ tests:
path: spec.template.metadata.annotations["checksum/secrets"]
pattern: ^[0-9a-f]{64}$
+ - it: hostPort disables surge so rollouts can rebind the node port
+ template: templates/control-plane-deployment.yaml
+ set:
+ controlPlane.hostPort: 8080
+ asserts:
+ - equal:
+ path: spec.strategy.rollingUpdate.maxSurge
+ value: 0
+ - equal:
+ path: spec.strategy.rollingUpdate.maxUnavailable
+ value: 1
+
+ - it: no strategy override without hostPort
+ template: templates/control-plane-deployment.yaml
+ asserts:
+ - notExists:
+ path: spec.strategy
+
- it: uses the default image tag when none is pinned
template: templates/control-plane-deployment.yaml
asserts: