agentleFS
autheggauthegg/agent-skills/skills/kubernetes-pod-security/SKILL.md

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".

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
  1. Distinctive:

    HIGH: No SecurityContext, missing resource limits, no NetworkPolicy, default service account with token

    line 205

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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)

  1. Run as non-root:
    securityContext:
      runAsNonRoot: true
      runAsUser: 1000
      runAsGroup: 1000
  2. Read-only root filesystem:
    securityContext:
      readOnlyRootFilesystem: true
  3. Drop all capabilities:
    securityContext:
      capabilities:
        drop: ["ALL"]
        add: ["NET_BIND_SERVICE"]  # Only if needed
  4. Disallow privilege escalation:
    securityContext:
      allowPrivilegeEscalation: false
  5. Use seccomp profile:
    securityContext:
      seccompProfile:
        type: RuntimeDefault

Resource Management (Required)

  1. CPU and memory limits on every container:
    resources:
      requests:
        cpu: "100m"
        memory: "128Mi"
      limits:
        cpu: "500m"
        memory: "512Mi"
  2. Never use resources: {} or omit resources entirely.

Image Security

  1. Pin images by digest:
    image: nginx@sha256:abc123...
  2. Always set imagePullPolicy:
    imagePullPolicy: Always  # For mutable tags
  3. Use private registries with imagePullSecrets.

RBAC (Least Privilege)

  1. Never bind ClusterAdmin to service accounts.
  2. Use Role (namespaced) over ClusterRole where possible.
  3. Avoid wildcards in RBAC rules: No verbs: ["*"] or resources: ["*"].
  4. ServiceAccount per workload — don't use the default service account:
    automountServiceAccountToken: false  # Unless needed

Network

  1. 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"]
  2. No hostNetwork, hostPID, or hostIPC:
    spec:
      hostNetwork: false
      hostPID: false
      hostIPC: false

Secrets

  1. Never put secrets in env vars from ConfigMaps — use Kubernetes Secrets or external secret operators.
  2. Never hardcode secrets in manifests — use SealedSecrets, ExternalSecrets, or Vault.
  3. Enable encryption at rest for etcd.

Pod Security Standards (PSS)

  1. 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

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.