Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Implement Kubernetes security policies including NetworkPolicy, PodSecurityPolicy, and RBAC for production-grade security. Use when securing Kubernetes clusters, implementing network isolation, or enforcing pod security standards.
.claude/skills/microck-k8s-security-policies/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-20 | ✗→✓ | ▲ Improved | 149% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 223% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 186% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 282% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 215% | 0% |
Comprehensive guide for implementing NetworkPolicy, PodSecurityPolicy, RBAC, and Pod Security Standards in Kubernetes.
Implement defense-in-depth security for Kubernetes clusters using network policies, pod security standards, and RBAC.
yamlapiVersion: v1 kind: Namespace metadata: name: privileged-ns labels: pod-security.kubernetes.io/enforce: privileged pod-security.kubernetes.io/audit: privileged pod-security.kubernetes.io/warn: privileged
yamlapiVersion: v1 kind: Namespace metadata: name: baseline-ns labels: pod-security.kubernetes.io/enforce: baseline pod-security.kubernetes.io/audit: baseline pod-security.kubernetes.io/warn: baseline
yamlapiVersion: v1 kind: Namespace metadata: name: restricted-ns labels: pod-security.kubernetes.io/enforce: restricted pod-security.kubernetes.io/audit: restricted pod-security.kubernetes.io/warn: restricted
yamlapiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: default-deny-all namespace: production spec: podSelector: {} policyTypes: - Ingress - Egress
yamlapiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: allow-frontend-to-backend namespace: production spec: podSelector: matchLabels: app: backend policyTypes: - Ingress ingress: - from: - podSelector: matchLabels: app: frontend ports: - protocol: TCP port: 8080
yamlapiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: allow-dns namespace: production spec: podSelector: {} policyTypes: - Egress egress: - to: - namespaceSelector: matchLabels: name: kube-system ports: - protocol: UDP port: 53
Reference: See assets/network-policy-template.yaml
yamlapiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: pod-reader namespace: production rules: - apiGroups: [""] resources: ["pods"] verbs: ["get", "watch", "list"]
yamlapiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: secret-reader rules: - apiGroups: [""] resources: ["secrets"] verbs: ["get", "watch", "list"]
yamlapiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: read-pods namespace: production subjects: - kind: User name: jane apiGroup: rbac.authorization.k8s.io - kind: ServiceAccount name: default namespace: production roleRef: kind: Role name: pod-reader apiGroup: rbac.authorization.k8s.io
Reference: See references/rbac-patterns.md
yamlapiVersion: v1 kind: Pod metadata: name: secure-pod spec: securityContext: runAsNonRoot: true runAsUser: 1000 fsGroup: 1000 seccompProfile: type: RuntimeDefault containers: - name: app image: myapp:1.0 securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true capabilities: drop: - ALL
yamlapiVersion: templates.gatekeeper.sh/v1 kind: ConstraintTemplate metadata: name: k8srequiredlabels spec: crd: spec: names: kind: K8sRequiredLabels validation: openAPIV3Schema: type: object properties: labels: type: array items: type: string targets: - target: admission.k8s.gatekeeper.sh rego: | package k8srequiredlabels violation[{"msg": msg, "details": {"missing_labels": missing}}] { provided := {label | input.review.object.metadata.labels[label]} required := {label | label := input.parameters.labels[_]} missing := required - provided count(missing) > 0 msg := sprintf("missing required labels: %v", [missing]) }
yamlapiVersion: constraints.gatekeeper.sh/v1beta1 kind: K8sRequiredLabels metadata: name: require-app-label spec: match: kinds: - apiGroups: ["apps"] kinds: ["Deployment"] parameters: labels: ["app", "environment"]
yamlapiVersion: security.istio.io/v1beta1 kind: PeerAuthentication metadata: name: default namespace: production spec: mtls: mode: STRICT
yamlapiVersion: security.istio.io/v1beta1 kind: AuthorizationPolicy metadata: name: allow-frontend namespace: production spec: selector: matchLabels: app: backend action: ALLOW rules: - from: - source: principals: ["cluster.local/ns/production/sa/frontend"]
NetworkPolicy not working:
bash# Check if CNI supports NetworkPolicy kubectl get nodes -o wide kubectl describe networkpolicy <name>
RBAC permission denied:
bash# Check effective permissions kubectl auth can-i list pods --as system:serviceaccount:default:my-sa kubectl auth can-i '*' '*' --as system:serviceaccount:default:my-sa
assets/network-policy-template.yaml - Network policy examplesassets/pod-security-template.yaml - Pod security policiesreferences/rbac-patterns.md - RBAC configuration patternsk8s-manifest-generator - For creating secure manifestsgitops-workflow - For automated policy deployment| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | pass→pass | 4,588 | 5,213 | +14% | 1 | 1 | 0% | 883 | 2,851 | +223% | 0 | 0 | — |
case-02 | pass→pass | 5,061 | 5,318 | +5% | 1 | 1 | 0% | 954 | 2,732 | +186% | 0 | 0 | — |
case-03 | pass→pass | 4,187 | 3,660 | -13% | 1 | 1 | 0% | 694 | 2,648 | +282% | 0 | 0 | — |
case-04 | pass→pass | 5,241 | 5,044 | -4% | 1 | 1 | 0% | 926 | 2,919 | +215% | 0 | 0 | — |
case-05 | pass→pass | 6,224 | 3,898 | -37% | 1 | 1 | 0% | 744 | 2,561 | +244% | 0 | 0 | — |
case-06 | pass→pass | 5,926 | 8,680 | +46% | 1 | 1 | 0% | 1,205 | 3,608 | +199% | 0 | 0 | — |
case-07 | pass→pass | 5,438 | 4,058 | -25% | 1 | 1 | 0% | 990 | 2,709 | +174% | 0 | 0 | — |
case-08 | pass→pass | 3,034 | 4,291 | +41% | 1 | 1 | 0% | 525 | 2,716 | +417% | 0 | 0 | — |
case-09 | pass→pass | 4,981 | 4,042 | -19% | 1 | 1 | 0% | 911 | 2,768 | +204% | 0 | 0 | — |
case-10 | pass→pass | 5,476 | 6,587 | +20% | 1 | 1 | 0% | 1,061 | 3,229 | +204% | 0 | 0 | — |
case-11 | pass→pass | 3,884 | 3,272 | -16% | 1 | 1 | 0% | 723 | 2,482 | +243% | 0 | 0 | — |
case-12 | pass→pass | 9,185 | 7,037 | -23% | 1 | 1 | 0% | 1,776 | 3,318 | +87% | 0 | 0 | — |
case-13 | pass→pass | 7,861 | 3,442 | -56% | 1 | 1 | 0% | 1,533 | 2,489 | +62% | 0 | 0 | — |
case-14 | pass→pass | 2,764 | 2,721 | -2% | 1 | 1 | 0% | 505 | 2,351 | +366% | 0 | 0 | — |
case-15 | pass→pass | 3,639 | 4,777 | +31% | 1 | 1 | 0% | 692 | 2,762 | +299% | 0 | 0 | — |
case-16 | pass→pass | 4,647 | 3,716 | -20% | 1 | 1 | 0% | 841 | 2,502 | +198% | 0 | 0 | — |
case-22 | pass→pass | 14,449 | 18,092 | +25% | 1 | 1 | 0% | 2,933 | 4,805 | +64% | 0 | 0 | — |
case-17 | fail→fail | 9,271 | 8,207 | -11% | 1 | 1 | 0% | 1,559 | 3,236 | +108% | 0 | 0 | — |
case-18 | pass→pass | 21,948 | 14,418 | -34% | 1 | 1 | 0% | 3,185 | 4,364 | +37% | 0 | 0 | — |
case-19 | pass→pass | 6,144 | 6,333 | +3% | 1 | 1 | 0% | 1,019 | 3,065 | +201% | 0 | 0 | — |
case-20 | fail→pass | 7,238 | 6,519 | -10% | 1 | 1 | 0% | 1,217 | 3,027 | +149% | 0 | 0 | — |
case-21 | pass→pass | 11,227 | 8,261 | -26% | 1 | 1 | 0% | 2,265 | 3,512 | +55% | 0 | 0 | — |
case-23 | pass→pass | 11,118 | 12,184 | +10% | 1 | 1 | 0% | 2,016 | 4,206 | +109% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +4 percentage points is the difference between those two pass rates over the 23 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.