[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7E6GP6JMTYYDSDG5AA4YK92":3,"skill-same:01M7E6GP6JMTYYDSDG5AA4YK92":57},{"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":35,"commitSha":36,"skillDirectory":37,"forksCount":14,"repositoryHtmlUrl":38,"repositoryHomepageUrl":6,"ownerHtmlUrl":39,"ownerBlogUrl":40,"ownerDescription":41,"updatedAt":42,"install":43,"resources":56},"01M7E6GP6JMTYYDSDG5AA4YK92","kubernetes-hardening",null,"Harden Kubernetes clusters and workloads - Pod Security Admission, securityContext, service-account tokens, default-deny NetworkPolicy that keeps DNS, least-privilege RBAC, admission policy (ValidatingAdmissionPolicy\u002FKyverno), image digests and signature verification, secrets encryption, audit logging, CIS scanning and runtime detection. Use for a K8s security review or before exposing a cluster to production; use operating-kubernetes for day-to-day workload operations.","w0rxbend\u002Fdot-agents","w0rxbend","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F8176996?v=4","01M7E4XY3Y871Z2NFBXF3H3T8F","Oleksandr B.","01M7E4XY51E6NSG05FXR36H9RV",0,"MIT","https:\u002F\u002Fgithub.com\u002Fw0rxbend\u002Fdot-agents\u002Fblob\u002Fmain\u002Fskills\u002Fsecurity\u002Fkubernetes-hardening\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: kubernetes-hardening\ndescription: Harden Kubernetes clusters and workloads - Pod Security Admission, securityContext, service-account tokens, default-deny NetworkPolicy that keeps DNS, least-privilege RBAC, admission policy (ValidatingAdmissionPolicy\u002FKyverno), image digests and signature verification, secrets encryption, audit logging, CIS scanning and runtime detection. Use for a K8s security review or before exposing a cluster to production; use operating-kubernetes for day-to-day workload operations.\ncategory: security\nrisk: critical\nsource: https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\nsource_repo: BagelHole\u002FDevOps-Security-Agent-Skills\nsource_type: community\ndate_added: '2026-09-20'\nlicense: MIT\nlicense_source: https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\u002Fblob\u002Fmain\u002FLICENSE\ncompatibility: Requires kubectl access with permission to read cluster configuration; changing admission, audit or encryption settings requires control-plane access (self-managed) or the cloud provider's equivalent settings (EKS\u002FGKE\u002FAKS).\nmetadata:\n  author: devops-skills\n  version: '1.1'\n---\n\n# Kubernetes Hardening\n\nWork in layers; verify each. Apply changes in non-production cluster first. `enforce` modes and default-deny policies break workloads relying on the gap.\n\n## 0. Inventory first (read-only)\n\n```bash\nkubectl version\nkubectl get ns --show-labels                         # current Pod Security labels\nkubectl get networkpolicy -A\nkubectl get clusterrolebindings -o wide | grep -E 'cluster-admin|system:anonymous|system:unauthenticated'\nkubectl auth can-i --list --as=system:serviceaccount:\u003Cns>:default -n \u003Cns>\nkubectl get pods -A -o jsonpath='{range .items[*]}{.metadata.namespace}\u002F{.metadata.name}{\"\\t\"}{.spec.containers[*].image}{\"\\n\"}{end}' | grep -v '@sha256'\n```\n\nThen run section 9 scanners for baseline.\n\n## 1. Pod Security Admission\n\nLabel every workload namespace. Roll out `warn`\u002F`audit` first, then `enforce`.\n\n```yaml\napiVersion: v1\nkind: Namespace\nmetadata:\n  name: production\n  labels:\n    env: production   # selected by the admission policy binding in section 6\n    pod-security.kubernetes.io\u002Fenforce: restricted\n    pod-security.kubernetes.io\u002Fenforce-version: latest\n    pod-security.kubernetes.io\u002Faudit: restricted\n    pod-security.kubernetes.io\u002Fwarn: restricted\n```\n\n```bash\n# Preview which existing pods would violate \"restricted\"\nkubectl label --dry-run=server --overwrite ns production pod-security.kubernetes.io\u002Fenforce=restricted\n```\n\nUse `baseline` only for namespaces that need it (for example some CNI or monitoring agents). Keep `privileged` for system namespaces.\n\n## 2. Workload securityContext\n\n```yaml\napiVersion: apps\u002Fv1\nkind: Deployment\nmetadata:\n  name: api\nspec:\n  template:\n    spec:\n      automountServiceAccountToken: false      # only mount when the pod calls the API server\n      serviceAccountName: api\n      securityContext:\n        runAsNonRoot: true\n        runAsUser: 10001\n        runAsGroup: 10001\n        fsGroup: 10001\n        seccompProfile:\n          type: RuntimeDefault\n      containers:\n        - name: api\n          image: registry.example.com\u002Fapi@sha256:\u003Cdigest>   # digest, not a mutable tag\n          securityContext:\n            allowPrivilegeEscalation: false\n            readOnlyRootFilesystem: true\n            capabilities:\n              drop: [\"ALL\"]\n          resources:\n            requests: { cpu: 100m, memory: 128Mi }\n            limits: { memory: 256Mi }\n          volumeMounts:\n            - { name: tmp, mountPath: \u002Ftmp }\n      volumes:\n        - name: tmp\n          emptyDir: {}\n```\n\nAvoid `hostNetwork`, `hostPID`, `hostIPC`, `hostPath` volumes and `privileged: true`. PSA `restricted` rejects most of these.\n\n## 3. Service accounts\n\n- One service account per workload; never grant permissions to `default`.\n- Set `automountServiceAccountToken: false` on ServiceAccount or pod unless pod calls the API. When it does, projected token is short-lived and audience-bound. Do not create legacy long-lived token Secrets.\n- For cloud APIs, use workload identity (EKS Pod Identity\u002FIRSA, GKE Workload Identity, AKS Workload ID), not static keys in Secrets.\n\n## 4. NetworkPolicy: default deny that keeps DNS\n\nNetworkPolicies take effect only if CNI enforces them (Calico, Cilium, cloud-native policy engines). Check before relying on them.\n\n```yaml\napiVersion: networking.k8s.io\u002Fv1\nkind: NetworkPolicy\nmetadata:\n  name: default-deny\n  namespace: production\nspec:\n  podSelector: {}\n  policyTypes: [Ingress, Egress]\n---\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          # check your DNS pods' labels\n      ports:\n        - { protocol: UDP, port: 53 }\n        - { protocol: TCP, port: 53 }\n---\napiVersion: networking.k8s.io\u002Fv1\nkind: NetworkPolicy\nmetadata:\n  name: web-from-frontend\n  namespace: production\nspec:\n  podSelector:\n    matchLabels: { app: web }\n  policyTypes: [Ingress]\n  ingress:\n    - from:\n        - podSelector:\n            matchLabels: { app: frontend }\n      ports:\n        - { protocol: TCP, port: 8080 }\n```\n\nWithout DNS rule, default-deny egress policy breaks every name lookup. Add explicit egress rules for databases, external APIs and API server where needed.\n\n## 5. RBAC least privilege\n\n```yaml\napiVersion: rbac.authorization.k8s.io\u002Fv1\nkind: Role\nmetadata: { name: app-reader, namespace: production }\nrules:\n  - apiGroups: [\"\"]\n    resources: [\"configmaps\"]\n    resourceNames: [\"app-config\"]\n    verbs: [\"get\", \"watch\"]\n---\napiVersion: rbac.authorization.k8s.io\u002Fv1\nkind: RoleBinding\nmetadata: { name: app-reader, namespace: production }\nsubjects:\n  - kind: ServiceAccount\n    name: api\n    namespace: production\nroleRef:\n  kind: Role\n  name: app-reader\n  apiGroup: rbac.authorization.k8s.io\n```\n\nTreat these as privilege-escalation paths. Grant only to cluster administrators:\n\n| Grant | Why dangerous |\n|---|---|\n| `*` verbs or resources | Includes everything, now and in future API versions |\n| `escalate`, `bind` on roles | Subject can grant itself more permissions |\n| `impersonate` | Act as any user, group or service account |\n| `create` on `pods` \u002F workloads | Can mount any service account token or hostPath in that namespace |\n| `get`\u002F`list` on `secrets` | Reads every credential in scope |\n| `create` on `serviceaccounts\u002Ftoken` | Mints tokens for other identities |\n| `nodes\u002Fproxy`, `pods\u002Fexec`, `pods\u002Fattach` | Code execution on nodes or in pods |\n\nAudit with `kubectl auth can-i --list --as=\u003Csubject>` plus a tool such as `rbac-tool` or `kubectl-who-can` if installed.\n\n## 6. Admission policy\n\nPSA covers pod-level controls only. Add policy for registries, digests, labels and resource limits.\n\nBuilt-in ValidatingAdmissionPolicy (CEL; GA in recent Kubernetes versions, check yours):\n\n```yaml\napiVersion: admissionregistration.k8s.io\u002Fv1\nkind: ValidatingAdmissionPolicy\nmetadata: { name: require-image-digest }\nspec:\n  failurePolicy: Fail\n  matchConstraints:\n    resourceRules:\n      - apiGroups: [\"apps\"]\n        apiVersions: [\"v1\"]\n        operations: [\"CREATE\", \"UPDATE\"]\n        resources: [\"deployments\"]\n  validations:\n    - expression: >-\n        object.spec.template.spec.containers.all(c, c.image.contains('@sha256:')) &&\n        (!has(object.spec.template.spec.initContainers) ||\n         object.spec.template.spec.initContainers.all(c, c.image.contains('@sha256:')))\n      message: \"images (including init containers) must be pinned by digest\"\n---\napiVersion: admissionregistration.k8s.io\u002Fv1\nkind: ValidatingAdmissionPolicyBinding\nmetadata: { name: require-image-digest }\nspec:\n  policyName: require-image-digest\n  validationActions: [\"Deny\"]\n  matchResources:\n    namespaceSelector:\n      matchLabels: { env: production }   # the Namespace in section 1 carries this label\n```\n\nExample matches Deployments only. Add StatefulSets, DaemonSets, Jobs and CronJobs (CronJob pods live under `spec.jobTemplate.spec.template`), or match `pods` directly to cover every workload kind.\n\nKyverno or OPA Gatekeeper add mutation, generation and image-signature checks. Start in audit mode (`validationActions: [\"Audit\"]`, Kyverno `Audit`). Switch to deny after reviewing reports.\n\n## 7. Supply chain: digests and signatures\n\n- Deploy by digest. Resolve digest in CI from the image you built and tested.\n- Sign images in CI (for example `cosign sign --yes \u003Cimage>@\u003Cdigest>` with keyless OIDC). Verify at admission (Kyverno `verifyImages`, Sigstore policy-controller, or Connaisseur).\n- Verify manually: `cosign verify \u003Cimage>@\u003Cdigest> --certificate-identity-regexp '\u003Crepo workflow>' --certificate-oidc-issuer https:\u002F\u002Ftoken.actions.githubusercontent.com`.\n- Scan images in CI and continuously in-cluster (see `dockerfile-optimise` rule `sec-scan-images`).\n\n## 8. Secrets\n\n- Enable encryption at rest for Secrets: `EncryptionConfiguration` with KMS provider (self-managed), or provider's envelope-encryption option (EKS\u002FGKE\u002FAKS). Re-encrypt existing Secrets after enabling.\n- Prefer external store synced in at runtime (External Secrets Operator, Secrets Store CSI Driver, Vault Agent; see `hashicorp-vault`) over Secrets committed to Git. If they must be in Git, encrypt them (Sealed Secrets, SOPS).\n- Restrict `get\u002Flist\u002Fwatch` on `secrets` to workloads that need specific names (`resourceNames`).\n\n## 9. Audit logging, scanning and runtime detection\n\n- **Audit policy** (self-managed API server: `--audit-policy-file`, `--audit-log-path`; managed clusters: enable control-plane audit logs in provider). Minimal policy:\n\n```yaml\napiVersion: audit.k8s.io\u002Fv1\nkind: Policy\nomitStages: [\"RequestReceived\"]\nrules:\n  - level: Metadata                       # never log Secret bodies\n    resources: [{ group: \"\", resources: [\"secrets\", \"configmaps\"] }]\n  - level: RequestResponse\n    resources: [{ group: \"rbac.authorization.k8s.io\" }]\n  - level: Metadata\n    verbs: [\"create\", \"update\", \"patch\", \"delete\"]\n  - level: None\n```\n\n- **CIS benchmark**: `kube-bench` (run as Job on nodes; use managed-service profile on EKS\u002FGKE\u002FAKS).\n- **Posture scan**: `KS_SKIP_UPDATE_CHECK=true kubescape scan` (NSA\u002FCISA and MITRE frameworks) or `TRIVY_DISABLE_TELEMETRY=true TRIVY_SKIP_VERSION_CHECK=true trivy k8s --report summary`. Both send usage\u002Fcluster data (version, node count, install or cluster ID) home by default; keep these opt-outs wherever they run, CI too.\n- **Runtime detection**: Falco (or Tetragon) for shells in containers, unexpected outbound connections, writes below `\u002Fetc`, and token reads. Route alerts to on-call.\n- **Control plane and nodes**: keep cluster on supported minor version. Restrict API server access (private endpoint or authorized networks). Disable anonymous auth. Restrict kubelet (`--anonymous-auth=false`, webhook authorization). Keep etcd unreachable from workloads with client TLS.\n\n## Done when\n\n- Every workload namespace enforces PSA `restricted` (or has a documented `baseline` exception).\n- Each namespace has default-deny ingress and egress plus explicit allows. DNS still resolves (`kubectl exec \u003Cpod> -- getent hosts kubernetes.default`).\n- No non-admin subject holds escalation grants above. Workloads use dedicated service accounts with tokens mounted only where needed.\n- Production admission rejects unpinned or unsigned images (test with deliberately bad Deployment).\n- Secrets encrypted at rest. Audit logs flowing. kube-bench\u002Fkubescape findings triaged with owners.\n\n## Related skills\n\n- `operating-kubernetes` - resources, scheduling, autoscaling and troubleshooting.\n- `security-hardening` - host, container runtime and cloud account hardening.\n- `implementing-gitops` - delivering these policies declaratively.\n- `hashicorp-vault` - external secrets source.\n\n> Adapted from [BagelHole\u002FDevOps-Security-Agent-Skills](https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills) (MIT) and substantially expanded.\n","# Kubernetes Hardening\n\nWork in layers; verify each. Apply changes in non-production cluster first. `enforce` modes and default-deny policies break workloads relying on the gap.\n\n## 0. Inventory first (read-only)\n\n```bash\nkubectl version\nkubectl get ns --show-labels                         # current Pod Security labels\nkubectl get networkpolicy -A\nkubectl get clusterrolebindings -o wide | grep -E 'cluster-admin|system:anonymous|system:unauthenticated'\nkubectl auth can-i --list --as=system:serviceaccount:\u003Cns>:default -n \u003Cns>\nkubectl get pods -A -o jsonpath='{range .items[*]}{.metadata.namespace}\u002F{.metadata.name}{\"\\t\"}{.spec.containers[*].image}{\"\\n\"}{end}' | grep -v '@sha256'\n```\n\nThen run section 9 scanners for baseline.\n\n## 1. Pod Security Admission\n\nLabel every workload namespace. Roll out `warn`\u002F`audit` first, then `enforce`.\n\n```yaml\napiVersion: v1\nkind: Namespace\nmetadata:\n  name: production\n  labels:\n    env: production   # selected by the admission policy binding in section 6\n    pod-security.kubernetes.io\u002Fenforce: restricted\n    pod-security.kubernetes.io\u002Fenforce-version: latest\n    pod-security.kubernetes.io\u002Faudit: restricted\n    pod-security.kubernetes.io\u002Fwarn: restricted\n```\n\n```bash\n# Preview which existing pods would violate \"restricted\"\nkubectl label --dry-run=server --overwrite ns production pod-security.kubernetes.io\u002Fenforce=restricted\n```\n\nUse `baseline` only for namespaces that need it (for example some CNI or monitoring agents). Keep `privileged` for system namespaces.\n\n## 2. Workload securityContext\n\n```yaml\napiVersion: apps\u002Fv1\nkind: Deployment\nmetadata:\n  name: api\nspec:\n  template:\n    spec:\n      automountServiceAccountToken: false      # only mount when the pod calls the API server\n      serviceAccountName: api\n      securityContext:\n        runAsNonRoot: true\n        runAsUser: 10001\n        runAsGroup: 10001\n        fsGroup: 10001\n        seccompProfile:\n          type: RuntimeDefault\n      containers:\n        - name: api\n          image: registry.example.com\u002Fapi@sha256:\u003Cdigest>   # digest, not a mutable tag\n          securityContext:\n            allowPrivilegeEscalation: false\n            readOnlyRootFilesystem: true\n            capabilities:\n              drop: [\"ALL\"]\n          resources:\n            requests: { cpu: 100m, memory: 128Mi }\n            limits: { memory: 256Mi }\n          volumeMounts:\n            - { name: tmp, mountPath: \u002Ftmp }\n      volumes:\n        - name: tmp\n          emptyDir: {}\n```\n\nAvoid `hostNetwork`, `hostPID`, `hostIPC`, `hostPath` volumes and `privileged: true`. PSA `restricted` rejects most of these.\n\n## 3. Service accounts\n\n- One service account per workload; never grant permissions to `default`.\n- Set `automountServiceAccountToken: false` on ServiceAccount or pod unless pod calls the API. When it does, projected token is short-lived and audience-bound. Do not create legacy long-lived token Secrets.\n- For cloud APIs, use workload identity (EKS Pod Identity\u002FIRSA, GKE Workload Identity, AKS Workload ID), not static keys in Secrets.\n\n## 4. NetworkPolicy: default deny that keeps DNS\n\nNetworkPolicies take effect only if CNI enforces them (Calico, Cilium, cloud-native policy engines). Check before relying on them.\n\n```yaml\napiVersion: networking.k8s.io\u002Fv1\nkind: NetworkPolicy\nmetadata:\n  name: default-deny\n  namespace: production\nspec:\n  podSelector: {}\n  policyTypes: [Ingress, Egress]\n---\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          # check your DNS pods' labels\n      ports:\n        - { protocol: UDP, port: 53 }\n        - { protocol: TCP, port: 53 }\n---\napiVersion: networking.k8s.io\u002Fv1\nkind: NetworkPolicy\nmetadata:\n  name: web-from-frontend\n  namespace: production\nspec:\n  podSelector:\n    matchLabels: { app: web }\n  policyTypes: [Ingress]\n  ingress:\n    - from:\n        - podSelector:\n            matchLabels: { app: frontend }\n      ports:\n        - { protocol: TCP, port: 8080 }\n```\n\nWithout DNS rule, default-deny egress policy breaks every name lookup. Add explicit egress rules for databases, external APIs and API server where needed.\n\n## 5. RBAC least privilege\n\n```yaml\napiVersion: rbac.authorization.k8s.io\u002Fv1\nkind: Role\nmetadata: { name: app-reader, namespace: production }\nrules:\n  - apiGroups: [\"\"]\n    resources: [\"configmaps\"]\n    resourceNames: [\"app-config\"]\n    verbs: [\"get\", \"watch\"]\n---\napiVersion: rbac.authorization.k8s.io\u002Fv1\nkind: RoleBinding\nmetadata: { name: app-reader, namespace: production }\nsubjects:\n  - kind: ServiceAccount\n    name: api\n    namespace: production\nroleRef:\n  kind: Role\n  name: app-reader\n  apiGroup: rbac.authorization.k8s.io\n```\n\nTreat these as privilege-escalation paths. Grant only to cluster administrators:\n\n| Grant | Why dangerous |\n|---|---|\n| `*` verbs or resources | Includes everything, now and in future API versions |\n| `escalate`, `bind` on roles | Subject can grant itself more permissions |\n| `impersonate` | Act as any user, group or service account |\n| `create` on `pods` \u002F workloads | Can mount any service account token or hostPath in that namespace |\n| `get`\u002F`list` on `secrets` | Reads every credential in scope |\n| `create` on `serviceaccounts\u002Ftoken` | Mints tokens for other identities |\n| `nodes\u002Fproxy`, `pods\u002Fexec`, `pods\u002Fattach` | Code execution on nodes or in pods |\n\nAudit with `kubectl auth can-i --list --as=\u003Csubject>` plus a tool such as `rbac-tool` or `kubectl-who-can` if installed.\n\n## 6. Admission policy\n\nPSA covers pod-level controls only. Add policy for registries, digests, labels and resource limits.\n\nBuilt-in ValidatingAdmissionPolicy (CEL; GA in recent Kubernetes versions, check yours):\n\n```yaml\napiVersion: admissionregistration.k8s.io\u002Fv1\nkind: ValidatingAdmissionPolicy\nmetadata: { name: require-image-digest }\nspec:\n  failurePolicy: Fail\n  matchConstraints:\n    resourceRules:\n      - apiGroups: [\"apps\"]\n        apiVersions: [\"v1\"]\n        operations: [\"CREATE\", \"UPDATE\"]\n        resources: [\"deployments\"]\n  validations:\n    - expression: >-\n        object.spec.template.spec.containers.all(c, c.image.contains('@sha256:')) &&\n        (!has(object.spec.template.spec.initContainers) ||\n         object.spec.template.spec.initContainers.all(c, c.image.contains('@sha256:')))\n      message: \"images (including init containers) must be pinned by digest\"\n---\napiVersion: admissionregistration.k8s.io\u002Fv1\nkind: ValidatingAdmissionPolicyBinding\nmetadata: { name: require-image-digest }\nspec:\n  policyName: require-image-digest\n  validationActions: [\"Deny\"]\n  matchResources:\n    namespaceSelector:\n      matchLabels: { env: production }   # the Namespace in section 1 carries this label\n```\n\nExample matches Deployments only. Add StatefulSets, DaemonSets, Jobs and CronJobs (CronJob pods live under `spec.jobTemplate.spec.template`), or match `pods` directly to cover every workload kind.\n\nKyverno or OPA Gatekeeper add mutation, generation and image-signature checks. Start in audit mode (`validationActions: [\"Audit\"]`, Kyverno `Audit`). Switch to deny after reviewing reports.\n\n## 7. Supply chain: digests and signatures\n\n- Deploy by digest. Resolve digest in CI from the image you built and tested.\n- Sign images in CI (for example `cosign sign --yes \u003Cimage>@\u003Cdigest>` with keyless OIDC). Verify at admission (Kyverno `verifyImages`, Sigstore policy-controller, or Connaisseur).\n- Verify manually: `cosign verify \u003Cimage>@\u003Cdigest> --certificate-identity-regexp '\u003Crepo workflow>' --certificate-oidc-issuer https:\u002F\u002Ftoken.actions.githubusercontent.com`.\n- Scan images in CI and continuously in-cluster (see `dockerfile-optimise` rule `sec-scan-images`).\n\n## 8. Secrets\n\n- Enable encryption at rest for Secrets: `EncryptionConfiguration` with KMS provider (self-managed), or provider's envelope-encryption option (EKS\u002FGKE\u002FAKS). Re-encrypt existing Secrets after enabling.\n- Prefer external store synced in at runtime (External Secrets Operator, Secrets Store CSI Driver, Vault Agent; see `hashicorp-vault`) over Secrets committed to Git. If they must be in Git, encrypt them (Sealed Secrets, SOPS).\n- Restrict `get\u002Flist\u002Fwatch` on `secrets` to workloads that need specific names (`resourceNames`).\n\n## 9. Audit logging, scanning and runtime detection\n\n- **Audit policy** (self-managed API server: `--audit-policy-file`, `--audit-log-path`; managed clusters: enable control-plane audit logs in provider). Minimal policy:\n\n```yaml\napiVersion: audit.k8s.io\u002Fv1\nkind: Policy\nomitStages: [\"RequestReceived\"]\nrules:\n  - level: Metadata                       # never log Secret bodies\n    resources: [{ group: \"\", resources: [\"secrets\", \"configmaps\"] }]\n  - level: RequestResponse\n    resources: [{ group: \"rbac.authorization.k8s.io\" }]\n  - level: Metadata\n    verbs: [\"create\", \"update\", \"patch\", \"delete\"]\n  - level: None\n```\n\n- **CIS benchmark**: `kube-bench` (run as Job on nodes; use managed-service profile on EKS\u002FGKE\u002FAKS).\n- **Posture scan**: `KS_SKIP_UPDATE_CHECK=true kubescape scan` (NSA\u002FCISA and MITRE frameworks) or `TRIVY_DISABLE_TELEMETRY=true TRIVY_SKIP_VERSION_CHECK=true trivy k8s --report summary`. Both send usage\u002Fcluster data (version, node count, install or cluster ID) home by default; keep these opt-outs wherever they run, CI too.\n- **Runtime detection**: Falco (or Tetragon) for shells in containers, unexpected outbound connections, writes below `\u002Fetc`, and token reads. Route alerts to on-call.\n- **Control plane and nodes**: keep cluster on supported minor version. Restrict API server access (private endpoint or authorized networks). Disable anonymous auth. Restrict kubelet (`--anonymous-auth=false`, webhook authorization). Keep etcd unreachable from workloads with client TLS.\n\n## Done when\n\n- Every workload namespace enforces PSA `restricted` (or has a documented `baseline` exception).\n- Each namespace has default-deny ingress and egress plus explicit allows. DNS still resolves (`kubectl exec \u003Cpod> -- getent hosts kubernetes.default`).\n- No non-admin subject holds escalation grants above. Workloads use dedicated service accounts with tokens mounted only where needed.\n- Production admission rejects unpinned or unsigned images (test with deliberately bad Deployment).\n- Secrets encrypted at rest. Audit logs flowing. kube-bench\u002Fkubescape findings triaged with owners.\n\n## Related skills\n\n- `operating-kubernetes` - resources, scheduling, autoscaling and troubleshooting.\n- `security-hardening` - host, container runtime and cloud account hardening.\n- `implementing-gitops` - delivering these policies declaratively.\n- `hashicorp-vault` - external secrets source.\n\n> Adapted from [BagelHole\u002FDevOps-Security-Agent-Skills](https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills) (MIT) and substantially expanded.\n",{"name":5,"risk":24,"source":25,"license":15,"category":26,"metadata":27,"date_added":30,"description":7,"source_repo":31,"source_type":32,"compatibility":33,"license_source":34},"critical","https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills","security",{"author":28,"version":29},"devops-skills","1.1","2026-09-20","BagelHole\u002FDevOps-Security-Agent-Skills","community","Requires kubectl access with permission to read cluster configuration; changing admission, audit or encryption settings requires control-plane access (self-managed) or the cloud provider's equivalent settings (EKS\u002FGKE\u002FAKS).","https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\u002Fblob\u002Fmain\u002FLICENSE","main","101d0f67250256ca5d80dc3f95767cad7b541457","skills\u002Fsecurity\u002Fkubernetes-hardening","https:\u002F\u002Fgithub.com\u002Fw0rxbend\u002Fdot-agents","https:\u002F\u002Fgithub.com\u002Fw0rxbend","https:\u002F\u002Freadme.worxbend.com\u002F","Fluent in Backend-ese (microservices, distributed systems, you know the drill)\r\nFunctional Programming Fanatic...","2026-11-14 14:44:12",{"source":8,"skillName":5,"commands":44,"prompt":54,"zipAvailable":55},[45,48,51],{"tool":46,"command":47},"npx","npx skills add w0rxbend\u002Fdot-agents --skill kubernetes-hardening",{"tool":49,"command":50},"bunx","bunx skills add w0rxbend\u002Fdot-agents --skill kubernetes-hardening",{"tool":52,"command":53},"pnpm","pnpm dlx skills add w0rxbend\u002Fdot-agents --skill kubernetes-hardening","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fw0rxbend\u002Fdot-agents\u002Fblob\u002Fmain\u002Fskills\u002Fsecurity\u002Fkubernetes-hardening\u002FSKILL.md",true,[],[58,65,72,80,87,94],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M7E6TS1SW1ZSXN748N0RBGHT","wiki-builder","Create and maintain a local Markdown research wiki (sources with provenance, compiled concept\u002Fsource pages, index, maintenance log) driven by a per-wiki config. Use when the user wants to start a wiki or knowledge base, ingest sources into one, or query and update it; use wiki-page-writer for a single code deep-dive page.","https:\u002F\u002Fgithub.com\u002Fw0rxbend\u002Fdot-agents\u002Fblob\u002Fmain\u002Fskills\u002Fworkflow\u002Fwiki-builder\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M7E6S8ARS0VQR85H4FEC390B","refactoring-guru","Diagnose a named code smell and apply the smallest behavior-preserving refactoring, with verification before and after and an explicit stop condition. Use for structural refactors (extract, move, consolidate, change ownership), not for feature or bug work; for readability cleanup of recent changes use code-simplification.","https:\u002F\u002Fgithub.com\u002Fw0rxbend\u002Fdot-agents\u002Fblob\u002Fmain\u002Fskills\u002Fworkflow\u002Frefactoring-guru\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":76,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M7E6RRXCYGSHA0ZBFX3YZP7Y","legacy-seams","When changing untested legacy code, pin the observed results with characterization tests and open the smallest seam that substitutes only the blocking dependency, separate from any later logic change. Use when a clock, random source, I\u002FO, global, or hidden constructor blocks a test or a safe edit. Use test-driven-development for a new behavior or a bug, refactoring-guru for one named structural refactor after the seam exists, and code-refactoring-tech-debt to choose which legacy to replace.","https:\u002F\u002Fgithub.com\u002Fw0rxbend\u002Fdot-agents\u002Fblob\u002Fmain\u002Fskills\u002Fworkflow\u002Flegacy-seams\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fw0rxbend\u002Fdot-agents\u002Fblob\u002Fmain\u002Fskills\u002Fworkflow\u002Flegacy-seams\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},"01M7E6QZ11XWSNHCBGYK8HH97C","idea-refine","Refine a raw idea into a one-page brief (problem statement, recommended direction, assumptions to validate, MVP scope, not-doing list) through divergent then convergent thinking. Use when an idea is still vague or you want options and a stress test before committing; use interview-me when the goal itself is unclear and spec-driven-development once the direction is chosen.","https:\u002F\u002Fgithub.com\u002Fw0rxbend\u002Fdot-agents\u002Fblob\u002Fmain\u002Fskills\u002Fworkflow\u002Fidea-refine\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},"01M7E6N2N7BYW7BA5XGM0QD3B4","code-review-and-quality","Review rubric and approval standard for any change before merge, including code written by you, another agent, or a human: five axes (correctness, readability, architecture, security, performance), change sizing, structural remedies, severity labels, and feedback technique. Use to judge whether a change is fit to merge; use code-review to run a PR or diff review end to end.","https:\u002F\u002Fgithub.com\u002Fw0rxbend\u002Fdot-agents\u002Fblob\u002Fmain\u002Fskills\u002Fworkflow\u002Fcode-review-and-quality\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":98,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":19},"01M7E6MNCZPTRD77Z419X755HQ","code-perfection","Smell and style gate for code you write or change. Bans known code smells (long method, large class, primitive obsession, long parameter list, data clumps, duplicate code, dead code, feature envy, shotgun surgery, flag arguments, message chains) and enforces behavior-preserving structure. On Scala files, enforces worxbend style. Use while implementing, reviewing a diff for smells, or when a smell or style violation is suspected. Routine construction stays with code-complete. SOLID and DRY stay with clean-code-guard. One named structural refactor stays with refactoring-guru.","https:\u002F\u002Fgithub.com\u002Fw0rxbend\u002Fdot-agents\u002Fblob\u002Fmain\u002Fskills\u002Fworkflow\u002Fcode-perfection\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fw0rxbend\u002Fdot-agents\u002Fblob\u002Fmain\u002Fskills\u002Fworkflow\u002Fcode-perfection\u002FSKILL.md",[],[]]