Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Kubernetes security policy expertise from a comprehensive 146-skill, 112-agent multi-agent orchestration system.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
assets/network-policy-template.yaml
1# Network Policy Templates23---4# Template 1: Default Deny All (Start Here)5apiVersion: networking.k8s.io/v16kind: NetworkPolicy7metadata:8name: default-deny-all9namespace: <namespace>10spec:11podSelector: {}12policyTypes:13- Ingress14- Egress1516---17# Template 2: Allow DNS (Essential)18apiVersion: networking.k8s.io/v119kind: NetworkPolicy20metadata:21name: allow-dns22namespace: <namespace>23spec:24podSelector: {}25policyTypes:26- Egress27egress:28- to:29- namespaceSelector:30matchLabels:31name: kube-system32ports:33- protocol: UDP34port: 533536---37# Template 3: Frontend to Backend38apiVersion: networking.k8s.io/v139kind: NetworkPolicy40metadata:41name: allow-frontend-to-backend42namespace: <namespace>43spec:44podSelector:45matchLabels:46app: backend47tier: backend48policyTypes:49- Ingress50ingress:51- from:52- podSelector:53matchLabels:54app: frontend55tier: frontend56ports:57- protocol: TCP58port: 808059- protocol: TCP60port: 90906162---63# Template 4: Allow Ingress Controller64apiVersion: networking.k8s.io/v165kind: NetworkPolicy66metadata:67name: allow-ingress-controller68namespace: <namespace>69spec:70podSelector:71matchLabels:72app: web73policyTypes:74- Ingress75ingress:76- from:77- namespaceSelector:78matchLabels:79name: ingress-nginx80ports:81- protocol: TCP82port: 8083- protocol: TCP84port: 4438586---87# Template 5: Allow Monitoring (Prometheus)88apiVersion: networking.k8s.io/v189kind: NetworkPolicy90metadata:91name: allow-prometheus-scraping92namespace: <namespace>93spec:94podSelector:95matchLabels:96prometheus.io/scrape: "true"97policyTypes:98- Ingress99ingress:100- from:101- namespaceSelector:102matchLabels:103name: monitoring104ports:105- protocol: TCP106port: 9090107108---109# Template 6: Allow External HTTPS110apiVersion: networking.k8s.io/v1111kind: NetworkPolicy112metadata:113name: allow-external-https114namespace: <namespace>115spec:116podSelector:117matchLabels:118app: api-client119policyTypes:120- Egress121egress:122- to:123- ipBlock:124cidr: 0.0.0.0/0125except:126- 169.254.169.254/32 # Block metadata service127ports:128- protocol: TCP129port: 443130131---132# Template 7: Database Access133apiVersion: networking.k8s.io/v1134kind: NetworkPolicy135metadata:136name: allow-app-to-database137namespace: <namespace>138spec:139podSelector:140matchLabels:141app: postgres142tier: database143policyTypes:144- Ingress145ingress:146- from:147- podSelector:148matchLabels:149tier: backend150ports:151- protocol: TCP152port: 5432153154---155# Template 8: Cross-Namespace Communication156apiVersion: networking.k8s.io/v1157kind: NetworkPolicy158metadata:159name: allow-from-prod-namespace160namespace: <namespace>161spec:162podSelector:163matchLabels:164app: api165policyTypes:166- Ingress167ingress:168- from:169- namespaceSelector:170matchLabels:171environment: production172podSelector:173matchLabels:174app: frontend175ports:176- protocol: TCP177port: 8080178