[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73BXTRZQJEP3SB07AWC9YHN":3,"skill-same:01M73BXTRZQJEP3SB07AWC9YHN":48},{"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":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M73BXTRZQJEP3SB07AWC9YHN","kubernetes-security",null,"Harden a Kubernetes cluster's data plane and control plane. Covers Pod Security Standards (Restricted, Baseline, Privileged), RBAC with least privilege, NetworkPolicy default-deny, secrets management without raw env vars, admission controllers (Kyverno, OPA Gatekeeper), image scanning, and audit logging. Invoke when provisioning a new cluster, inheriting one, or before adding a new tenant to a shared cluster.","Horonomos-laps\u002FYana-AI","Horonomos-laps","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F355299122?v=4","01M76B3QPXE88ET2SQPDPVATZT"," Horonomos-laps","01M72ZQRJPCYPSSWT4D00VJR2A",13,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fgw360--kubernetes-security\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: kubernetes-security\ndescription: Harden a Kubernetes cluster's data plane and control plane. Covers Pod Security Standards (Restricted, Baseline, Privileged), RBAC with least privilege, NetworkPolicy default-deny, secrets management without raw env vars, admission controllers (Kyverno, OPA Gatekeeper), image scanning, and audit logging. Invoke when provisioning a new cluster, inheriting one, or before adding a new tenant to a shared cluster.\n---\n\n# Kubernetes Security\n\nA pragmatic baseline for a single Kubernetes cluster running a small-team workload. Skews toward \"I have a cluster and need it to not be the cause of an incident\" — not a full CIS Benchmark for regulated environments. Most managed-K8s providers ship sensible defaults at the control-plane layer; the data-plane (your workloads) is where the work is.\n\n## When to invoke\n\n- Provisioning a new cluster\n- Inheriting a cluster with no documented hardening\n- Before adding a new tenant \u002F team \u002F workload to a shared cluster\n- After a K8s security advisory affecting your version\n- Periodic re-audit (quarterly)\n- Multi-tenant SaaS where customer workloads share infrastructure\n\n## Step 1 — Cluster baseline\n\nBefore workload hardening, the cluster itself.\n\n```bash\n# What version? Is it supported?\nkubectl version --short\n# K8s has a ~14-month support window. Unsupported = unpatched CVEs.\n\n# Who can reach the API?\nkubectl cluster-info\n# For managed clusters, check the provider's \"API endpoint\" access setting:\n# - Private endpoint, restricted CIDRs, or behind a bastion is correct\n# - \"Public, open to 0.0.0.0\u002F0\" is a finding\n\n# Audit log enabled?\n# For EKS\u002FGKE\u002FAKS: check the cluster's \"audit logging\" \u002F \"control-plane logging\" setting\n# Self-hosted: --audit-log-path on the API server\n```\n\nPatterns:\n\n- **Restrict the API endpoint.** Public + open is the worst default. Use private endpoint + bastion, or public + CIDR allowlist + IAM auth at minimum.\n- **Enable control-plane audit logging.** Without it, an incident has no record. Ship to a log destination outside the cluster (so a compromise cannot wipe its own audit trail).\n- **Pin to a supported version**, automate patching to within the support window.\n- **Encrypt etcd at rest.** Default-on for EKS, GKE, AKS. Self-hosted: configure `--encryption-provider-config`.\n\n## Step 2 — Pod Security Standards\n\nSince K8s 1.25, **Pod Security Admission** is built-in. There are three policy levels:\n\n| Level | What it allows | When to use |\n|---|---|---|\n| **Privileged** | Everything | System namespaces only (kube-system, ingress controllers that need it) |\n| **Baseline** | No privileged escalation, no host networking, no hostPath | Default for most workloads |\n| **Restricted** | The above plus: non-root user, read-only root filesystem, drop all capabilities, seccomp profile | Production application workloads |\n\nApply per namespace:\n\n```yaml\napiVersion: v1\nkind: Namespace\nmetadata:\n  name: production\n  labels:\n    pod-security.kubernetes.io\u002Fenforce: restricted\n    pod-security.kubernetes.io\u002Fenforce-version: latest\n    pod-security.kubernetes.io\u002Fwarn: restricted\n    pod-security.kubernetes.io\u002Faudit: restricted\n```\n\n`enforce` rejects non-compliant pods. `warn` returns a warning to the user. `audit` logs to the audit log.\n\nFor workloads that cannot meet `restricted` (legacy containers needing root), use `baseline` and document why. Anything in `privileged` mode is a finding unless it's a known infrastructure component.\n\nCommon adjustments to make existing workloads `restricted`-compliant:\n\n```yaml\n# In the pod spec\nsecurityContext:\n  runAsNonRoot: true\n  runAsUser: 1000\n  runAsGroup: 1000\n  fsGroup: 1000\n  seccompProfile:\n    type: RuntimeDefault\n\n# Per container\ncontainers:\n- name: app\n  securityContext:\n    allowPrivilegeEscalation: false\n    readOnlyRootFilesystem: true\n    capabilities:\n      drop: [ALL]\n    runAsNonRoot: true\n```\n\nAnything writable (cache, temp) goes to an `emptyDir` volume; the root filesystem stays read-only.\n\n## Step 3 — RBAC and ServiceAccounts\n\nThe single most common K8s misconfiguration: every workload running as the `default` ServiceAccount of its namespace, which often has more rights than the workload needs.\n\n```bash\n# What can the default ServiceAccount in 'production' do?\nkubectl auth can-i --list --as=system:serviceaccount:production:default -n production\n\n# What ServiceAccounts have cluster-admin or near-admin rights?\nkubectl get clusterrolebindings -o json \\\n  | jq -r '.items[] | select(.roleRef.name == \"cluster-admin\") | \"\\(.metadata.name) -> \\(.subjects | map(.name) | join(\",\"))\"'\n```\n\nPatterns:\n\n- **One ServiceAccount per workload.** Don't use `default`.\n- **`automountServiceAccountToken: false`** on workloads that don't talk to the K8s API. Most don't.\n- **Bind to a Role (namespace-scoped) before a ClusterRole** — `ClusterRoleBinding` should be rare and justified.\n- **Avoid `*` verbs and `*` resources** in Role rules.\n- **Audit `system:authenticated` and `system:anonymous`** — these should have minimal permissions, never cluster-admin.\n\nExample tight Role:\n\n```yaml\napiVersion: rbac.authorization.k8s.io\u002Fv1\nkind: Role\nmetadata:\n  name: app-reader\n  namespace: production\nrules:\n- apiGroups: [\"\"]\n  resources: [\"configmaps\"]\n  resourceNames: [\"app-config\"]\n  verbs: [\"get\"]\n```\n\nThe resource name pin matters — `verbs: [get]` on all configmaps is too broad if the workload only reads one.\n\n## Step 4 — NetworkPolicy (default-deny)\n\nBy default, every pod can talk to every other pod, in any namespace. That's a flat network — one compromised workload pivots freely.\n\n```yaml\n# Default-deny ingress AND egress in a namespace\napiVersion: networking.k8s.io\u002Fv1\nkind: NetworkPolicy\nmetadata:\n  name: default-deny-all\n  namespace: production\nspec:\n  podSelector: {}\n  policyTypes:\n  - Ingress\n  - Egress\n```\n\nThen explicitly allow what's needed:\n\n```yaml\napiVersion: networking.k8s.io\u002Fv1\nkind: NetworkPolicy\nmetadata:\n  name: app-allow\n  namespace: production\nspec:\n  podSelector:\n    matchLabels:\n      app: web\n  policyTypes: [Ingress, Egress]\n  ingress:\n  - from:\n    - namespaceSelector:\n        matchLabels:\n          name: ingress-nginx\n    ports:\n    - protocol: TCP\n      port: 8080\n  egress:\n  - to:\n    - podSelector:\n        matchLabels:\n          app: postgres\n    ports:\n    - protocol: TCP\n      port: 5432\n  - to:                            # DNS\n    - namespaceSelector: {}\n      podSelector:\n        matchLabels:\n          k8s-app: kube-dns\n    ports:\n    - protocol: UDP\n      port: 53\n```\n\n**NetworkPolicy requires a compatible CNI** (Calico, Cilium, Weave, Antrea, AWS VPC CNI with policy enabled). If the CNI ignores NetworkPolicy, the manifests are decoration.\n\n## Step 5 — Secrets management\n\nK8s `Secret` objects are base64-encoded, not encrypted at the application level. At rest in etcd they are encrypted only if you configured encryption. They are still accessible to anyone with `get secrets` in the namespace.\n\nPatterns, from worst to best:\n\n1. **Env vars from `kind: Secret`** — workable but secrets leak via `kubectl describe pod`, env-dumping logs, child processes\n2. **Mounted as files via volume** — better; not in env, lifecycle is the pod\n3. **External secret manager via CSI driver \u002F External Secrets Operator** — secrets stay in Vault \u002F AWS Secrets Manager \u002F GCP Secret Manager, K8s only sees references\n4. **Workload Identity \u002F IRSA** — workload assumes a cloud IAM role directly, no secret crosses K8s at all\n\nStandard tooling:\n\n- **External Secrets Operator** (external-secrets.io) — syncs from cloud secret managers\n- **SealedSecrets** (Bitnami) — encrypt secrets in the repo with a cluster-specific key; the controller decrypts at apply time\n- **SOPS + age** — encrypted secrets in Git, decrypted at apply time via a Flux\u002FArgo plugin\n- **HashiCorp Vault** with the Vault Agent injector\n\nFor new clusters, prefer External Secrets + a cloud secret manager. SOPS is a good fit for GitOps-heavy teams.\n\n## Step 6 — Admission controllers\n\nPolicy-as-code that blocks non-compliant resources at API time. Two common choices:\n\n- **Kyverno** — K8s-native syntax, easier learning curve\n- **OPA Gatekeeper** — Rego policies, more flexible, used at scale\n\nBaseline policies worth enforcing:\n\n- Reject images from non-allowlisted registries\n- Reject images tagged `:latest` (only digests or version tags allowed)\n- Reject containers without `runAsNonRoot: true` (catches workloads that slipped past PSS)\n- Reject NetworkPolicy-less namespaces in production\n- Require resource limits (CPU\u002Fmemory) on every container\n- Reject `hostNetwork: true`, `hostPID: true`, `hostIPC: true` outside of audited exceptions\n\n```yaml\n# Kyverno example — require resource limits\napiVersion: kyverno.io\u002Fv1\nkind: ClusterPolicy\nmetadata:\n  name: require-resources\nspec:\n  validationFailureAction: enforce\n  rules:\n  - name: validate-resources\n    match:\n      any:\n      - resources:\n          kinds: [Pod]\n    validate:\n      message: \"Resource limits are required.\"\n      pattern:\n        spec:\n          containers:\n          - resources:\n              limits:\n                memory: \"?*\"\n                cpu: \"?*\"\n```\n\n## Step 7 — Image hygiene\n\n- **Scan every image before it lands in the cluster.** Trivy, Grype, or your registry's built-in scanner. See [`docker-container-security`](..\u002Fdocker-container-security\u002FSKILL.md).\n- **Pull by digest, not tag.** `myapp@sha256:abc123...` is immutable; `myapp:v1.2.3` can be repushed.\n- **Use a private registry** for app images; the public Docker Hub is a supply-chain surface.\n- **Enable registry-side admission** that rejects unsigned \u002F unscanned images. Sigstore \u002F cosign for signing; Kyverno or Gatekeeper for enforcement.\n\n## Step 8 — Cluster + control-plane hygiene\n\n- **kubeconfigs are credentials.** Treat them like SSH private keys. Rotate on team change. Scope per-user.\n- **No long-lived static admin token.** Use SSO (cloud provider's OIDC) or short-lived tokens.\n- **Don't `kubectl exec` in production casually.** It bypasses normal audit logging in some setups. Configure cluster audit policy to capture exec events explicitly.\n- **`kubectl proxy`** opens the API to localhost without auth — never on a shared dev machine.\n- **Restrict who can create resources in `kube-system`** — that namespace's pods can compromise the cluster.\n\n## Step 9 — Multi-tenancy (if applicable)\n\nIf multiple teams or customers share a cluster, hard isolation is hard. Options:\n\n- **Namespace per tenant** + strict RBAC + NetworkPolicy + ResourceQuotas — minimum bar\n- **vCluster \u002F Capsule** — virtual clusters inside one cluster, more isolated but operational overhead\n- **Cluster per tenant** — strongest isolation, highest cost\n\nA single-cluster multi-tenant setup with shared nodes is **soft isolation**. Container escape and kernel CVEs can cross tenants. For security-sensitive multi-tenancy, run separate node pools per tenant or move to per-tenant clusters.\n\n## Common findings on inherited clusters\n\nWalk this list against any cluster you're auditing:\n\n- API endpoint open to `0.0.0.0\u002F0`\n- Pod Security Admission not configured (or only at `audit`, not `enforce`)\n- Workloads using `default` ServiceAccount\n- ClusterRoleBindings to `cluster-admin` for human accounts or generic ServiceAccounts\n- No NetworkPolicy in any namespace (flat network)\n- CNI does not support NetworkPolicy (manifests present but ineffective)\n- Secrets in env vars throughout\n- Images pulled by `:latest`\n- No image scanning\n- No admission controller\n- Containers running as root (`runAsUser: 0` or unspecified)\n- `privileged: true` on application workloads\n- `hostNetwork: true` or `hostPath:` volumes outside system pods\n- Audit logging disabled or sent only to the cluster itself\n- kubeconfigs for `cluster-admin` shared on multiple machines\n- etcd backups absent or unencrypted\n\n## Quick audit script\n\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\necho \"=== Cluster version ===\"\nkubectl version --short\n\necho \"=== PSS labels per namespace ===\"\nkubectl get ns -o json | jq -r '.items[] | \"\\(.metadata.name)\\t\\(.metadata.labels \u002F\u002F {} | to_entries | map(select(.key | startswith(\"pod-security.kubernetes.io\"))) | from_entries)\"'\n\necho \"=== ServiceAccounts with cluster-admin ===\"\nkubectl get clusterrolebindings -o json | jq -r '.items[] | select(.roleRef.name == \"cluster-admin\") | \"\\(.metadata.name)\\t\\(.subjects \u002F\u002F [] | map(\"\\(.kind):\\(.namespace \u002F\u002F \"-\"):\\(.name)\") | join(\", \"))\"'\n\necho \"=== Namespaces without NetworkPolicy ===\"\nfor ns in $(kubectl get ns -o jsonpath='{.items[*].metadata.name}'); do\n  count=$(kubectl get networkpolicy -n \"$ns\" 2>\u002Fdev\u002Fnull | grep -c -v NAME)\n  [ \"$count\" -eq 0 ] && echo \"$ns\"\ndone\n\necho \"=== Pods running as root ===\"\nkubectl get pods -A -o json | jq -r '.items[] | select(.spec.securityContext.runAsNonRoot != true and (.spec.containers[]?.securityContext.runAsNonRoot \u002F\u002F false) != true) | \"\\(.metadata.namespace)\u002F\\(.metadata.name)\"' | head -30\n\necho \"=== Pods using :latest ===\"\nkubectl get pods -A -o json | jq -r '.items[] | \"\\(.metadata.namespace)\u002F\\(.metadata.name)\\t\\(.spec.containers[].image)\"' | grep ':latest' | head -30\n```\n\n## Checklist\n\n- [ ] K8s version is supported; auto-patching within the window\n- [ ] API endpoint restricted (private or CIDR-allowlisted)\n- [ ] Control-plane audit logging on, shipped off-cluster\n- [ ] etcd encryption at rest\n- [ ] Pod Security Standards: `restricted` enforced in app namespaces\n- [ ] Every workload has a dedicated ServiceAccount with minimal RBAC\n- [ ] `automountServiceAccountToken: false` for workloads not calling K8s API\n- [ ] Default-deny NetworkPolicy in every namespace; explicit allows\n- [ ] CNI supports NetworkPolicy enforcement\n- [ ] Secrets via External Secrets \u002F SealedSecrets \u002F Vault, not raw `kind: Secret` in env\n- [ ] Image scanning before admission\n- [ ] Images pinned by digest or version, not `:latest`\n- [ ] Admission controller (Kyverno \u002F Gatekeeper) enforcing baseline policies\n- [ ] No `privileged`, `hostNetwork`, `hostPID`, `hostIPC` in app workloads\n- [ ] kubeconfigs scoped per user, rotated on offboarding\n- [ ] Multi-tenancy strategy documented (or single-tenant explicitly)\n\n## What this skill will not do\n\n- Replace a full CIS Kubernetes Benchmark for regulated environments\n- Help compromise a cluster you do not own\n- Recommend `privileged: true` or `hostNetwork: true` for application workloads\n","# Kubernetes Security\n\nA pragmatic baseline for a single Kubernetes cluster running a small-team workload. Skews toward \"I have a cluster and need it to not be the cause of an incident\" — not a full CIS Benchmark for regulated environments. Most managed-K8s providers ship sensible defaults at the control-plane layer; the data-plane (your workloads) is where the work is.\n\n## When to invoke\n\n- Provisioning a new cluster\n- Inheriting a cluster with no documented hardening\n- Before adding a new tenant \u002F team \u002F workload to a shared cluster\n- After a K8s security advisory affecting your version\n- Periodic re-audit (quarterly)\n- Multi-tenant SaaS where customer workloads share infrastructure\n\n## Step 1 — Cluster baseline\n\nBefore workload hardening, the cluster itself.\n\n```bash\n# What version? Is it supported?\nkubectl version --short\n# K8s has a ~14-month support window. Unsupported = unpatched CVEs.\n\n# Who can reach the API?\nkubectl cluster-info\n# For managed clusters, check the provider's \"API endpoint\" access setting:\n# - Private endpoint, restricted CIDRs, or behind a bastion is correct\n# - \"Public, open to 0.0.0.0\u002F0\" is a finding\n\n# Audit log enabled?\n# For EKS\u002FGKE\u002FAKS: check the cluster's \"audit logging\" \u002F \"control-plane logging\" setting\n# Self-hosted: --audit-log-path on the API server\n```\n\nPatterns:\n\n- **Restrict the API endpoint.** Public + open is the worst default. Use private endpoint + bastion, or public + CIDR allowlist + IAM auth at minimum.\n- **Enable control-plane audit logging.** Without it, an incident has no record. Ship to a log destination outside the cluster (so a compromise cannot wipe its own audit trail).\n- **Pin to a supported version**, automate patching to within the support window.\n- **Encrypt etcd at rest.** Default-on for EKS, GKE, AKS. Self-hosted: configure `--encryption-provider-config`.\n\n## Step 2 — Pod Security Standards\n\nSince K8s 1.25, **Pod Security Admission** is built-in. There are three policy levels:\n\n| Level | What it allows | When to use |\n|---|---|---|\n| **Privileged** | Everything | System namespaces only (kube-system, ingress controllers that need it) |\n| **Baseline** | No privileged escalation, no host networking, no hostPath | Default for most workloads |\n| **Restricted** | The above plus: non-root user, read-only root filesystem, drop all capabilities, seccomp profile | Production application workloads |\n\nApply per namespace:\n\n```yaml\napiVersion: v1\nkind: Namespace\nmetadata:\n  name: production\n  labels:\n    pod-security.kubernetes.io\u002Fenforce: restricted\n    pod-security.kubernetes.io\u002Fenforce-version: latest\n    pod-security.kubernetes.io\u002Fwarn: restricted\n    pod-security.kubernetes.io\u002Faudit: restricted\n```\n\n`enforce` rejects non-compliant pods. `warn` returns a warning to the user. `audit` logs to the audit log.\n\nFor workloads that cannot meet `restricted` (legacy containers needing root), use `baseline` and document why. Anything in `privileged` mode is a finding unless it's a known infrastructure component.\n\nCommon adjustments to make existing workloads `restricted`-compliant:\n\n```yaml\n# In the pod spec\nsecurityContext:\n  runAsNonRoot: true\n  runAsUser: 1000\n  runAsGroup: 1000\n  fsGroup: 1000\n  seccompProfile:\n    type: RuntimeDefault\n\n# Per container\ncontainers:\n- name: app\n  securityContext:\n    allowPrivilegeEscalation: false\n    readOnlyRootFilesystem: true\n    capabilities:\n      drop: [ALL]\n    runAsNonRoot: true\n```\n\nAnything writable (cache, temp) goes to an `emptyDir` volume; the root filesystem stays read-only.\n\n## Step 3 — RBAC and ServiceAccounts\n\nThe single most common K8s misconfiguration: every workload running as the `default` ServiceAccount of its namespace, which often has more rights than the workload needs.\n\n```bash\n# What can the default ServiceAccount in 'production' do?\nkubectl auth can-i --list --as=system:serviceaccount:production:default -n production\n\n# What ServiceAccounts have cluster-admin or near-admin rights?\nkubectl get clusterrolebindings -o json \\\n  | jq -r '.items[] | select(.roleRef.name == \"cluster-admin\") | \"\\(.metadata.name) -> \\(.subjects | map(.name) | join(\",\"))\"'\n```\n\nPatterns:\n\n- **One ServiceAccount per workload.** Don't use `default`.\n- **`automountServiceAccountToken: false`** on workloads that don't talk to the K8s API. Most don't.\n- **Bind to a Role (namespace-scoped) before a ClusterRole** — `ClusterRoleBinding` should be rare and justified.\n- **Avoid `*` verbs and `*` resources** in Role rules.\n- **Audit `system:authenticated` and `system:anonymous`** — these should have minimal permissions, never cluster-admin.\n\nExample tight Role:\n\n```yaml\napiVersion: rbac.authorization.k8s.io\u002Fv1\nkind: Role\nmetadata:\n  name: app-reader\n  namespace: production\nrules:\n- apiGroups: [\"\"]\n  resources: [\"configmaps\"]\n  resourceNames: [\"app-config\"]\n  verbs: [\"get\"]\n```\n\nThe resource name pin matters — `verbs: [get]` on all configmaps is too broad if the workload only reads one.\n\n## Step 4 — NetworkPolicy (default-deny)\n\nBy default, every pod can talk to every other pod, in any namespace. That's a flat network — one compromised workload pivots freely.\n\n```yaml\n# Default-deny ingress AND egress in a namespace\napiVersion: networking.k8s.io\u002Fv1\nkind: NetworkPolicy\nmetadata:\n  name: default-deny-all\n  namespace: production\nspec:\n  podSelector: {}\n  policyTypes:\n  - Ingress\n  - Egress\n```\n\nThen explicitly allow what's needed:\n\n```yaml\napiVersion: networking.k8s.io\u002Fv1\nkind: NetworkPolicy\nmetadata:\n  name: app-allow\n  namespace: production\nspec:\n  podSelector:\n    matchLabels:\n      app: web\n  policyTypes: [Ingress, Egress]\n  ingress:\n  - from:\n    - namespaceSelector:\n        matchLabels:\n          name: ingress-nginx\n    ports:\n    - protocol: TCP\n      port: 8080\n  egress:\n  - to:\n    - podSelector:\n        matchLabels:\n          app: postgres\n    ports:\n    - protocol: TCP\n      port: 5432\n  - to:                            # DNS\n    - namespaceSelector: {}\n      podSelector:\n        matchLabels:\n          k8s-app: kube-dns\n    ports:\n    - protocol: UDP\n      port: 53\n```\n\n**NetworkPolicy requires a compatible CNI** (Calico, Cilium, Weave, Antrea, AWS VPC CNI with policy enabled). If the CNI ignores NetworkPolicy, the manifests are decoration.\n\n## Step 5 — Secrets management\n\nK8s `Secret` objects are base64-encoded, not encrypted at the application level. At rest in etcd they are encrypted only if you configured encryption. They are still accessible to anyone with `get secrets` in the namespace.\n\nPatterns, from worst to best:\n\n1. **Env vars from `kind: Secret`** — workable but secrets leak via `kubectl describe pod`, env-dumping logs, child processes\n2. **Mounted as files via volume** — better; not in env, lifecycle is the pod\n3. **External secret manager via CSI driver \u002F External Secrets Operator** — secrets stay in Vault \u002F AWS Secrets Manager \u002F GCP Secret Manager, K8s only sees references\n4. **Workload Identity \u002F IRSA** — workload assumes a cloud IAM role directly, no secret crosses K8s at all\n\nStandard tooling:\n\n- **External Secrets Operator** (external-secrets.io) — syncs from cloud secret managers\n- **SealedSecrets** (Bitnami) — encrypt secrets in the repo with a cluster-specific key; the controller decrypts at apply time\n- **SOPS + age** — encrypted secrets in Git, decrypted at apply time via a Flux\u002FArgo plugin\n- **HashiCorp Vault** with the Vault Agent injector\n\nFor new clusters, prefer External Secrets + a cloud secret manager. SOPS is a good fit for GitOps-heavy teams.\n\n## Step 6 — Admission controllers\n\nPolicy-as-code that blocks non-compliant resources at API time. Two common choices:\n\n- **Kyverno** — K8s-native syntax, easier learning curve\n- **OPA Gatekeeper** — Rego policies, more flexible, used at scale\n\nBaseline policies worth enforcing:\n\n- Reject images from non-allowlisted registries\n- Reject images tagged `:latest` (only digests or version tags allowed)\n- Reject containers without `runAsNonRoot: true` (catches workloads that slipped past PSS)\n- Reject NetworkPolicy-less namespaces in production\n- Require resource limits (CPU\u002Fmemory) on every container\n- Reject `hostNetwork: true`, `hostPID: true`, `hostIPC: true` outside of audited exceptions\n\n```yaml\n# Kyverno example — require resource limits\napiVersion: kyverno.io\u002Fv1\nkind: ClusterPolicy\nmetadata:\n  name: require-resources\nspec:\n  validationFailureAction: enforce\n  rules:\n  - name: validate-resources\n    match:\n      any:\n      - resources:\n          kinds: [Pod]\n    validate:\n      message: \"Resource limits are required.\"\n      pattern:\n        spec:\n          containers:\n          - resources:\n              limits:\n                memory: \"?*\"\n                cpu: \"?*\"\n```\n\n## Step 7 — Image hygiene\n\n- **Scan every image before it lands in the cluster.** Trivy, Grype, or your registry's built-in scanner. See [`docker-container-security`](..\u002Fdocker-container-security\u002FSKILL.md).\n- **Pull by digest, not tag.** `myapp@sha256:abc123...` is immutable; `myapp:v1.2.3` can be repushed.\n- **Use a private registry** for app images; the public Docker Hub is a supply-chain surface.\n- **Enable registry-side admission** that rejects unsigned \u002F unscanned images. Sigstore \u002F cosign for signing; Kyverno or Gatekeeper for enforcement.\n\n## Step 8 — Cluster + control-plane hygiene\n\n- **kubeconfigs are credentials.** Treat them like SSH private keys. Rotate on team change. Scope per-user.\n- **No long-lived static admin token.** Use SSO (cloud provider's OIDC) or short-lived tokens.\n- **Don't `kubectl exec` in production casually.** It bypasses normal audit logging in some setups. Configure cluster audit policy to capture exec events explicitly.\n- **`kubectl proxy`** opens the API to localhost without auth — never on a shared dev machine.\n- **Restrict who can create resources in `kube-system`** — that namespace's pods can compromise the cluster.\n\n## Step 9 — Multi-tenancy (if applicable)\n\nIf multiple teams or customers share a cluster, hard isolation is hard. Options:\n\n- **Namespace per tenant** + strict RBAC + NetworkPolicy + ResourceQuotas — minimum bar\n- **vCluster \u002F Capsule** — virtual clusters inside one cluster, more isolated but operational overhead\n- **Cluster per tenant** — strongest isolation, highest cost\n\nA single-cluster multi-tenant setup with shared nodes is **soft isolation**. Container escape and kernel CVEs can cross tenants. For security-sensitive multi-tenancy, run separate node pools per tenant or move to per-tenant clusters.\n\n## Common findings on inherited clusters\n\nWalk this list against any cluster you're auditing:\n\n- API endpoint open to `0.0.0.0\u002F0`\n- Pod Security Admission not configured (or only at `audit`, not `enforce`)\n- Workloads using `default` ServiceAccount\n- ClusterRoleBindings to `cluster-admin` for human accounts or generic ServiceAccounts\n- No NetworkPolicy in any namespace (flat network)\n- CNI does not support NetworkPolicy (manifests present but ineffective)\n- Secrets in env vars throughout\n- Images pulled by `:latest`\n- No image scanning\n- No admission controller\n- Containers running as root (`runAsUser: 0` or unspecified)\n- `privileged: true` on application workloads\n- `hostNetwork: true` or `hostPath:` volumes outside system pods\n- Audit logging disabled or sent only to the cluster itself\n- kubeconfigs for `cluster-admin` shared on multiple machines\n- etcd backups absent or unencrypted\n\n## Quick audit script\n\n```bash\n#!\u002Fusr\u002Fbin\u002Fenv bash\necho \"=== Cluster version ===\"\nkubectl version --short\n\necho \"=== PSS labels per namespace ===\"\nkubectl get ns -o json | jq -r '.items[] | \"\\(.metadata.name)\\t\\(.metadata.labels \u002F\u002F {} | to_entries | map(select(.key | startswith(\"pod-security.kubernetes.io\"))) | from_entries)\"'\n\necho \"=== ServiceAccounts with cluster-admin ===\"\nkubectl get clusterrolebindings -o json | jq -r '.items[] | select(.roleRef.name == \"cluster-admin\") | \"\\(.metadata.name)\\t\\(.subjects \u002F\u002F [] | map(\"\\(.kind):\\(.namespace \u002F\u002F \"-\"):\\(.name)\") | join(\", \"))\"'\n\necho \"=== Namespaces without NetworkPolicy ===\"\nfor ns in $(kubectl get ns -o jsonpath='{.items[*].metadata.name}'); do\n  count=$(kubectl get networkpolicy -n \"$ns\" 2>\u002Fdev\u002Fnull | grep -c -v NAME)\n  [ \"$count\" -eq 0 ] && echo \"$ns\"\ndone\n\necho \"=== Pods running as root ===\"\nkubectl get pods -A -o json | jq -r '.items[] | select(.spec.securityContext.runAsNonRoot != true and (.spec.containers[]?.securityContext.runAsNonRoot \u002F\u002F false) != true) | \"\\(.metadata.namespace)\u002F\\(.metadata.name)\"' | head -30\n\necho \"=== Pods using :latest ===\"\nkubectl get pods -A -o json | jq -r '.items[] | \"\\(.metadata.namespace)\u002F\\(.metadata.name)\\t\\(.spec.containers[].image)\"' | grep ':latest' | head -30\n```\n\n## Checklist\n\n- [ ] K8s version is supported; auto-patching within the window\n- [ ] API endpoint restricted (private or CIDR-allowlisted)\n- [ ] Control-plane audit logging on, shipped off-cluster\n- [ ] etcd encryption at rest\n- [ ] Pod Security Standards: `restricted` enforced in app namespaces\n- [ ] Every workload has a dedicated ServiceAccount with minimal RBAC\n- [ ] `automountServiceAccountToken: false` for workloads not calling K8s API\n- [ ] Default-deny NetworkPolicy in every namespace; explicit allows\n- [ ] CNI supports NetworkPolicy enforcement\n- [ ] Secrets via External Secrets \u002F SealedSecrets \u002F Vault, not raw `kind: Secret` in env\n- [ ] Image scanning before admission\n- [ ] Images pinned by digest or version, not `:latest`\n- [ ] Admission controller (Kyverno \u002F Gatekeeper) enforcing baseline policies\n- [ ] No `privileged`, `hostNetwork`, `hostPID`, `hostIPC` in app workloads\n- [ ] kubeconfigs scoped per user, rotated on offboarding\n- [ ] Multi-tenancy strategy documented (or single-tenant explicitly)\n\n## What this skill will not do\n\n- Replace a full CIS Kubernetes Benchmark for regulated environments\n- Help compromise a cluster you do not own\n- Recommend `privileged: true` or `hostNetwork: true` for application workloads\n",{"name":5,"description":7},"main","481dcd7dd2e288b9d627a2bd017db70e64e6c6fa","core\u002Fskills\u002Fgw360--kubernetes-security",2,"https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI","https:\u002F\u002Fyana.vutam.link\u002F","https:\u002F\u002Fgithub.com\u002FHoronomos-laps","https:\u002F\u002Fyana.vutam.link","An open-source governed runtime & execution environment for multi-agent AI systems.","2026-11-14 13:24:09",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add Horonomos-laps\u002FYana-AI --skill kubernetes-security",{"tool":40,"command":41},"bunx","bunx skills add Horonomos-laps\u002FYana-AI --skill kubernetes-security",{"tool":43,"command":44},"pnpm","pnpm dlx skills add Horonomos-laps\u002FYana-AI --skill kubernetes-security","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fgw360--kubernetes-security\u002FSKILL.md",true,[],[49,57,64,72,80,88],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":19},"01M735GKET5YVYKAY62W2P5YXB","openai--sentry--sentry","Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.","MIT","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fopenai--sentry--sentry\u002FSKILL.md",[],[],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M73DCAP83T17HY7SMGK7MGFE","ito-basket-compare","Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fito-basket-compare\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":68,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M734CYEMZFDR3KH6SW0JP8TD","implementing-network-traffic-baselining","Build network traffic baselines from NetFlow\u002FIPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly\u002Fdaily traffic pattern profiling","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\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},"01M73ASZ6NJRJM44Z2P84NGQ3Q","detecting-evasion-techniques-in-endpoint-logs","Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\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":84,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M734AFNXD06Z78QRK0VKGT7Q","implementing-microsegmentation-with-guardicore","Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"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":91,"categories":92,"keywords":93,"publishedAt":19},"01M736TK27QMCXK0DVCH25SJN5","ramdisk-tmpfs-patterns","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Framdisk-tmpfs-patterns\u002FSKILL.md",[],[]]