Pod OS — control operating system for Pod security.
1apiVersion: v12kind: Pod3metadata:4 name: secure-pod5spec:6 os:7 name: linux8 securityContext:9 runAsNonRoot: true10 runAsUser: 100011 runAsGroup: 100012 fsGroup: 100013 fsGroupChangePolicy: OnRootMismatch14 seccompProfile:15 type: RuntimeDefault16 containers:17 - name: app18 image: nginx:latest19 securityContext:20 allowPrivilegeEscalation: false21 readOnlyRootFilesystem: true22 capabilities:23 drop:24 - ALL25 add:26 - NET_BIND_SERVICE27 volumeMounts:28 - name: tmp29 mountPath: /tmp30 - name: nginx-cache31 mountPath: /var/cache/nginx32 - name: nginx-run33 mountPath: /var/run34 volumes:35 - name: tmp36 emptyDir: {}37 - name: nginx-cache38 emptyDir: {}39 - name: nginx-run40 emptyDir: {}41---42# Windows Pod security43apiVersion: v144kind: Pod45metadata:46 name: windows-pod47spec:48 os:49 name: windows50 securityContext:51 windowsOptions:52 runAsUserName: "ContainerUser"53 containers:54 - name: app55 image: mcr.microsoft.com/dotnet/runtime:8.0
1# Check Pod security2kubectl get pod secure-pod -o jsonpath='{.spec.securityContext}' | jq3kubectl get pod secure-pod -o jsonpath='{.spec.containers[0].securityContext}' | jq45# Verify non-root6kubectl exec secure-pod -- id7kubectl exec secure-pod -- whoami89# Check seccomp profile10kubectl get pod secure-pod -o jsonpath='{.spec.securityContext.seccompProfile}' | jq1112# Check capabilities13kubectl exec secure-pod -- cat /proc/1/status | grep Cap
Linux Security:
Windows Security: