Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Implement Kubernetes network segmentation using Calico NetworkPolicy and GlobalNetworkPolicy for zero-trust pod-to-pod communication.
.claude/skills/implementing-kubernetes-network-policy-with-calico/SKILL.md| Model | Eval pass | Runs |
|---|---|---|
| gemini-3.6-flash | 67% | 19 |
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-18 | ✗→✓ | ▲ Improved | — | — |
| case-22 | ✗→✓ | ▲ Improved | — | — |
| case-11 | ✗→✓ | ▲ Improved | — | — |
| case-01 | ✗→✓ | ▲ Improved | — | — |
| case-15 | ✗→✓ | ▲ Improved | — | — |
Calico is an open-source CNI plugin that provides fine-grained network policy enforcement for Kubernetes clusters. It implements the full Kubernetes NetworkPolicy API and extends it with Calico-specific GlobalNetworkPolicy, supporting policy ordering, deny rules, and service-account-based selectors.
kubectl and calicoctl CLI toolsbash# Install the Tigera operator kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.27.0/manifests/tigera-operator.yaml # Install Calico custom resources kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.27.0/manifests/custom-resources.yaml # Verify installation kubectl get pods -n calico-system watch kubectl get pods -n calico-system # Install calicoctl kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.27.0/manifests/calicoctl.yaml
bash# Check Calico pods kubectl get pods -n calico-system # Check Calico node status kubectl exec -n calico-system calicoctl -- calicoctl node status # Check IP pools kubectl exec -n calico-system calicoctl -- calicoctl get ippool -o wide
yaml# deny-all-ingress.yaml apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: default-deny-ingress namespace: production spec: podSelector: {} policyTypes: - Ingress --- # deny-all-egress.yaml apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: default-deny-egress namespace: production spec: podSelector: {} policyTypes: - Egress
yaml# allow-frontend-to-backend.yaml apiVersion: 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
yaml# allow-dns-egress.yaml apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: allow-dns-egress namespace: production spec: podSelector: {} policyTypes: - Egress egress: - to: - namespaceSelector: {} ports: - protocol: UDP port: 53 - protocol: TCP port: 53
yaml# allow-same-namespace.yaml apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: allow-same-namespace namespace: production spec: podSelector: {} policyTypes: - Ingress ingress: - from: - podSelector: {}
yaml# global-deny-external.yaml apiVersion: projectcalico.org/v3 kind: GlobalNetworkPolicy metadata: name: deny-external-ingress spec: order: 100 selector: "projectcalico.org/namespace != 'ingress-nginx'" types: - Ingress ingress: - action: Deny source: nets: - 0.0.0.0/0 destination: {}
yaml# calico-deny-policy.yaml apiVersion: projectcalico.org/v3 kind: NetworkPolicy metadata: name: deny-database-from-frontend namespace: production spec: order: 10 selector: app == 'database' types: - Ingress ingress: - action: Deny source: selector: app == 'frontend' - action: Allow source: selector: app == 'backend' destination: ports: - 5432
yaml# sa-based-policy.yaml apiVersion: projectcalico.org/v3 kind: NetworkPolicy metadata: name: allow-by-service-account namespace: production spec: selector: app == 'api' ingress: - action: Allow source: serviceAccounts: names: - frontend-sa - monitoring-sa egress: - action: Allow destination: serviceAccounts: names: - database-sa
yaml# host-endpoint-policy.yaml apiVersion: projectcalico.org/v3 kind: GlobalNetworkPolicy metadata: name: restrict-host-ssh spec: order: 10 selector: "has(kubernetes.io/hostname)" applyOnForward: false types: - Ingress ingress: - action: Allow protocol: TCP source: nets: - 10.0.0.0/8 destination: ports: - 22 - action: Deny protocol: TCP destination: ports: - 22
yaml# security-tier.yaml apiVersion: projectcalico.org/v3 kind: Tier metadata: name: security spec: order: 100 --- # platform-tier.yaml apiVersion: projectcalico.org/v3 kind: Tier metadata: name: platform spec: order: 200
bash# List all network policies kubectl get networkpolicy --all-namespaces # List Calico-specific policies kubectl exec -n calico-system calicoctl -- calicoctl get networkpolicy --all-namespaces -o wide kubectl exec -n calico-system calicoctl -- calicoctl get globalnetworkpolicy -o wide # Check policy evaluation for a specific endpoint kubectl exec -n calico-system calicoctl -- calicoctl get workloadendpoint -n production -o yaml # View Calico logs kubectl logs -n calico-system -l k8s-app=calico-node --tail=100 # Test connectivity kubectl exec -n production frontend-pod -- wget -qO- --timeout=2 http://backend-svc:8080/health
order field) to control evaluation precedence| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-23 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
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 +48 percentage points is the difference between those two pass rates over the 23 comparable cases.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.