Infra & Cloud
yaml
Advanced
Kubernetes Network Policy
Deny all ingress by default and only allow traffic from specific namespaces.
yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all-ingress
spec:
podSelector: {}
policyTypes: [Ingress]
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-from-api
spec:
podSelector:
matchLabels: { app: database }
ingress:
- from:
- podSelector:
matchLabels: { app: api }
Prerequisites
- Kubernetes >= 1.26
- CNI with NetworkPolicy support
Pro Tips
- → Test with kubectl exec + nc before applying to production.
Commercial Licensing
Acquire a production access token or template license for enterprise deployment.
Module Info
- Language
- yaml
- Level
- Advanced
- Read time
- 4 min
- Published
- Nov 2025
- License
- Commercial License
Newsletter
New modules every week, directly to your inbox.
Similar Modules
AWS S3 Static Website
Terraform module to provision an S3 bucket for static website hosting.
terraform
·
Intermediate
AWS RDS Postgres Terraform
Terraform resource for an RDS PostgreSQL instance with encryption and backup.
terraform
·
Intermediate
ECS Task Force Stop
Force-stop all running ECS tasks in a service for emergency rollback.
bash
·
Intermediate