Hi Alan, sorry for the late reply.
There's no prebuilt feature to support this, but it looks like K8s has some features and you can always roll your own. I can think of a couple of ways you might approach it.
- I'd look at Kubernetes network policies first. This looks like what you want, and it has the advantage of not being gVisor-specific. But I don't know exactly how your CNI plugin works, so it's possible there's some compatibility issue. Worth trying.
- You can install iptables filtering rules (or BPF if you feel ambitious) on the veth used by the pod (the end in the host network namespace, not the pod's). A DaemonSet might be able to set these rules up for newly spun-up pods.
- Istio also probably supports this, although likely the rules are set inside the pod.
Note that, from a security perspective, the IP address allowlist should be enforced outside the pod; we assume that code inside the pod can be malicious, so enforcing security inside the pod doesn't get us much. It would not be ideal to set iptables rules inside the gVisor pod, as malicious code or a determined enough attacker might be able to change those rules.