kubernetes-pod-security
Skill2 starsChanged 9 months agoMITView on GitHub
Enforce Kubernetes pod and workload security best practices. Use when creating or editing Kubernetes manifests, Helm charts, or Kustomize overlays involving pods, deployments, statefulsets, daemonsets, jobs, or cronjobs. Covers Pod Security Standards (Restricted), SecurityContext hardening, RBAC least privilege, network policies, resource quotas, and admission control. Activates on keywords like "pod security", "K8s manifest", "deployment.yaml", "Helm chart", "securityContext", or "RBAC".
In this repository4 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- ci-security-pipelineSkill
- docker-security-hardeningSkill
- secrets-managementSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 205
HIGH: No SecurityContext, missing resource limits, no NetworkPolicy, default service account with token
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Kubernetes Pod Security
Enforce Kubernetes pod and workload security using Pod Security Standards (PSS), CIS Kubernetes Benchmark, and NSA/CISA Kubernetes Hardening Guide.
When to Use
- Creating or editing Kubernetes Deployments, StatefulSets, DaemonSets, Jobs, CronJobs
- Writing Helm charts or Kustomize overlays
- Configuring RBAC roles and bindings
- Setting up NetworkPolicies
- Reviewing manifests before production deployment
Pod Security Checklist — Apply to Every Workload
SecurityContext (Required on Every Pod/Container)
- Run as non-root:
securityContext: runAsNonRoot: true runAsUser: 1000 runAsGroup: 1000 - Read-only root filesystem:
securityContext: readOnlyRootFilesystem: true - Drop all capabilities:
securityContext: capabilities: drop: ["ALL"] add: ["NET_BIND_SERVICE"] # Only if needed - Disallow privilege escalation:
securityContext: allowPrivilegeEscalation: false - Use seccomp profile:
securityContext: seccompProfile: type: RuntimeDefault
Resource Management (Required)
- CPU and memory limits on every container:
resources: requests: cpu: "100m" memory: "128Mi" limits: cpu: "500m" memory: "512Mi" - Never use
resources: {}or omit resources entirely.
Image Security
- Pin images by digest:
image: nginx@sha256:abc123... - Always set imagePullPolicy:
imagePullPolicy: Always # For mutable tags - Use private registries with imagePullSecrets.
RBAC (Least Privilege)
- Never bind ClusterAdmin to service accounts.
- Use Role (namespaced) over ClusterRole where possible.
- Avoid wildcards in RBAC rules: No
verbs: ["*"]orresources: ["*"]. - ServiceAccount per workload — don't use the
defaultservice account:automountServiceAccountToken: false # Unless needed
Network
- NetworkPolicy for every namespace — default deny ingress/egress, then allow explicitly:
apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: default-deny-all spec: podSelector: {} policyTypes: ["Ingress", "Egress"] - No hostNetwork, hostPID, or hostIPC:
spec: hostNetwork: false hostPID: false hostIPC: false
Secrets
- Never put secrets in env vars from ConfigMaps — use Kubernetes Secrets or external secret operators.
- Never hardcode secrets in manifests — use SealedSecrets, ExternalSecrets, or Vault.
- Enable encryption at rest for etcd.
Pod Security Standards (PSS)
- Target "Restricted" profile for production namespaces:
apiVersion: v1 kind: Namespace metadata: labels: pod-security.kubernetes.io/enforce: restricted pod-security.kubernetes.io/warn: restricted pod-security.kubernetes.io/audit: restricted
Secure Deployment Template
apiVersion: apps/v1
kind: Deployment
metadata:
name: secure-app
spec:
replicas: 2
selector:
matchLabels:
app: secure-app
template:
metadata:
labels:
app: secure-app
spec:
automountServiceAccountToken: false
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: app
image: myapp@sha256:abc123...
imagePullPolicy: Always
ports:
- containerPort: 8080
protocol: TCP
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "500m"
memory: "512Mi"
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 10
periodSeconds: 15
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
volumeMounts:
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
emptyDir:
sizeLimit: "100Mi"Severity Classification
- CRITICAL: Running as root, privileged containers, hostPID/hostNetwork, wildcard RBAC
- HIGH: No SecurityContext, missing resource limits, no NetworkPolicy, default service account with token
- MEDIUM: Missing probes, no seccomp profile, mutable image tags
- LOW: Missing pod disruption budgets, no topology spread, missing labels
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

