Updated on 2024-02-01 GMT+08:00

k8spspseccomp

Basic Information

  • Policy type: security
  • Recommended level: L3
  • Effective resource type: Pod
  • Parameter

    allowedLocalhostFiles: Array

    allowedProfiles: Array

    exemptImages: String array

Function

This policy restricts the seccomp.security.alpha.kubernetes.io/allowedProfileNames annotation in PodSecurityPolicy.

Policy Example

The following policy instance shows the types of resources for which the policy definition takes effect. allowedProfiles in parameters defines the allowed annotations.

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: K8sPSPSeccomp
metadata:
  name: psp-seccomp
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
  parameters:
    allowedProfiles:
    - runtime/default
    - docker/default

Resource Definition That Complies with the Policy

In the example, the value of the container.seccomp.security.alpha.kubernetes.io/nginx annotation is in the specified value list and complies with the policy definition.

apiVersion: v1
kind: Pod
metadata:
  name: nginx-seccomp-allowed
  annotations:
    container.seccomp.security.alpha.kubernetes.io/nginx: runtime/default
  labels:
    app: nginx-seccomp
spec:
  containers:
  - name: nginx
    image: nginx

Resource Definition That Does Not Comply with the Policy

In the example, the value of the container.seccomp.security.alpha.kubernetes.io/nginx annotation is not in the configured value list and does not comply with the policy definition.

apiVersion: v1
kind: Pod
metadata:
  name: nginx-seccomp-disallowed
  annotations:
    container.seccomp.security.alpha.kubernetes.io/nginx: unconfined
  labels:
    app: nginx-seccomp
spec:
  containers:
  - name: nginx
    image: nginx