Back to Skills

managing-network-policies

jeremylongshore
Updated Today
18 views
712
74
712
View on GitHub
Metaapi

About

This Claude Skill generates Kubernetes NetworkPolicy manifests to secure pod communication. It follows least-privilege and zero-trust principles, automating policy creation based on natural language requests. Use it when you need to create, configure, or restrict network policies and firewall rules within a Kubernetes cluster.

Quick Install

Claude Code

Recommended
Plugin CommandRecommended
/plugin add https://github.com/jeremylongshore/claude-code-plugins-plus
Git CloneAlternative
git clone https://github.com/jeremylongshore/claude-code-plugins-plus.git ~/.claude/skills/managing-network-policies

Copy and paste this command in Claude Code to install this skill

Documentation

Prerequisites

Before using this skill, ensure:

  • Kubernetes cluster has network policy support enabled
  • Network plugin supports policies (Calico, Cilium, Weave)
  • Pod labels are properly defined for policy selectors
  • Understanding of application communication patterns
  • Namespace isolation strategy is defined

Instructions

  1. Identify Requirements: Determine which pods need to communicate
  2. Define Selectors: Use pod/namespace labels for policy targeting
  3. Configure Ingress: Specify allowed incoming traffic sources and ports
  4. Configure Egress: Define allowed outgoing traffic destinations
  5. Test Policies: Verify connectivity works as expected
  6. Monitor Denials: Check for blocked traffic in network plugin logs
  7. Iterate: Refine policies based on application behavior

Output

Network Policy Examples:

# {baseDir}/network-policies/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
---
# Deny all ingress by default
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny-ingress
  namespace: production
spec:
  podSelector: {}
  policyTypes:
    - Ingress

Egress Policy:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-external-api
spec:
  podSelector:
    matchLabels:
      app: api-client
  policyTypes:
    - Egress
  egress:
    - to:
      - namespaceSelector:
          matchLabels:
            name: external-services
      ports:
      - protocol: TCP
        port: 443

Error Handling

Policy Not Applied

  • Error: Traffic still blocked/allowed contrary to policy
  • Solution: Verify network plugin supports policies and policy is applied to correct namespace

DNS Resolution Fails

  • Error: Pods cannot resolve DNS after applying policy
  • Solution: Add egress rule allowing DNS traffic to kube-dns/coredns

No Communication After Policy

  • Error: All traffic blocked unexpectedly
  • Solution: Check for default-deny policies and ensure explicit allow rules exist

Label Mismatch

  • Error: Policy not targeting intended pods
  • Solution: Verify pod labels match policy selectors using kubectl get pods --show-labels

Resources

GitHub Repository

jeremylongshore/claude-code-plugins-plus
Path: plugins/devops/network-policy-manager/skills/network-policy-manager
aiautomationclaude-codedevopsmarketplacemcp

Related Skills

evaluating-llms-harness

Testing

This Claude Skill runs the lm-evaluation-harness to benchmark LLMs across 60+ standardized academic tasks like MMLU and GSM8K. It's designed for developers to compare model quality, track training progress, or report academic results. The tool supports various backends including HuggingFace and vLLM models.

View skill

langchain

Meta

LangChain is a framework for building LLM applications using agents, chains, and RAG pipelines. It supports multiple LLM providers, offers 500+ integrations, and includes features like tool calling and memory management. Use it for rapid prototyping and deploying production systems like chatbots, autonomous agents, and question-answering services.

View skill

huggingface-accelerate

Development

HuggingFace Accelerate provides the simplest API for adding distributed training to PyTorch scripts with just 4 lines of code. It offers a unified interface for multiple distributed training frameworks like DeepSpeed, FSDP, and DDP while handling automatic device placement and mixed precision. This makes it ideal for developers who want to quickly scale their PyTorch training across multiple GPUs or nodes without complex configuration.

View skill

nestjs

Meta

This skill provides NestJS development standards and architectural patterns for building domain-centric applications. It covers modular design, dependency injection, decorator patterns, and key framework features like controllers, services, middleware, and interceptors. Use it when developing NestJS applications, implementing APIs, configuring microservices, or integrating with databases.

View skill