Skip to content

Commit 9c7ceb1

Browse files
authored
Merge pull request #50501 from rayandas/add-example
Add service-cluster-cidr-address-range.yaml as an example to simplify 1.33 release note
2 parents 2000786 + 709be11 commit 9c7ceb1

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
apiVersion: admissionregistration.k8s.io/v1
2+
kind: ValidatingAdmissionPolicy
3+
metadata:
4+
name: "servicecidrs.default"
5+
annotations:
6+
kubernetes.io/description: >-2
7+
A ValidatingAdmissionPolicy that restricts the IP address ranges that can be
8+
used for ClusterIP type Services. Deploying this admission policy and its
9+
associated ValidatingAdmissionPolicyBinding prevents creating (or updating)
10+
a ServiceCIDR outside the permitted ranges.
11+
spec:
12+
failurePolicy: Fail
13+
matchConstraints:
14+
resourceRules:
15+
- apiGroups: ["networking.k8s.io"]
16+
apiVersions: ["v1","v1beta1"]
17+
operations: ["CREATE", "UPDATE"]
18+
resources: ["servicecidrs"]
19+
matchConditions:
20+
- name: 'exclude-default-servicecidr'
21+
expression: "object.metadata.name != 'kubernetes'"
22+
variables:
23+
- name: allowed
24+
expression: "['10.96.0.0/16','2001:db8::/64']"
25+
validations:
26+
- expression: "object.spec.cidrs.all(currentCIDR, variables.allowed.exists(allowedCIDR, cidr(allowedCIDR).containsCIDR(currentCIDR)))"
27+
---
28+
apiVersion: admissionregistration.k8s.io/v1
29+
kind: ValidatingAdmissionPolicyBinding
30+
metadata:
31+
name: "servicecidrs-binding"
32+
annotations:
33+
kubernetes.io/description: >-2
34+
A ValidatingAdmissionPolicyBinding to restricts the IP address ranges that
35+
can be used for ClusterIP type Services. Deploying this binding and its
36+
associated ValidatingAdmissionPolicy prevents creating (or updating)
37+
a ServiceCIDR that falls outside the permitted ranges.
38+
spec:
39+
policyName: "servicecidrs.default"
40+
validationActions: [Deny,Audit]
41+

0 commit comments

Comments
 (0)