Skip to content

Agent Mesh

charts: run the sam pods under the restricted Pod Security Standard

Tomas Tormoca94afaa8dac
diff --git a/charts/sam-mesh/templates/bootstrap-job.yaml b/charts/sam-mesh/templates/bootstrap-job.yaml
index e93e06ad..00a9da80 100644
--- a/charts/sam-mesh/templates/bootstrap-job.yaml
+++ b/charts/sam-mesh/templates/bootstrap-job.yaml
@@ -49,10 +49,20 @@ spec:
spec:
serviceAccountName: {{ include "sam-mesh.fullname" . }}-bootstrap-sa
restartPolicy: OnFailure
+ securityContext:
+ runAsNonRoot: true
+ # curlimages/curl's USER is non-numeric; runAsNonRoot needs an explicit uid.
+ runAsUser: 100
+ seccompProfile:
+ type: RuntimeDefault
containers:
- name: bootstrap
image: curlimages/curl:8.6.0
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
+ securityContext:
+ allowPrivilegeEscalation: false
+ capabilities:
+ drop: ["ALL"]
env:
- name: NAMESPACE
value: {{ .Release.Namespace | quote }}
diff --git a/charts/sam-mesh/templates/console-deployment.yaml b/charts/sam-mesh/templates/console-deployment.yaml
index c3f22ce3..c65abf42 100644
--- a/charts/sam-mesh/templates/console-deployment.yaml
+++ b/charts/sam-mesh/templates/console-deployment.yaml
@@ -15,10 +15,20 @@ spec:
labels:
app: {{ include "sam-mesh.fullname" . }}-console
spec:
+ {{- with .Values.console.podSecurityContext }}
+ securityContext:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
initContainers:
- name: wait-control-plane
image: curlimages/curl:8.6.0
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
+ securityContext:
+ # curlimages/curl's USER is non-numeric; runAsNonRoot needs an explicit uid.
+ runAsUser: 100
+ allowPrivilegeEscalation: false
+ capabilities:
+ drop: ["ALL"]
command: ["/bin/sh", "-c"]
args:
- |
@@ -32,6 +42,10 @@ spec:
- name: sam-console
image: "{{ .Values.console.image.repository }}:{{ .Values.global.imageTag }}"
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
+ {{- with .Values.console.securityContext }}
+ securityContext:
+ {{- toYaml . | nindent 10 }}
+ {{- end }}
env:
- name: SAM_ADMIN_TOKEN
valueFrom:
diff --git a/charts/sam-mesh/templates/control-plane-deployment.yaml b/charts/sam-mesh/templates/control-plane-deployment.yaml
index 9897cc55..8c22c40a 100644
--- a/charts/sam-mesh/templates/control-plane-deployment.yaml
+++ b/charts/sam-mesh/templates/control-plane-deployment.yaml
@@ -14,10 +14,18 @@ spec:
labels:
app: {{ include "sam-mesh.fullname" . }}-control-plane
spec:
+ {{- with .Values.controlPlane.podSecurityContext }}
+ securityContext:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
containers:
- name: sam-control-plane
image: "{{ .Values.controlPlane.image.repository }}:{{ .Values.global.imageTag }}"
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
+ {{- with .Values.controlPlane.securityContext }}
+ securityContext:
+ {{- toYaml . | nindent 10 }}
+ {{- end }}
env:
- name: DB_PASSWORD
valueFrom:
diff --git a/charts/sam-mesh/templates/router-statefulset.yaml b/charts/sam-mesh/templates/router-statefulset.yaml
index f07b0fd4..c32c9ee1 100644
--- a/charts/sam-mesh/templates/router-statefulset.yaml
+++ b/charts/sam-mesh/templates/router-statefulset.yaml
@@ -36,6 +36,12 @@ spec:
- name: wait-control-plane
image: curlimages/curl:8.6.0
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
+ securityContext:
+ # curlimages/curl's USER is non-numeric; runAsNonRoot needs an explicit uid.
+ runAsUser: 100
+ allowPrivilegeEscalation: false
+ capabilities:
+ drop: ["ALL"]
command: ["/bin/sh", "-c"]
args:
- |
@@ -49,6 +55,10 @@ spec:
- name: sam-router
image: "{{ .Values.router.image.repository }}:{{ .Values.global.imageTag }}"
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
+ {{- with .Values.router.securityContext }}
+ securityContext:
+ {{- toYaml . | nindent 10 }}
+ {{- end }}
ports:
- containerPort: 4501
name: p2p-tcp
diff --git a/charts/sam-mesh/values.yaml b/charts/sam-mesh/values.yaml
index 33e6217e..4b3a2db1 100644
--- a/charts/sam-mesh/values.yaml
+++ b/charts/sam-mesh/values.yaml
@@ -45,6 +45,17 @@ controlPlane:
# (comma-separated for more than one); the control plane refuses to start without one.
oidcIssuer: ""
allowedAudiences: "sam-mesh-audience,sam-control-plane-audience"
+ podSecurityContext:
+ runAsNonRoot: true
+ # Dockerfiles say "USER nonroot" by name; runAsNonRoot needs the numeric uid.
+ runAsUser: 65532
+ runAsGroup: 65532
+ seccompProfile:
+ type: RuntimeDefault
+ securityContext:
+ allowPrivilegeEscalation: false
+ capabilities:
+ drop: ["ALL"]
resources:
requests:
cpu: 100m
@@ -84,8 +95,18 @@ router:
enabled: true
replicaCount: 1
podSecurityContext:
+ runAsNonRoot: true
+ # Dockerfiles say "USER nonroot" by name; runAsNonRoot needs the numeric uid.
+ runAsUser: 65532
+ runAsGroup: 65532
+ seccompProfile:
+ type: RuntimeDefault
fsGroup: 65532
fsGroupChangePolicy: "OnRootMismatch"
+ securityContext:
+ allowPrivilegeEscalation: false
+ capabilities:
+ drop: ["ALL"]
image:
repository: sam-router
useOidcToken: false
@@ -113,6 +134,17 @@ console:
replicaCount: 1
image:
repository: sam-console
+ podSecurityContext:
+ runAsNonRoot: true
+ # Dockerfiles say "USER nonroot" by name; runAsNonRoot needs the numeric uid.
+ runAsUser: 65532
+ runAsGroup: 65532
+ seccompProfile:
+ type: RuntimeDefault
+ securityContext:
+ allowPrivilegeEscalation: false
+ capabilities:
+ drop: ["ALL"]
resources:
requests:
cpu: 50m