Cold packets hit the firewall and vanish. Only the permitted survive. This is the promise of Kubernetes Network Policies when used to secure a database access gateway.
Kubernetes does not protect your network traffic by default. Pods can talk to each other freely, even across namespaces. If your database accepts connections from anywhere inside the cluster, it is exposed to accidental queries and malicious traffic. The solution is to block everything, then open only what you need. Network Policies give you that control.
To secure a database access gateway, start by labeling the pods that run the gateway. Then apply a NetworkPolicy that restricts ingress only from trusted application pods and namespaces. This prevents rogue workloads from sending traffic to the gateway. A second policy can restrict egress from the gateway, ensuring it only connects to the database’s service on its internal port.
Ingress rules define who can access the gateway. Egress rules define where the gateway can send traffic. Both rely on Kubernetes selectors and CIDR IP blocks. Keep the rules tight and simple. Test connectivity after each change using a temporary debug pod. Fail closed.