Kubernetes NetworkPolicy YAML Security Rule Generator
Create fine-grained Kubernetes NetworkPolicy YAML manifests with Ingress/Egress CIDR blocks, podSelector labels, namespaceSelector, and port restrictions.
Define which pods inside namespace "production" this security policy restricts.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: backend-api-netpol
namespace: production
labels:
tier: api
spec:
podSelector:
matchLabels:
app: backend-api
tier: api
policyTypes:
- Ingress
- Egress
ingress:
- # Allow HTTP from Frontend Pods
from:
- podSelector:
matchLabels:
app: web-frontend
ports:
- protocol: TCP
port: 8080
- # Allow Metrics Scraping from Monitoring Namespace
from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: monitoring
podSelector:
matchLabels:
app: prometheus
ports:
- protocol: TCP
port: 9090
egress:
- # Allow CoreDNS Resolution in kube-system
to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
podSelector:
matchLabels:
k8s-app: kube-dns
ports:
- protocol: UDP
port: 53
- protocol: TCP
port: 53
- # Allow PostgreSQL Connection
to:
- podSelector:
matchLabels:
app: postgres
ports:
- protocol: TCP
port: 5432
- # Allow Redis Cluster Egress
to:
- podSelector:
matchLabels:
app: redis
ports:
- protocol: TCP
port: 6379Zero-Trust Microsegmentation
Generate RFC-compliant Kubernetes networking policies with precise podSelector, CIDR blocks, and port whitelisting.
100% In-Browser Privacy
All policy configurations, IP subnets, and cluster topology remain strictly in your browser memory with zero network calls.
Production GitOps Delivery
Instantly exports standard Kubernetes manifests alongside parameterized Helm templates and Kustomize overlays.