You can get stuff like this with Network Policies...
This repository contains various use cases of Kubernetes Network Policies and sample YAML files to leverage in your setup. If you ever wondered how to drop/restrict traffic to applications running on Kubernetes, read on.
Easiest way to try out Network Policies is to create a new Google Container Engine cluster. Applying Network Policies on your existing cluster can disrupt the networking. At the time of writing, most cloud providers do not provide built-in network policy support.
If you are not familiar with Network Policies at all, I recommend reading my Securing Kubernetes Cluster Networking article first.
- DENY all non-whitelisted traffic in the current namespace
- DENY all traffic from other namespaces (a.k.a. LIMIT access to the current namespace)
- ALLOW traffic to an application from all namespaces
- ALLOW all traffic from a namespace
- ALLOW traffic from some pods in another namespace
- LIMIT traffic to an application the current namespace
- ALLOW traffic only to certain port numbers of an application
- ALLOW traffic from apps using multiple selectors
Ahmet Alp Balkan (@ahmetb).
Copyright 2017, Google Inc. Licensed under Apache 2.0. Disclaimer: This is not an official Google product.