Design and validate Kubernetes NetworkPolicies following Zero Trust principles (NIST SP 800-207). Two-tier analysis — architecture review then live cluster verification — produces a verified implementation plan with apply-and-verify results. Use when: - "Create NetworkPolicies for my namespace" - "Audit network isolation for this workload" - "Design network segmentation for a new application" - "Verify NetworkPolicies implement Zero Trust" - User mentions "network policy", "microsegmentation", "default-deny" NOT for Admin Network Policy (ANP) cluster-wide rules — those are cluster-admin infrastructure guardrails, not application-level microsegmentation. NOT for CNI plugin configuration or Multus secondary networks.
73
92%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Audience: Platform engineers and security architects responsible for Kubernetes network segmentation.
Goal: Design NetworkPolicies that enforce the principle of least privilege at the network layer — every connection must be explicitly justified and authorized.
This skill follows NIST SP 800-207 (Zero Trust Architecture) which states:
"Zero trust assumes there is no implicit trust granted to assets or user accounts based solely on their physical or network location."
Recommendations carry the weight of a security audit. Every rule proposed must be justified. Every port opened must be documented. Every exception must be explicitly acknowledged by the user.
MCP-First Approach: This skill uses MCP tools from openshift-administration server. MCP tools have absolute priority.
CLI Tools Policy:
oc, kubectl) may be attempted if no MCP alternative existsRequired MCP Servers: openshift-administration — Kubernetes/OpenShift cluster operations (setup guide)
Required MCP Tools (all from openshift-administration server):
pods_list — list pods in a namespace with status and labelsresources_list — list resources by apiVersion/kind in a namespaceresources_get — get a single resource by apiVersion/kind/nameresources_create_or_update — apply NetworkPolicy YAML (for temporary verification)resources_delete — remove dry-run NetworkPoliciesEnvironment Variables:
KUBECONFIG — path to kubeconfig with access to the target clusterVerification Steps:
openshift-administration MCP server is availableKUBECONFIG is set: test -n "$KUBECONFIG" && echo "✓ Set" || echo "✗ Missing"namespaces_listHuman Notification Protocol:
When prerequisites fail:
❌ Cannot execute skill: MCP server `openshift-administration` unavailable
📋 Setup: Configure the openshift MCP server in mcps.json with KUBECONFIGSecurity: Never display credential values. Only report whether KUBECONFIG is set.
Use when:
Do NOT use when:
This skill operates in two mandatory tiers. Both must be completed before producing the final implementation plan.
Objective: Understand the application's communication requirements from source code, documentation, and deployment manifests — before touching a live cluster.
For each pod type in the namespace, document:
hostNetwork (critical — NetworkPolicies do NOT apply to hostNetwork pods)hostPID or hostIPCFor each service:
For each pod type, determine:
Some operators create and manage their own NetworkPolicies (e.g., RHBK operator creates keycloak-network-policy). These must NOT be duplicated or overridden — the operator will revert changes. Document them and design around them.
podSelector/namespaceSelector cannot match them. Use port-only rules.policy-group.network.openshift.io/ingress namespace label for ingress matching.openshift-dns.For each pod type, propose:
Tier 1 output: Present the communication map and draft rules to the user. Get confirmation before proceeding to Tier 2.
Objective: Validate the draft rules against a running cluster. Confirm actual pod labels, ports, connections, and behavior.
Prerequisites: User must have an OCP/Kubernetes cluster with the target application deployed and healthy. The openshift-administration MCP server must be connected.
MCP Tool: pods_list (from openshift-administration)
Parameters:
namespace: "" (string, target namespace to verify)Expected Output: List of pods with name, status, and ready state.
Error Handling:
MCP Tool: resources_list (from openshift-administration)
Parameters:
apiVersion: "v1" (string)kind: "Pod" (string)namespace: "" (string)Expected Output: Full pod specs including metadata.labels. Confirm labels match the selectors drafted in Tier 1.
Error Handling:
MCP Tool: resources_list (from openshift-administration)
Parameters (Services):
apiVersion: "v1"kind: "Service"namespace: ""Parameters (Endpoints):
apiVersion: "v1"kind: "Endpoints"namespace: ""Expected Output: Services with ports, selectors, and endpoint addresses.
Error Handling:
MCP Tool: resources_list (from openshift-administration)
Parameters:
apiVersion: "route.openshift.io/v1"kind: "Route"namespace: ""Expected Output: Routes with host, TLS termination, and target service.
Error Handling:
MCP Tool: resources_list (from openshift-administration)
Parameters:
apiVersion: "networking.k8s.io/v1"kind: "NetworkPolicy"namespace: ""Expected Output: Existing policies including operator-managed ones. Cross-reference with Tier 1 Step 4 findings.
Error Handling:
MCP Tool: resources_list (from openshift-administration)
Parameters (Deployments):
apiVersion: "apps/v1"kind: "Deployment"namespace: ""Repeat for kind: "StatefulSet" and kind: "DaemonSet".
Expected Output: Workload specs including spec.template.spec.containers[].ports and spec.template.spec.hostNetwork.
Error Handling:
MCP Tool: pods_log (from openshift-administration)
Parameters:
namespace: ""name: "" (string, specific pod name)tail: 100 (integer, recent lines)For each pod type, check logs for:
Error Handling:
Human Confirmation Required — display all policies and wait for approval before applying.
MCP Tool: resources_create_or_update (from openshift-administration)
Parameters:
resource: "" (string, complete NetworkPolicy manifest)Apply each proposed NetworkPolicy. Then verify:
pods_list)pods_log)For each verification check, record PASS or FAIL with evidence.
If any check FAILS: Immediately proceed to Step 16 to remove the applied policies before diagnosing the issue. Report the failure evidence to the user and ask how to proceed (fix draft rules and retry, or abort).
Human Confirmation Required — list policies and wait for approval.
MCP Tool: resources_delete (from openshift-administration)
Parameters:
apiVersion: "networking.k8s.io/v1"kind: "NetworkPolicy"name: "" (string)namespace: "" (string)Error Handling:
After both tiers are complete, produce the final implementation plan.
The plan MUST include:
A default-deny NetworkPolicy MUST be included in every implementation plan.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-in-namespace-<namespace>
spec:
podSelector: {}
policyTypes:
- Ingress
- EgressIf the user decides NOT to implement default-deny, this must be:
For each pod type, document:
| Field | Detail |
|---|---|
| Pod type | Name, labels, workload type |
| Policy name | Kubernetes NetworkPolicy name |
| Ingress rules | Each rule with: port, protocol, source (selector or port-only), justification |
| Egress rules | Each rule with: port, protocol, destination (selector or port-only), justification |
| Why this rule exists | Reference to the communication flow identified in Tier 1 |
| What breaks if removed | Specific failure mode |
Document each exception:
| Verification | Result | Evidence |
|---|---|---|
| All pods Running after NP applied | PASS/FAIL | pods_list output |
| Routes respond | PASS/FAIL | HTTP status codes |
| Dependent apps work | PASS/FAIL | Specific checks performed |
| Pod restart recovery | PASS/FAIL | Logs showing re-attestation/reconnection |
| No new errors in logs | PASS/FAIL | Log excerpts |
Recommend the deployment method:
extraValueFiles in their pattern.Map each policy to Zero Trust principles:
enabled: true), always use (eq (.Values.field | toString) "true") — not bare .Values.field. Helm overrides via extraValueFiles and pattern frameworks often pass booleans as strings ("true" not true). Bare boolean evaluation fails silently when the value is a string, causing policies to not render. Apply | toString consistently to ALL condition halves in {{- if and ... }} expressions.openshift-administration for cluster operations. Do not use oc or kubectl CLI commands unless no MCP alternative exists.openshift-administration — Kubernetes/OpenShift cluster operations for resource queries, policy application, and log inspection (setup guide)pods_list (from openshift-administration) — list pods with status and labels
resources_list (from openshift-administration) — list resources by apiVersion/kind
resources_get (from openshift-administration) — get single resource
resources_create_or_update (from openshift-administration) — apply NetworkPolicy YAML
resources_delete (from openshift-administration) — delete NetworkPolicy
pods_log (from openshift-administration) — read pod logs
/cluster-report — use for multi-cluster health overview before designing policiesOfficial: Kubernetes NetworkPolicy API Official: OpenShift Networking - NetworkPolicy Official: NIST SP 800-207 - Zero Trust Architecture Official: Admin Network Policy API
This skill performs operations that modify cluster state, requiring explicit user confirmation:
Before applying NetworkPolicies (Step 14)
Before force-restarting pods (Step 14)
Before removing verification policies (Step 16)
Default-deny exception
Never assume approval — always wait for explicit confirmation before apply, delete, or restart operations.
User: "Create NetworkPolicies for the qtodo namespace following Zero Trust principles"
Skill response:
e46c4fa
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.