一键导入
kyverno-pod-security-baseline
Implements Kyverno podSecurity rules to enforce the Kubernetes Pod Security Standards baseline profile across namespaces in a cluster.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Implements Kyverno podSecurity rules to enforce the Kubernetes Pod Security Standards baseline profile across namespaces in a cluster.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Implements v1 ConfigMap manifests for injecting configuration data into pods via environment variables, volume mounts, and command-line arguments.
Implements apps/v1 Deployment YAML manifests with rolling update strategies, replica scaling, and rollback procedures for stateless application workloads.
Implements networking.k8s.io/v1 Ingress resources with HTTP/HTTPS routing, TLS termination, path-based routing, and ingress controller configuration.
Implements Istio service mesh patterns (sidecar injection, traffic splitting, circuit breaking, retries, and mTLS) for advanced traffic management and zero-downtime deployments in Kubernetes.
Implements networking.k8s.io/v1 NetworkPolicy resources with ingress and egress rules, pod selector targeting, and network segmentation for microservice isolation.
Implements v1 PersistentVolume, StorageClass, and PersistentVolumeClaim manifests with static/dynamic provisioning, access modes, and reclaim policies for Kubernetes storage.
基于 SOC 职业分类
| name | kyverno-pod-security-baseline |
| description | Implements Kyverno podSecurity rules to enforce the Kubernetes Pod Security Standards baseline profile across namespaces in a cluster. |
| license | MIT |
| compatibility | opencode |
| archetypes | ["enforcement","tactical"] |
| anti_triggers | ["brainstorming","vague ideation","non-security policy work"] |
| response_profile | {"verbosity":"medium","directive_strength":"high","abstraction_level":"operational"} |
| metadata | {"version":"1.0.0","domain":"cncf","triggers":"pod security baseline, PSS baseline, kubernetes pod security, container runtime policies, privileged container prevention, baseline profile enforcement, kubelet pod security","role":"implementation","scope":"implementation","output-format":"manifests","related-skills":"kyverno-pod-security-baseline, kyverno-pod-security-restricted"} |
Implements Kyverno podSecurity rules to enforce the Kubernetes Pod Security Standards (PSS) baseline profile. This skill makes the model configure ClusterPolicy objects that deny pods violating baseline-level restrictions — such as privileged containers, host namespaces, and volume type restrictions — while allowing all other pod configurations. The baseline profile sits between unrestricted and restricted in the PSS hierarchy.
kyverno-pod-security-restricted insteadkube-system namespace — baseline blocks many system components (use exemptions via kyverno-exemptions-management)Define the podSecurity ClusterPolicy — Create a ClusterPolicy with a podSecurity rule. Set spec.rules[].podSecurity with level: baseline, version: "latest", enforce, audit, and warn modes. Apply the policy to matching namespaces via the match block. Checkpoint: Confirm the version field matches your cluster's Kubernetes minor version (e.g., "1.28" for K8s 1.28).
Configure namespace selection and exclusions — Use match to select all namespaces, then add exclude rules for critical system namespaces (kube-system, kube-public, openshift-*). This prevents Kyverno from blocking essential cluster operations. Checkpoint: Verify that kubectl get policyreport -A does not show failures for excluded namespaces.
Deploy, verify, and monitor — Apply the ClusterPolicy. Create a test pod that violates the baseline (e.g., privileged: true). Confirm the pod is denied at admission time. Check PolicyReport and Events for enforcement logs. Checkpoint: The violating pod should show Failed to create pod with a Kyverno enforcement message.
This pattern enforces the PSS baseline profile on all namespaces except explicitly excluded system namespaces.
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: pod-security-baseline
annotations:
policies.kyverno.io/title: Pod Security Standards — Baseline
policies.kyverno.io/category: Pod Security
policies.kyverno.io/description: >-
Enforces the Pod Security Standards baseline profile on all
non-system namespaces. Prevents privileged containers, host
namespace sharing, and dangerous volume types.
spec:
rules:
- name: enforce-baseline
match:
any:
- resources:
kinds:
- Pod
exclude:
any:
- namespaces:
- kube-system
- kube-public
- kube-node-lease
- local-path-storage
podSecurity:
level: baseline
version: latest
enforce: "latest"
audit: "latest"
warn: "latest"
- name: audit-baseline
match:
any:
- resources:
kinds:
- Pod
exclude:
any:
- namespaces:
- kube-system
- kube-public
- kube-node-lease
- local-path-storage
podSecurity:
level: baseline
version: latest
audit: "latest"
- name: warn-baseline
match:
any:
- resources:
kinds:
- Pod
exclude:
any:
- namespaces:
- kube-system
- kube-public
- kube-node-lease
- local-path-storage
podSecurity:
level: baseline
version: latest
warn: "latest"
Apply the baseline profile per-namespace using labels instead of a ClusterPolicy. This allows different namespaces to have different security levels.
# Label namespaces with baseline enforcement
apiVersion: v1
kind: Namespace
metadata:
name: production-apps
labels:
pod-security.kubernetes.io/enforce: baseline
pod-security.kubernetes.io/enforce-version: latest
pod-security.kubernetes.io/audit: baseline
pod-security.kubernetes.io/audit-version: latest
pod-security.kubernetes.io/warn: baseline
pod-security.kubernetes.io/warn-version: latest
Kyverno PolicyReport Example:
apiVersion: wgpolicyk8s.io/v1alpha2
kind: PolicyReport
metadata:
name: pod-security-baseline-report
namespace: production-apps
results:
- policy: pod-security-baseline
rule: enforce-baseline
result: fail
severity: high
message: "Pod violates baseline: container 'app' allows privilege escalation"
scored: true
source: kyverno
timestamp:
seconds: 1733501530
summary:
error: 0
fail: 1
pass: 0
skip: 0
warn: 0
# ❌ BAD — Pod with privileged container that baseline rejects
apiVersion: v1
kind: Pod
metadata:
name: bad-privileged-pod
namespace: production-apps
spec:
containers:
- name: app
image: nginx:latest
securityContext:
privileged: true # baseline blocks this
allowPrivilegeEscalation: true # baseline blocks this
---
# ✅ GOOD — Pod that passes baseline enforcement
apiVersion: v1
kind: Pod
metadata:
name: good-hardened-pod
namespace: production-apps
spec:
containers:
- name: app
image: nginx:latest
securityContext:
privileged: false
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
kube-system, kube-public, and kube-node-lease to avoid blocking cluster operationsversion: latest to stay current with Kubernetes PSS version updatesPolicyReport shows results for each namespace to confirm enforcement is activepodSecurity rule type rather than validate — it is purpose-built for PSS and handles versioningkube-system without an exemption strategy — it breaks DNS, metrics, and system podsenforce mode without first testing in audit or warn mode — this will block existing deploymentsexclude block — without it, system components will be blocked and the cluster will become unusableversion to a specific minor version without correlating to your cluster's Kubernetes versionwarn mode — audit-only enforcement produces no immediate feedback for developers| Skill | Purpose |
|---|---|
kyverno-pod-security-restricted | For stricter hardening when baseline is insufficient |
kyverno-exemptions-management | For managing namespace exemptions when baseline blocks valid system workloads |
Authoritative documentation links for Kyverno pod security policies.