Skip to content

Commit 4df1db9

Browse files
aojeatengqm
andauthored
Multiple Service CIDRs - KEP 1880 (#49746)
* ServiceCIDR - Kep 1880 GA * Update content/en/docs/reference/command-line-tools-reference/feature-gates/DisableAllocatorDualWrite.md Co-authored-by: Qiming Teng <[email protected]> * Update content/en/docs/reference/command-line-tools-reference/feature-gates/MultiCIDRServiceAllocator.md Co-authored-by: Qiming Teng <[email protected]> * Update content/en/docs/reference/networking/virtual-ips.md * Update content/en/docs/reference/networking/virtual-ips.md --------- Co-authored-by: Qiming Teng <[email protected]>
1 parent 726d06f commit 4df1db9

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ stages:
99
- stage: alpha
1010
defaultValue: false
1111
fromVersion: "1.31"
12+
toVersion: "1.32"
13+
- stage: beta
14+
defaultValue: false
15+
fromVersion: "1.33"
1216
---
1317
You can enable the `MultiCIDRServiceAllocator` feature gate. The API server supports migration
1418
from the old bitmap ClusterIP allocators to the new IPAddress allocators.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,9 @@ stages:
1313
- stage: beta
1414
defaultValue: false
1515
fromVersion: "1.31"
16+
toVersion: "1.32"
17+
- stage: stable
18+
defaultValue: true
19+
fromVersion: "1.33"
1620
---
1721
Track IP address allocations for Service cluster IPs using IPAddress objects.

content/en/docs/reference/networking/virtual-ips.md

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,7 @@ IP addresses that are no longer used by any Services.
438438

439439
{{< feature-state feature_gate_name="MultiCIDRServiceAllocator" >}}
440440

441-
If you enable the `MultiCIDRServiceAllocator`
442-
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/) and the
443-
[`networking.k8s.io/v1alpha1` API group](/docs/tasks/administer-cluster/enable-disable-api/),
444-
the control plane replaces the existing etcd allocator with a revised implementation
441+
The control plane replaces the existing etcd allocator with a revised implementation
445442
that uses IPAddress and ServiceCIDR objects instead of an internal global allocation map.
446443
Each cluster IP address associated to a Service then references an IPAddress object.
447444

@@ -495,7 +492,7 @@ Users can create or delete new ServiceCIDR objects to manage the available IP ra
495492

496493
```shell
497494
cat <<'EOF' | kubectl apply -f -
498-
apiVersion: networking.k8s.io/v1beta1
495+
apiVersion: networking.k8s.io/v1
499496
kind: ServiceCIDR
500497
metadata:
501498
name: newservicecidr
@@ -517,6 +514,46 @@ kubernetes 10.96.0.0/28 17m
517514
newservicecidr 10.96.0.0/24 7m
518515
```
519516

517+
Distributions or administrators of Kubernetes clusters may want to control that
518+
new Service CIDRs added to the cluster does not overlap with other networks on
519+
the cluster, that only belong to a specific range of IPs or just simple retain
520+
the existing behavior of only having one ServiceCIDR per cluster. An example of
521+
a Validation Admission Policy to achieve this is:
522+
523+
```yaml
524+
---
525+
apiVersion: admissionregistration.k8s.io/v1
526+
kind: ValidatingAdmissionPolicy
527+
metadata:
528+
name: "servicecidrs-default"
529+
spec:
530+
failurePolicy: Fail
531+
matchConstraints:
532+
resourceRules:
533+
- apiGroups: ["networking.k8s.io"]
534+
apiVersions: ["v1","v1beta1"]
535+
operations: ["CREATE", "UPDATE"]
536+
resources: ["servicecidrs"]
537+
matchConditions:
538+
- name: 'exclude-default-servicecidr'
539+
expression: "object.metadata.name != 'kubernetes'"
540+
variables:
541+
- name: allowed
542+
expression: "['10.96.0.0/16','2001:db8::/64']"
543+
validations:
544+
- expression: "object.spec.cidrs.all(i , variables.allowed.exists(j , cidr(j).containsCIDR(i)))"
545+
---
546+
apiVersion: admissionregistration.k8s.io/v1
547+
kind: ValidatingAdmissionPolicyBinding
548+
metadata:
549+
name: "servicecidrs-binding"
550+
spec:
551+
policyName: "servicecidrs-default"
552+
validationActions: [Deny,Audit]
553+
---
554+
```
555+
556+
520557
### IP address ranges for Service virtual IP addresses {#service-ip-static-sub-range}
521558

522559
{{< feature-state for_k8s_version="v1.26" state="stable" >}}

0 commit comments

Comments
 (0)