Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes: reserving subrange of service-cluster-ip-range for manual allocation

Tags:

kubernetes

When creating a service, I can either specify static IP address from cluster IP range or don't specify any IP address in which case such address will be dynamically assigned.

But when specifying static IP address, how can I make sure that it will not conflict with existing dynamically assigned IP address? I could for example programmatically query if such IP address is already in use. Or, what I would more prefer is to specify IP range that is cluster-wise reserved for manual allocation. For example

  • Service cluster IP range: 10.20.0.0/16
  • Service cluster IP manual range: 10.20.5.0/24

Now, I can manage IP address in range from 10.20.5.0-10.22.5.255 myself and kubernetes can use remaining pool for dynamic allocation. Sort of how usually DHCP/static IP range works on home routers.

Is this scenario possible in kubernetes?

like image 581
Sasa Avatar asked Nov 07 '22 15:11

Sasa


1 Answers

The service ip you manually select has to be part of the selected range or you'll receive an invalid (422) response from kubernetes. The kubernetes documentation has a choosing your own ip section for services. If you have admin rights to the cluster the easiest option is going to perform kubectl get services --all-namespaces which will show you every service provisioned in your cluster with its corresponding CLUSTER-IP shown.

like image 68
Ralph Avatar answered Nov 15 '22 08:11

Ralph