Skip to content

Commit 9778eaf

Browse files
authored
ServiceIPStaticSubrange alpha feature in 1.24 (#32345)
1 parent 085ef8e commit 9778eaf

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

content/en/docs/concepts/services-networking/service.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,8 @@ someone else's choice. That is an isolation failure.
12461246

12471247
In order to allow you to choose a port number for your Services, we must
12481248
ensure that no two Services can collide. Kubernetes does that by allocating each
1249-
Service its own IP address.
1249+
Service its own IP address from within the `service-cluster-ip-range`
1250+
CIDR range that is configured for the API server.
12501251

12511252
To ensure each Service receives a unique IP, an internal allocator atomically
12521253
updates a global allocation map in {{< glossary_tooltip term_id="etcd" >}}
@@ -1260,6 +1261,25 @@ in-memory locking). Kubernetes also uses controllers to check for invalid
12601261
assignments (eg due to administrator intervention) and for cleaning up allocated
12611262
IP addresses that are no longer used by any Services.
12621263

1264+
#### IP address ranges for `type: ClusterIP` Services {#service-ip-static-sub-range}
1265+
1266+
{{< feature-state for_k8s_version="v1.24" state="alpha" >}}
1267+
However, there is a problem with this `ClusterIP` allocation strategy, because a user
1268+
can also [choose their own address for the service](#choosing-your-own-ip-address).
1269+
This could result in a conflict if the internal allocator selects the same IP address
1270+
for another Service.
1271+
1272+
If you enable the `ServiceIPStaticSubrange`
1273+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/),
1274+
the allocation strategy divides the `ClusterIP` range into two bands, based on
1275+
the size of the configured `service-cluster-ip-range` by using the following formula
1276+
`min(max(16, cidrSize / 16), 256)`, described as _never less than 16 or more than 256,
1277+
with a graduated step function between them_. Dynamic IP allocations will be preferentially
1278+
chosen from the upper band, reducing risks of conflicts with the IPs
1279+
assigned from the lower band.
1280+
This allows users to use the lower band of the `service-cluster-ip-range` for their
1281+
Services with static IPs assigned with a very low risk of running into conflicts.
1282+
12631283
### Service IP addresses {#ips-and-vips}
12641284

12651285
Unlike Pod IP addresses, which actually route to a fixed destination,

content/en/docs/reference/command-line-tools-reference/feature-gates.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ different Kubernetes components.
174174
| `SeccompDefault` | `false` | Alpha | 1.22 | |
175175
| `ServiceInternalTrafficPolicy` | `false` | Alpha | 1.21 | 1.21 |
176176
| `ServiceInternalTrafficPolicy` | `true` | Beta | 1.22 | |
177+
| `ServiceIPStaticSubrange` | `false` | Alpha | 1.24 | |
177178
| `SizeMemoryBackedVolumes` | `false` | Alpha | 1.20 | 1.21 |
178179
| `SizeMemoryBackedVolumes` | `true` | Beta | 1.22 | |
179180
| `StatefulSetAutoDeletePVC` | `false` | Alpha | 1.22 | |
@@ -1101,6 +1102,12 @@ Each feature gate is designed for enabling/disabling a specific feature:
11011102
topology of the cluster. See
11021103
[ServiceTopology](/docs/concepts/services-networking/service-topology/)
11031104
for more details.
1105+
- `ServiceIPStaticSubrange`: Enables a strategy for Services ClusterIP allocations, whereby the
1106+
ClusterIP range is subdivided. Dynamic allocated ClusterIP addresses will be allocated preferently
1107+
from the upper range allowing users to assign static ClusterIPs from the lower range with a low
1108+
risk of collision. See
1109+
[Avoiding collisions](/docs/concepts/services-networking/service/#avoiding-collisions)
1110+
for more details.
11041111
- `SetHostnameAsFQDN`: Enable the ability of setting Fully Qualified Domain
11051112
Name(FQDN) as the hostname of a pod. See
11061113
[Pod's `setHostnameAsFQDN` field](/docs/concepts/services-networking/dns-pod-service/#pod-sethostnameasfqdn-field).

0 commit comments

Comments
 (0)