Skip to content

Commit 05f10fd

Browse files
authored
Merge pull request #6313 from schrej/feature/ipam
✨ Add IPAddress and IPAddressClaim CRs to Experimental API
2 parents 29495a2 + 7527a62 commit 05f10fd

25 files changed

+1435
-2
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ generate-manifests-core: $(CONTROLLER_GEN) $(KUSTOMIZE) ## Generate manifests e.
222222
paths=./$(EXP_DIR)/internal/controllers/... \
223223
paths=./$(EXP_DIR)/addons/api/... \
224224
paths=./$(EXP_DIR)/addons/internal/controllers/... \
225+
paths=./$(EXP_DIR)/ipam/api/... \
226+
paths=./$(EXP_DIR)/ipam/internal/webhooks/... \
225227
paths=./$(EXP_DIR)/runtime/api/... \
226228
paths=./$(EXP_DIR)/runtime/internal/controllers/... \
227229
crd:crdVersions=v1 \
@@ -288,6 +290,7 @@ generate-go-deepcopy-core: $(CONTROLLER_GEN) ## Generate deepcopy go code for co
288290
paths=./api/... \
289291
paths=./$(EXP_DIR)/api/... \
290292
paths=./$(EXP_DIR)/addons/api/... \
293+
paths=./$(EXP_DIR)/ipam/api/... \
291294
paths=./$(EXP_DIR)/runtime/api/... \
292295
paths=./$(EXP_DIR)/runtime/hooks/api/... \
293296
paths=./internal/runtime/test/... \
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.9.1
7+
creationTimestamp: null
8+
name: ipaddressclaims.ipam.cluster.x-k8s.io
9+
spec:
10+
group: ipam.cluster.x-k8s.io
11+
names:
12+
categories:
13+
- cluster-api
14+
kind: IPAddressClaim
15+
listKind: IPAddressClaimList
16+
plural: ipaddressclaims
17+
singular: ipaddressclaim
18+
scope: Namespaced
19+
versions:
20+
- additionalPrinterColumns:
21+
- description: Name of the pool to allocate an address from
22+
jsonPath: .spec.poolRef.name
23+
name: Pool Name
24+
type: string
25+
- description: Kind of the pool to allocate an address from
26+
jsonPath: .spec.poolRef.kind
27+
name: Pool Kind
28+
type: string
29+
name: v1alpha1
30+
schema:
31+
openAPIV3Schema:
32+
description: IPAddressClaim is the Schema for the ipaddressclaim API.
33+
properties:
34+
apiVersion:
35+
description: 'APIVersion defines the versioned schema of this representation
36+
of an object. Servers should convert recognized schemas to the latest
37+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
38+
type: string
39+
kind:
40+
description: 'Kind is a string value representing the REST resource this
41+
object represents. Servers may infer this from the endpoint the client
42+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
43+
type: string
44+
metadata:
45+
type: object
46+
spec:
47+
description: IPAddressClaimSpec is the desired state of an IPAddressClaim.
48+
properties:
49+
poolRef:
50+
description: PoolRef is a reference to the pool from which an IP address
51+
should be created.
52+
properties:
53+
apiGroup:
54+
description: APIGroup is the group for the resource being referenced.
55+
If APIGroup is not specified, the specified Kind must be in
56+
the core API group. For any other third-party types, APIGroup
57+
is required.
58+
type: string
59+
kind:
60+
description: Kind is the type of resource being referenced
61+
type: string
62+
name:
63+
description: Name is the name of resource being referenced
64+
type: string
65+
required:
66+
- apiGroup
67+
- kind
68+
- name
69+
type: object
70+
required:
71+
- poolRef
72+
type: object
73+
status:
74+
description: IPAddressClaimStatus is the observed status of a IPAddressClaim.
75+
properties:
76+
addressRef:
77+
description: AddressRef is a reference to the address that was created
78+
for this claim.
79+
properties:
80+
name:
81+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
82+
TODO: Add other useful fields. apiVersion, kind, uid?'
83+
type: string
84+
type: object
85+
conditions:
86+
description: Conditions summarises the current state of the IPAddressClaim
87+
items:
88+
description: Condition defines an observation of a Cluster API resource
89+
operational state.
90+
properties:
91+
lastTransitionTime:
92+
description: Last time the condition transitioned from one status
93+
to another. This should be when the underlying condition changed.
94+
If that is not known, then using the time when the API field
95+
changed is acceptable.
96+
format: date-time
97+
type: string
98+
message:
99+
description: A human readable message indicating details about
100+
the transition. This field may be empty.
101+
type: string
102+
reason:
103+
description: The reason for the condition's last transition
104+
in CamelCase. The specific API may choose whether or not this
105+
field is considered a guaranteed API. This field may not be
106+
empty.
107+
type: string
108+
severity:
109+
description: Severity provides an explicit classification of
110+
Reason code, so the users or machines can immediately understand
111+
the current situation and act accordingly. The Severity field
112+
MUST be set only when Status=False.
113+
type: string
114+
status:
115+
description: Status of the condition, one of True, False, Unknown.
116+
type: string
117+
type:
118+
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
119+
Many .condition.type values are consistent across resources
120+
like Available, but because arbitrary conditions can be useful
121+
(see .node.status.conditions), the ability to deconflict is
122+
important.
123+
type: string
124+
required:
125+
- lastTransitionTime
126+
- status
127+
- type
128+
type: object
129+
type: array
130+
required:
131+
- addressRef
132+
type: object
133+
type: object
134+
served: true
135+
storage: true
136+
subresources:
137+
status: {}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.9.1
7+
creationTimestamp: null
8+
name: ipaddresses.ipam.cluster.x-k8s.io
9+
spec:
10+
group: ipam.cluster.x-k8s.io
11+
names:
12+
categories:
13+
- cluster-api
14+
kind: IPAddress
15+
listKind: IPAddressList
16+
plural: ipaddresses
17+
singular: ipaddress
18+
scope: Namespaced
19+
versions:
20+
- additionalPrinterColumns:
21+
- description: Address
22+
jsonPath: .spec.address
23+
name: Address
24+
type: string
25+
- description: Name of the pool the address is from
26+
jsonPath: .spec.poolRef.name
27+
name: Pool Name
28+
type: string
29+
- description: Kind of the pool the address is from
30+
jsonPath: .spec.poolRef.kind
31+
name: Pool Kind
32+
type: string
33+
name: v1alpha1
34+
schema:
35+
openAPIV3Schema:
36+
description: IPAddress is the Schema for the ipaddress API.
37+
properties:
38+
apiVersion:
39+
description: 'APIVersion defines the versioned schema of this representation
40+
of an object. Servers should convert recognized schemas to the latest
41+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
42+
type: string
43+
kind:
44+
description: 'Kind is a string value representing the REST resource this
45+
object represents. Servers may infer this from the endpoint the client
46+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
47+
type: string
48+
metadata:
49+
type: object
50+
spec:
51+
description: IPAddressSpec is the desired state of an IPAddress.
52+
properties:
53+
address:
54+
description: Address is the IP address.
55+
type: string
56+
claimRef:
57+
description: ClaimRef is a reference to the claim this IPAddress was
58+
created for.
59+
properties:
60+
name:
61+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
62+
TODO: Add other useful fields. apiVersion, kind, uid?'
63+
type: string
64+
type: object
65+
gateway:
66+
description: Gateway is the network gateway of the network the address
67+
is from.
68+
type: string
69+
poolRef:
70+
description: PoolRef is a reference to the pool that this IPAddress
71+
was created from.
72+
properties:
73+
apiGroup:
74+
description: APIGroup is the group for the resource being referenced.
75+
If APIGroup is not specified, the specified Kind must be in
76+
the core API group. For any other third-party types, APIGroup
77+
is required.
78+
type: string
79+
kind:
80+
description: Kind is the type of resource being referenced
81+
type: string
82+
name:
83+
description: Name is the name of resource being referenced
84+
type: string
85+
required:
86+
- apiGroup
87+
- kind
88+
- name
89+
type: object
90+
prefix:
91+
description: Prefix is the prefix of the address.
92+
type: integer
93+
required:
94+
- address
95+
- claimRef
96+
- gateway
97+
- poolRef
98+
- prefix
99+
type: object
100+
type: object
101+
served: true
102+
storage: true
103+
subresources: {}

config/crd/kustomization.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ resources:
1212
- bases/addons.cluster.x-k8s.io_clusterresourcesetbindings.yaml
1313
- bases/cluster.x-k8s.io_machinehealthchecks.yaml
1414
- bases/runtime.cluster.x-k8s.io_extensionconfigs.yaml
15+
- bases/ipam.cluster.x-k8s.io_ipaddresses.yaml
16+
- bases/ipam.cluster.x-k8s.io_ipaddressclaims.yaml
1517
# +kubebuilder:scaffold:crdkustomizeresource
1618

1719
patchesStrategicMerge:

config/rbac/role.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,14 @@ rules:
290290
- list
291291
- patch
292292
- watch
293+
- apiGroups:
294+
- ipam.cluster.x-k8s.io
295+
resources:
296+
- ipaddressclaims
297+
verbs:
298+
- get
299+
- list
300+
- watch
293301
- apiGroups:
294302
- runtime.cluster.x-k8s.io
295303
resources:

config/webhook/manifests.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,3 +410,49 @@ webhooks:
410410
resources:
411411
- clusterresourcesets
412412
sideEffects: None
413+
- admissionReviewVersions:
414+
- v1
415+
- v1beta1
416+
clientConfig:
417+
service:
418+
name: webhook-service
419+
namespace: system
420+
path: /validate-ipam-cluster-x-k8s-io-v1alpha1-ipaddress
421+
failurePolicy: Fail
422+
matchPolicy: Equivalent
423+
name: validation.ipaddress.ipam.cluster.x-k8s.io
424+
rules:
425+
- apiGroups:
426+
- ipam.cluster.x-k8s.io
427+
apiVersions:
428+
- v1alpha1
429+
operations:
430+
- CREATE
431+
- UPDATE
432+
- DELETE
433+
resources:
434+
- ipaddresses
435+
sideEffects: None
436+
- admissionReviewVersions:
437+
- v1
438+
- v1beta1
439+
clientConfig:
440+
service:
441+
name: webhook-service
442+
namespace: system
443+
path: /validate-ipam-cluster-x-k8s-io-v1alpha1-ipaddressclaim
444+
failurePolicy: Fail
445+
matchPolicy: Equivalent
446+
name: validation.ipaddressclaim.ipam.cluster.x-k8s.io
447+
rules:
448+
- apiGroups:
449+
- ipam.cluster.x-k8s.io
450+
apiVersions:
451+
- v1alpha1
452+
operations:
453+
- CREATE
454+
- UPDATE
455+
- DELETE
456+
resources:
457+
- ipaddressclaims
458+
sideEffects: None

exp/api/v1beta1/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
// Package v1beta1 contains experimental v1beta1 API implementation.
1718
package v1beta1

exp/ipam/api/v1alpha1/doc.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
Copyright 2022 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package v1alpha1 contains API Schema definitions for the exp v1alpha1 IPAM API.
18+
package v1alpha1
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2022 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// +kubebuilder:object:generate=true
18+
// +groupName=ipam.cluster.x-k8s.io
19+
20+
package v1alpha1
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects.
29+
GroupVersion = schema.GroupVersion{Group: "ipam.cluster.x-k8s.io", Version: "v1alpha1"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)

0 commit comments

Comments
 (0)