1

I have one master and one worker and 10 namespaces in k8s. I want to create and assign subnet to each namespace using by pods. for example I want to create and assign 10.0.0.0/24 to namespace 1, create and assign 10.1.0.0/24 to namespace 2 and...

I played with network policies but it did not any results. How can I do this?

0

1 Answer 1

2

Kubernetes itself doesn't offer such a functionality natively to map namespaces to pod CIDR ranges.

Network policies define ingress/egress rules for pods and not CIDR ranges for namespaces.

The closest solutions I could think of:

  1. CNI-specific solution like Calico IPAM.

https://docs.tigera.io/calico/latest/networking/ipam/ https://docs.tigera.io/calico/latest/reference/configure-cni-plugins#using-kubernetes-annotations

  1. Making use of the fact that different nodes will have different pod IP ranges, and scheduling selected pods to run on specific node(s). Not something I'd recommend.

https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/

  1. Making use of the fact that static pods and daemonset pods will have the IP address of the node they are running on. Again, not something I'd recommend.
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .