[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7F190RNP04SN68G5PEJG1JY":3,"skill-same:01M7F190RNP04SN68G5PEJG1JY":59},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":14,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M7F190RNP04SN68G5PEJG1JY","k8s-security-policies",null,"Implement Kubernetes security policies with Pod Security Admission, NetworkPolicy, RBAC and pod security contexts. Use when securing Kubernetes clusters, implementing network isolation, enforcing pod security standards, or migrating off PodSecurityPolicy.","shotcowboystyle\u002Fag-skills","shotcowboystyle","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F62471?v=4","01M7EZTCFCZJ6K3MYW8BPM4X6R","Curtis Blanton","01M7EZTCG1S5M04J90A931X9BX",0,"MIT","https:\u002F\u002Fgithub.com\u002Fshotcowboystyle\u002Fag-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fkubernetes-operations\u002Fskills\u002Fk8s-security-policies\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: k8s-security-policies\ndescription: Implement Kubernetes security policies with Pod Security Admission, NetworkPolicy, RBAC and pod security contexts. Use when securing Kubernetes clusters, implementing network isolation, enforcing pod security standards, or migrating off PodSecurityPolicy.\nlast_verified: 2026-10-27\n---\n\n# Kubernetes Security Policies\n\nLayered workload security with built-in Kubernetes APIs: Pod Security Admission\n(PSA) for what pods may run, NetworkPolicy for who they may talk to, RBAC for\nwhat identities may do, and security contexts on the pods themselves.\n\nPodSecurityPolicy was removed in Kubernetes 1.25. Pod Security Admission, built\ninto the API server, replaces it. Do not write PSP manifests.\n\n## Procedure\n\n1. **Pick a Pod Security level per namespace.** `restricted` for application\n   namespaces, `baseline` where a workload genuinely needs more, `privileged`\n   only for system namespaces (CNI, storage, node agents).\n2. **Dry-run it before enforcing.** The server reports every existing pod that\n   would violate the level, without changing anything:\n\n   ```bash\n   kubectl label --dry-run=server --overwrite ns production \\\n     pod-security.kubernetes.io\u002Fenforce=restricted\n   ```\n\n3. **Label the namespace** (below). Start with `warn` and `audit` if pods still\n   violate, then add `enforce`.\n4. **Fix pod specs** with a restricted security context (below) until the\n   dry-run is clean.\n5. **Default-deny traffic**, then allow DNS and each required flow\n   (`assets\u002Fnetwork-policy-template.yaml`). Confirm the CNI enforces\n   NetworkPolicy; some do not, and then policies are silently ignored.\n6. **Give each workload its own ServiceAccount** with a namespaced Role that\n   lists only the verbs and resources it uses (`references\u002Frbac-patterns.md`).\n7. **Verify** with `kubectl auth can-i` and a test pod (Troubleshooting).\n\n## Pod Security Admission\n\n```yaml\napiVersion: v1\nkind: Namespace\nmetadata:\n  name: production\n  labels:\n    pod-security.kubernetes.io\u002Fenforce: restricted\n    # Pin the policy version so a cluster upgrade can't tighten it unannounced\n    pod-security.kubernetes.io\u002Fenforce-version: v1.37\n    pod-security.kubernetes.io\u002Fwarn: restricted\n    pod-security.kubernetes.io\u002Fwarn-version: latest\n    pod-security.kubernetes.io\u002Faudit: restricted\n    pod-security.kubernetes.io\u002Faudit-version: latest\n```\n\n`warn` and `audit` at `latest` show what the next policy version will reject\nbefore you move `enforce-version` forward.\n\n## Restricted Pod Security Context\n\nThe minimum a pod needs to pass the `restricted` level:\n\n```yaml\napiVersion: v1\nkind: Pod\nmetadata:\n  name: secure-pod\n  namespace: production\nspec:\n  securityContext:\n    runAsNonRoot: true\n    runAsUser: 1000\n    fsGroup: 1000\n    seccompProfile:\n      type: RuntimeDefault\n  containers:\n    - name: app\n      image: registry.example.com\u002Fmyapp:1.0.0\n      securityContext:\n        allowPrivilegeEscalation: false\n        readOnlyRootFilesystem: true # not required by PSA, but recommended\n        capabilities:\n          drop: [\"ALL\"]\n```\n\n## Network Policies\n\n```yaml\n# Deny all ingress and egress for every pod in the namespace\napiVersion: networking.k8s.io\u002Fv1\nkind: NetworkPolicy\nmetadata:\n  name: default-deny-all\n  namespace: production\nspec:\n  podSelector: {}\n  policyTypes: [\"Ingress\", \"Egress\"]\n---\n# Allow DNS to the cluster DNS pods\napiVersion: networking.k8s.io\u002Fv1\nkind: NetworkPolicy\nmetadata:\n  name: allow-dns\n  namespace: production\nspec:\n  podSelector: {}\n  policyTypes: [\"Egress\"]\n  egress:\n    - to:\n        - namespaceSelector:\n            matchLabels:\n              kubernetes.io\u002Fmetadata.name: kube-system\n          podSelector:\n            matchLabels:\n              k8s-app: kube-dns\n      ports:\n        - protocol: UDP\n          port: 53\n        - protocol: TCP\n          port: 53\n```\n\nSelect namespaces with the `kubernetes.io\u002Fmetadata.name` label, which the API\nserver sets on every namespace. A hand-added `name:` label may not exist. More\nflows (frontend to backend, ingress controller, monitoring, external HTTPS,\ndatabase) are in `assets\u002Fnetwork-policy-template.yaml`.\n\n## RBAC\n\n```yaml\napiVersion: v1\nkind: ServiceAccount\nmetadata:\n  name: my-app\n  namespace: production\nautomountServiceAccountToken: false # opt in per pod only if it calls the API\n---\napiVersion: rbac.authorization.k8s.io\u002Fv1\nkind: Role\nmetadata:\n  name: my-app\n  namespace: production\nrules:\n  - apiGroups: [\"\"]\n    resources: [\"configmaps\"]\n    resourceNames: [\"my-app-config\"]\n    verbs: [\"get\", \"watch\"]\n---\napiVersion: rbac.authorization.k8s.io\u002Fv1\nkind: RoleBinding\nmetadata:\n  name: my-app\n  namespace: production\nsubjects:\n  - kind: ServiceAccount\n    name: my-app\n    namespace: production\nroleRef:\n  kind: Role\n  name: my-app\n  apiGroup: rbac.authorization.k8s.io\n```\n\nPrefer Roles over ClusterRoles, name resources where you can, and avoid `*`.\n`list` and `watch` on Secrets expose every Secret's contents, not only names.\nMore patterns: `references\u002Frbac-patterns.md`.\n\n## Beyond the built-ins\n\n- **Custom admission rules** (required labels, allowed registries):\n  ValidatingAdmissionPolicy (`admissionregistration.k8s.io\u002Fv1`, GA since 1.30)\n  runs CEL in the API server with no extra component. Kyverno or OPA Gatekeeper\n  add mutation, image verification and policy reports.\n- **Service mesh mTLS and L7 authorization**: see the `mtls-configuration`\n  skill in the `cloud-infrastructure` plugin.\n\n## Troubleshooting\n\n```bash\n# Which pods in a namespace would a level reject?\nkubectl label --dry-run=server --overwrite ns \u003Cns> pod-security.kubernetes.io\u002Fenforce=restricted\n\n# Pod rejected at admission: the event names the failing check\nkubectl get events -n \u003Cns> --field-selector reason=FailedCreate\n\n# Effective permissions of a ServiceAccount\nkubectl auth can-i --list --as system:serviceaccount:\u003Cns>:\u003Csa> -n \u003Cns>\n\n# NetworkPolicy has no effect: test from a pod the policy selects\nkubectl run nettest -n \u003Cns> --rm -it --image=busybox:1.37 --labels app=frontend -- \\\n  wget -qO- -T 3 http:\u002F\u002Fbackend:8080\n```\n\n## Related Skills\n\n- `k8s-manifest-generator` - For creating secure manifests\n- `gitops-workflow` - For automated policy deployment\n","# Kubernetes Security Policies\n\nLayered workload security with built-in Kubernetes APIs: Pod Security Admission\n(PSA) for what pods may run, NetworkPolicy for who they may talk to, RBAC for\nwhat identities may do, and security contexts on the pods themselves.\n\nPodSecurityPolicy was removed in Kubernetes 1.25. Pod Security Admission, built\ninto the API server, replaces it. Do not write PSP manifests.\n\n## Procedure\n\n1. **Pick a Pod Security level per namespace.** `restricted` for application\n   namespaces, `baseline` where a workload genuinely needs more, `privileged`\n   only for system namespaces (CNI, storage, node agents).\n2. **Dry-run it before enforcing.** The server reports every existing pod that\n   would violate the level, without changing anything:\n\n   ```bash\n   kubectl label --dry-run=server --overwrite ns production \\\n     pod-security.kubernetes.io\u002Fenforce=restricted\n   ```\n\n3. **Label the namespace** (below). Start with `warn` and `audit` if pods still\n   violate, then add `enforce`.\n4. **Fix pod specs** with a restricted security context (below) until the\n   dry-run is clean.\n5. **Default-deny traffic**, then allow DNS and each required flow\n   (`assets\u002Fnetwork-policy-template.yaml`). Confirm the CNI enforces\n   NetworkPolicy; some do not, and then policies are silently ignored.\n6. **Give each workload its own ServiceAccount** with a namespaced Role that\n   lists only the verbs and resources it uses (`references\u002Frbac-patterns.md`).\n7. **Verify** with `kubectl auth can-i` and a test pod (Troubleshooting).\n\n## Pod Security Admission\n\n```yaml\napiVersion: v1\nkind: Namespace\nmetadata:\n  name: production\n  labels:\n    pod-security.kubernetes.io\u002Fenforce: restricted\n    # Pin the policy version so a cluster upgrade can't tighten it unannounced\n    pod-security.kubernetes.io\u002Fenforce-version: v1.37\n    pod-security.kubernetes.io\u002Fwarn: restricted\n    pod-security.kubernetes.io\u002Fwarn-version: latest\n    pod-security.kubernetes.io\u002Faudit: restricted\n    pod-security.kubernetes.io\u002Faudit-version: latest\n```\n\n`warn` and `audit` at `latest` show what the next policy version will reject\nbefore you move `enforce-version` forward.\n\n## Restricted Pod Security Context\n\nThe minimum a pod needs to pass the `restricted` level:\n\n```yaml\napiVersion: v1\nkind: Pod\nmetadata:\n  name: secure-pod\n  namespace: production\nspec:\n  securityContext:\n    runAsNonRoot: true\n    runAsUser: 1000\n    fsGroup: 1000\n    seccompProfile:\n      type: RuntimeDefault\n  containers:\n    - name: app\n      image: registry.example.com\u002Fmyapp:1.0.0\n      securityContext:\n        allowPrivilegeEscalation: false\n        readOnlyRootFilesystem: true # not required by PSA, but recommended\n        capabilities:\n          drop: [\"ALL\"]\n```\n\n## Network Policies\n\n```yaml\n# Deny all ingress and egress for every pod in the namespace\napiVersion: networking.k8s.io\u002Fv1\nkind: NetworkPolicy\nmetadata:\n  name: default-deny-all\n  namespace: production\nspec:\n  podSelector: {}\n  policyTypes: [\"Ingress\", \"Egress\"]\n---\n# Allow DNS to the cluster DNS pods\napiVersion: networking.k8s.io\u002Fv1\nkind: NetworkPolicy\nmetadata:\n  name: allow-dns\n  namespace: production\nspec:\n  podSelector: {}\n  policyTypes: [\"Egress\"]\n  egress:\n    - to:\n        - namespaceSelector:\n            matchLabels:\n              kubernetes.io\u002Fmetadata.name: kube-system\n          podSelector:\n            matchLabels:\n              k8s-app: kube-dns\n      ports:\n        - protocol: UDP\n          port: 53\n        - protocol: TCP\n          port: 53\n```\n\nSelect namespaces with the `kubernetes.io\u002Fmetadata.name` label, which the API\nserver sets on every namespace. A hand-added `name:` label may not exist. More\nflows (frontend to backend, ingress controller, monitoring, external HTTPS,\ndatabase) are in `assets\u002Fnetwork-policy-template.yaml`.\n\n## RBAC\n\n```yaml\napiVersion: v1\nkind: ServiceAccount\nmetadata:\n  name: my-app\n  namespace: production\nautomountServiceAccountToken: false # opt in per pod only if it calls the API\n---\napiVersion: rbac.authorization.k8s.io\u002Fv1\nkind: Role\nmetadata:\n  name: my-app\n  namespace: production\nrules:\n  - apiGroups: [\"\"]\n    resources: [\"configmaps\"]\n    resourceNames: [\"my-app-config\"]\n    verbs: [\"get\", \"watch\"]\n---\napiVersion: rbac.authorization.k8s.io\u002Fv1\nkind: RoleBinding\nmetadata:\n  name: my-app\n  namespace: production\nsubjects:\n  - kind: ServiceAccount\n    name: my-app\n    namespace: production\nroleRef:\n  kind: Role\n  name: my-app\n  apiGroup: rbac.authorization.k8s.io\n```\n\nPrefer Roles over ClusterRoles, name resources where you can, and avoid `*`.\n`list` and `watch` on Secrets expose every Secret's contents, not only names.\nMore patterns: `references\u002Frbac-patterns.md`.\n\n## Beyond the built-ins\n\n- **Custom admission rules** (required labels, allowed registries):\n  ValidatingAdmissionPolicy (`admissionregistration.k8s.io\u002Fv1`, GA since 1.30)\n  runs CEL in the API server with no extra component. Kyverno or OPA Gatekeeper\n  add mutation, image verification and policy reports.\n- **Service mesh mTLS and L7 authorization**: see the `mtls-configuration`\n  skill in the `cloud-infrastructure` plugin.\n\n## Troubleshooting\n\n```bash\n# Which pods in a namespace would a level reject?\nkubectl label --dry-run=server --overwrite ns \u003Cns> pod-security.kubernetes.io\u002Fenforce=restricted\n\n# Pod rejected at admission: the event names the failing check\nkubectl get events -n \u003Cns> --field-selector reason=FailedCreate\n\n# Effective permissions of a ServiceAccount\nkubectl auth can-i --list --as system:serviceaccount:\u003Cns>:\u003Csa> -n \u003Cns>\n\n# NetworkPolicy has no effect: test from a pod the policy selects\nkubectl run nettest -n \u003Cns> --rm -it --image=busybox:1.37 --labels app=frontend -- \\\n  wget -qO- -T 3 http:\u002F\u002Fbackend:8080\n```\n\n## Related Skills\n\n- `k8s-manifest-generator` - For creating secure manifests\n- `gitops-workflow` - For automated policy deployment\n",{"name":5,"description":7,"last_verified":24},1793059200000,"main","f846d9a97082ff30d613b55a085cef425d822473","plugins\u002Fkubernetes-operations\u002Fskills\u002Fk8s-security-policies","https:\u002F\u002Fgithub.com\u002Fshotcowboystyle\u002Fag-skills","https:\u002F\u002Fgithub.com\u002Fshotcowboystyle","https:\u002F\u002Fshotcowboystyle.github.io","Building smarter with AI, automation & modern tools. Exploring how far one person can go without a big team using today’s AI.","2026-11-10 04:58:27",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add shotcowboystyle\u002Fag-skills --skill k8s-security-policies",{"tool":39,"command":40},"bunx","bunx skills add shotcowboystyle\u002Fag-skills --skill k8s-security-policies",{"tool":42,"command":43},"pnpm","pnpm dlx skills add shotcowboystyle\u002Fag-skills --skill k8s-security-policies","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fshotcowboystyle\u002Fag-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fkubernetes-operations\u002Fskills\u002Fk8s-security-policies\u002FSKILL.md",true,[47,53],{"path":48,"resourceType":49,"resourceTypeDesc":50,"sizeBytes":51,"sourceHtmlUrl":52},"assets\u002Fnetwork-policy-template.yaml","ASSET","资产文件",3452,"https:\u002F\u002Fgithub.com\u002Fshotcowboystyle\u002Fag-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fkubernetes-operations\u002Fskills\u002Fk8s-security-policies\u002Fassets\u002Fnetwork-policy-template.yaml",{"path":54,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":57,"sourceHtmlUrl":58},"references\u002Frbac-patterns.md","REFERENCE","参考文档",4623,"https:\u002F\u002Fgithub.com\u002Fshotcowboystyle\u002Fag-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fkubernetes-operations\u002Fskills\u002Fk8s-security-policies\u002Freferences\u002Frbac-patterns.md",[60,66,73,80,87,94],{"skillNo":61,"name":62,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M7F1YRY5S5QRJ1V0BJS130QX","no-description","https:\u002F\u002Fgithub.com\u002Fshotcowboystyle\u002Fag-skills\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fno-description\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M7F1Y9BV2FJNQJ3NB32JS5CM","good-skill","Fixture skill that satisfies every rule.","https:\u002F\u002Fgithub.com\u002Fshotcowboystyle\u002Fag-skills\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fgood-skill\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M7F1XXBQ3NQRXZSS0KAGAR9V","broken-link","Links to a reference file that does not exist.","https:\u002F\u002Fgithub.com\u002Fshotcowboystyle\u002Fag-skills\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fbroken-link\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M7F1XBX4R46NR9W0HXQ7XCDX","Bad_Name","Name violates the kebab-case rule and does not match the directory.","https:\u002F\u002Fgithub.com\u002Fshotcowboystyle\u002Fag-skills\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fbad-name\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M7F1WNAF8WNEQ7S5HKT5VK0D","skill-authoring","Write, review, and validate portable agent skills in SKILL.md format. Use when creating a new skill, editing an existing one, or asked whether a skill follows the Agent Skills spec.","https:\u002F\u002Fgithub.com\u002Fshotcowboystyle\u002Fag-skills\u002Fblob\u002Fmain\u002Fskills\u002Fskill-authoring\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":19},"01M7F1W30TC0XFNSF7YBRGETK2","weigh-bags","Record scale readings for each bag — empty (tare), outbound, current, final — and reconcile them against the itemised inventory to find unaccounted weight. Use when the user gives a bag weight, says how heavy something is, weighs their luggage, or asks how close to the limit they are. Appends to bags.yaml and runs scripts\u002Freconcile.py.","https:\u002F\u002Fgithub.com\u002Fshotcowboystyle\u002Fag-skills\u002Fblob\u002Fmain\u002Fplugins\u002Ftravel-packing-assistant\u002Fskills\u002Fweigh-bags\u002FSKILL.md",[],[]]