--- reviewers: - thockin - dwinship min-kubernetes-server-version: v1.29 title: Extend Service IP Ranges content_type: task --- {{< feature-state state="alpha" for_k8s_version="v1.29" >}} This document shares how to extend the existing Service IP range assigned to a cluster. ## {{% heading "prerequisites" %}} {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}} ## API Kubernetes clusters with kube-apiservers that have enabled the `MultiCIDRServiceAllocator` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) and the `networking.k8s.io/v1alpha1` API, will create a new ServiceCIDR object that takes the well-known name `kubernetes`, and that uses an IP address range based on the value of the `--service-cluster-ip-range` command line argument to kube-apiserver. ```sh kubectl get servicecidr ``` ``` NAME CIDRS AGE kubernetes 10.96.0.0/28 17d ``` The well-known `kubernetes` Service, that exposes the kube-apiserver endpoint to the Pods, calculates the first IP address from the default ServiceCIDR range and uses that IP address as its cluster IP address. ```sh kubectl get service kubernetes ``` ``` NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 443/TCP 17d ``` The default Service, in this case, uses the ClusterIP 10.96.0.1, that has the corresponding IPAddress object. ```sh kubectl get ipaddress 10.96.0.1 ``` ``` NAME PARENTREF 10.96.0.1 services/default/kubernetes ``` The ServiceCIDRs are protected with {{}}, to avoid leaving Service ClusterIPs orphans; the finalizer is only removed if there is another subnet that contains the existing IPAddresses or there are no IPAddresses belonging to the subnet. ## Extend the number of available IPs for Services There are cases that users will need to increase the number addresses available to Services, previously, increasing the Service range was a disruptive operation that could also cause data loss. With this new feature users only need to add a new ServiceCIDR to increase the number of available addresses. ### Adding a new ServiceCIDR On a cluster with a 10.96.0.0/28 range for Services, there is only 2^(32-28) - 2 = 14 IP addresses available. The `kubernetes.default` Service is always created; for this example, that leaves you with only 13 possible Services. ```sh for i in $(seq 1 13); do kubectl create service clusterip "test-$i" --tcp 80 -o json | jq -r .spec.clusterIP; done ``` ``` 10.96.0.11 10.96.0.5 10.96.0.12 10.96.0.13 10.96.0.14 10.96.0.2 10.96.0.3 10.96.0.4 10.96.0.6 10.96.0.7 10.96.0.8 10.96.0.9 error: failed to create ClusterIP service: Internal error occurred: failed to allocate a serviceIP: range is full ``` You can increase the number of IP addresses available for Services, by creating a new ServiceCIDR that extends or adds new IP address ranges. ```sh cat