bowei / k8s-custom-iptables

How to add custom iptables rules to a Kubernetes cluster
Apache License 2.0
59 stars 34 forks source link

How does this work? #16

Closed georgejdli closed 2 years ago

georgejdli commented 2 years ago

In this example are we making routing rule changes to the underlying k8s nodes?

bowei commented 2 years ago

Yes, we are modifying the Linux iptables directly.

georgejdli commented 2 years ago

Thanks for the response! I'm new to iptables and had a limited understanding of the network isolation options in Kubernetes so I didn't understand how the rules were being applied by running commands in a k8s container.

For others that were wondering like I was:

If you're looking to apply rules "locally" to a pod you can disable hostNetwork and run a side car container to run the iptables comments:

image

This means the iptables rules will only apply within the pod's network isolation and not affect any other traffic within the cluster.