diff --git a/prototypes/argocd/ytt/ns.ytt.yaml b/prototypes/argocd/ytt/ns.ytt.yaml index f66069b..1bc2a22 100644 --- a/prototypes/argocd/ytt/ns.ytt.yaml +++ b/prototypes/argocd/ytt/ns.ytt.yaml @@ -9,7 +9,7 @@ kind: Namespace metadata: name: #@ ns labels: - pod-security.kubernetes.io/enforce: privileged + pod-security.kubernetes.io/enforce: restricted #@overlay/match by=overlay.all, expects="1+" --- diff --git a/prototypes/cert-manager/ytt/ns.ytt.yaml b/prototypes/cert-manager/ytt/ns.ytt.yaml index f66069b..1bc2a22 100644 --- a/prototypes/cert-manager/ytt/ns.ytt.yaml +++ b/prototypes/cert-manager/ytt/ns.ytt.yaml @@ -9,7 +9,7 @@ kind: Namespace metadata: name: #@ ns labels: - pod-security.kubernetes.io/enforce: privileged + pod-security.kubernetes.io/enforce: restricted #@overlay/match by=overlay.all, expects="1+" --- diff --git a/prototypes/cloudnative-pg/ytt/ns.ytt.yaml b/prototypes/cloudnative-pg/ytt/ns.ytt.yaml index f66069b..1bc2a22 100644 --- a/prototypes/cloudnative-pg/ytt/ns.ytt.yaml +++ b/prototypes/cloudnative-pg/ytt/ns.ytt.yaml @@ -9,7 +9,7 @@ kind: Namespace metadata: name: #@ ns labels: - pod-security.kubernetes.io/enforce: privileged + pod-security.kubernetes.io/enforce: restricted #@overlay/match by=overlay.all, expects="1+" --- diff --git a/prototypes/ocis/ytt/external-secret-precheck-job.ytt.yaml b/prototypes/ocis/ytt/external-secret-precheck-job.ytt.yaml index 694dd6d..49a8f78 100644 --- a/prototypes/ocis/ytt/external-secret-precheck-job.ytt.yaml +++ b/prototypes/ocis/ytt/external-secret-precheck-job.ytt.yaml @@ -60,6 +60,12 @@ spec: spec: serviceAccountName: ocis-external-secret-precheck restartPolicy: OnFailure + securityContext: + runAsNonRoot: true + runAsUser: 65532 + runAsGroup: 65532 + seccompProfile: + type: RuntimeDefault containers: - name: precheck image: alpine/k8s:1.32.3 @@ -80,3 +86,9 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: + drop: + - ALL diff --git a/prototypes/ocis/ytt/ns.ytt.yaml b/prototypes/ocis/ytt/ns.ytt.yaml index f66069b..1bc2a22 100644 --- a/prototypes/ocis/ytt/ns.ytt.yaml +++ b/prototypes/ocis/ytt/ns.ytt.yaml @@ -9,7 +9,7 @@ kind: Namespace metadata: name: #@ ns labels: - pod-security.kubernetes.io/enforce: privileged + pod-security.kubernetes.io/enforce: restricted #@overlay/match by=overlay.all, expects="1+" --- diff --git a/prototypes/ocis/ytt/pss-restricted.ytt.yaml b/prototypes/ocis/ytt/pss-restricted.ytt.yaml new file mode 100644 index 0000000..ca21d34 --- /dev/null +++ b/prototypes/ocis/ytt/pss-restricted.ytt.yaml @@ -0,0 +1,62 @@ +#@ load("@ytt:overlay", "overlay") + +#@ helm_match = overlay.subset({"metadata": {"labels": {"app.kubernetes.io/managed-by": "Helm"}}}) + +#@overlay/match by=overlay.and_op(overlay.subset({"kind": "Deployment"}), helm_match), expects="1+" +--- +spec: + template: + spec: + securityContext: + #@overlay/match missing_ok=True + seccompProfile: + type: RuntimeDefault + containers: + #@overlay/match by=overlay.all, expects="1+" + - + securityContext: + #@overlay/match missing_ok=True + allowPrivilegeEscalation: false + #@overlay/match missing_ok=True + capabilities: + drop: + - ALL + +#! idm is the only chart Deployment with initContainers +#@overlay/match by=overlay.subset({"kind": "Deployment", "metadata": {"name": "idm"}}) +--- +spec: + template: + spec: + initContainers: + #@overlay/match by=overlay.all, expects="1+" + - + securityContext: + #@overlay/match missing_ok=True + allowPrivilegeEscalation: false + #@overlay/match missing_ok=True + capabilities: + drop: + - ALL + +#@overlay/match by=overlay.and_op(overlay.subset({"kind": "CronJob"}), helm_match), expects="1+" +--- +spec: + jobTemplate: + spec: + template: + spec: + securityContext: + #@overlay/match missing_ok=True + seccompProfile: + type: RuntimeDefault + containers: + #@overlay/match by=overlay.all, expects="1+" + - + securityContext: + #@overlay/match missing_ok=True + allowPrivilegeEscalation: false + #@overlay/match missing_ok=True + capabilities: + drop: + - ALL diff --git a/prototypes/ocis/ytt/s3-backup-cronjob.ytt.yaml b/prototypes/ocis/ytt/s3-backup-cronjob.ytt.yaml index 329d2e0..b6e79cc 100644 --- a/prototypes/ocis/ytt/s3-backup-cronjob.ytt.yaml +++ b/prototypes/ocis/ytt/s3-backup-cronjob.ytt.yaml @@ -27,74 +27,76 @@ spec: spec: restartPolicy: OnFailure serviceAccountName: ocis-s3-backup + securityContext: + runAsNonRoot: true + runAsUser: 1009 + runAsGroup: 1009 + seccompProfile: + type: RuntimeDefault containers: - name: backup - image: alpine:3.20 + image: rclone/rclone:1.69.0 + args: + - sync + - "s3:ocis-tr1ceracop" + - "backup:" + - --transfers=4 + - -v resources: requests: memory: 128Mi cpu: 50m - command: - - sh - - -c - - | - set -e - apk add --no-cache rclone >/dev/null 2>&1 - - mkdir -p /tmp/rclone - cat > /tmp/rclone/rclone.conf </dev/null 2>&1 - - mkdir -p /tmp/rclone - cat > /tmp/rclone/rclone.conf <