diff --git a/helm/kmcp/templates/deployment.yaml b/helm/kmcp/templates/deployment.yaml index bb044fc..41fb261 100644 --- a/helm/kmcp/templates/deployment.yaml +++ b/helm/kmcp/templates/deployment.yaml @@ -79,6 +79,10 @@ spec: affinity: {{- toYaml . | nindent 8 }} {{- end }} + {{- with .Values.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml . | nindent 8 }} + {{- end }} {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} diff --git a/helm/kmcp/tests/__snapshot__/deployment_test.yaml.snap b/helm/kmcp/tests/__snapshot__/deployment_test.yaml.snap index f7bf18a..adcef17 100644 --- a/helm/kmcp/tests/__snapshot__/deployment_test.yaml.snap +++ b/helm/kmcp/tests/__snapshot__/deployment_test.yaml.snap @@ -555,6 +555,91 @@ should include tolerations when specified: operator: Equal value: value volumes: [] +should include topologySpreadConstraints when specified: + 1: | + apiVersion: apps/v1 + kind: Deployment + metadata: + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: kmcp + control-plane: controller-manager + helm.sh/chart: kmcp-1.0.0 + name: RELEASE-NAME-controller-manager + namespace: NAMESPACE + spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/name: kmcp + control-plane: controller-manager + template: + metadata: + annotations: + kubectl.kubernetes.io/default-container: manager + labels: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/name: kmcp + control-plane: controller-manager + spec: + containers: + - args: + - --leader-elect + - --health-probe-bind-address=:8081 + - --metrics-bind-address=:8443 + command: + - /manager + image: test-repo:v1.0.0 + imagePullPolicy: IfNotPresent + livenessProbe: + httpGet: + path: /healthz + port: health + initialDelaySeconds: 15 + periodSeconds: 20 + name: manager + ports: + - containerPort: 8443 + name: metrics + protocol: TCP + - containerPort: 8081 + name: health + protocol: TCP + readinessProbe: + httpGet: + path: /readyz + port: health + initialDelaySeconds: 5 + periodSeconds: 10 + resources: + limits: + cpu: 500m + memory: 128Mi + requests: + cpu: 10m + memory: 64Mi + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + volumeMounts: [] + securityContext: + runAsNonRoot: true + seccompProfile: + type: RuntimeDefault + serviceAccountName: RELEASE-NAME-controller-manager + terminationGracePeriodSeconds: 10 + topologySpreadConstraints: + - labelSelector: + matchLabels: + app.kubernetes.io/name: kmcp + maxSkew: 1 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: DoNotSchedule + volumes: [] should set custom replica count: 1: | apiVersion: apps/v1 diff --git a/helm/kmcp/tests/deployment_test.yaml b/helm/kmcp/tests/deployment_test.yaml index d17d730..e61b4e4 100644 --- a/helm/kmcp/tests/deployment_test.yaml +++ b/helm/kmcp/tests/deployment_test.yaml @@ -116,6 +116,23 @@ tests: count: 1 - matchSnapshot: {} + - it: should include topologySpreadConstraints when specified + template: deployment.yaml + set: + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: topology.kubernetes.io/zone + whenUnsatisfiable: DoNotSchedule + labelSelector: + matchLabels: + app.kubernetes.io/name: kmcp + image.repository: test-repo + image.tag: v1.0.0 + asserts: + - hasDocuments: + count: 1 + - matchSnapshot: {} + - it: should set security context template: deployment.yaml set: diff --git a/helm/kmcp/values.yaml b/helm/kmcp/values.yaml index efd8b7d..70680e2 100644 --- a/helm/kmcp/values.yaml +++ b/helm/kmcp/values.yaml @@ -81,6 +81,9 @@ tolerations: [] # Affinity affinity: {} +# Topology Spread Constraints +topologySpreadConstraints: [] + # Service account configuration serviceAccount: # Specifies whether a service account should be created