Skip to content

Commit 948c005

Browse files
committed
add IPAddress and IPAddressClaim to exp api
1 parent 4f79490 commit 948c005

13 files changed

+1155
-71
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.8.0
7+
creationTimestamp: null
8+
name: ipaddressclaims.cluster.x-k8s.io
9+
spec:
10+
group: 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: Pool the address is from
22+
jsonPath: .spec.pool.name
23+
name: Pool Name
24+
type: string
25+
- description: Pool the address is from
26+
jsonPath: .spec.pool.kind
27+
name: Pool Kind
28+
type: string
29+
name: v1beta1
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+
pool:
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+
- kind
67+
- name
68+
type: object
69+
type: object
70+
status:
71+
description: IPAddressClaimStatus is the observed status of a IPAddressClaim.
72+
properties:
73+
address:
74+
description: AddressRef is a reference to the address that was created
75+
for this claim.
76+
properties:
77+
name:
78+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
79+
TODO: Add other useful fields. apiVersion, kind, uid?'
80+
type: string
81+
type: object
82+
conditions:
83+
description: Conditions summarises the current state of the IPAddressClaim
84+
items:
85+
description: Condition defines an observation of a Cluster API resource
86+
operational state.
87+
properties:
88+
lastTransitionTime:
89+
description: Last time the condition transitioned from one status
90+
to another. This should be when the underlying condition changed.
91+
If that is not known, then using the time when the API field
92+
changed is acceptable.
93+
format: date-time
94+
type: string
95+
message:
96+
description: A human readable message indicating details about
97+
the transition. This field may be empty.
98+
type: string
99+
reason:
100+
description: The reason for the condition's last transition
101+
in CamelCase. The specific API may choose whether or not this
102+
field is considered a guaranteed API. This field may not be
103+
empty.
104+
type: string
105+
severity:
106+
description: Severity provides an explicit classification of
107+
Reason code, so the users or machines can immediately understand
108+
the current situation and act accordingly. The Severity field
109+
MUST be set only when Status=False.
110+
type: string
111+
status:
112+
description: Status of the condition, one of True, False, Unknown.
113+
type: string
114+
type:
115+
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
116+
Many .condition.type values are consistent across resources
117+
like Available, but because arbitrary conditions can be useful
118+
(see .node.status.conditions), the ability to deconflict is
119+
important.
120+
type: string
121+
required:
122+
- lastTransitionTime
123+
- status
124+
- type
125+
type: object
126+
type: array
127+
type: object
128+
type: object
129+
served: true
130+
storage: true
131+
subresources:
132+
status: {}
133+
status:
134+
acceptedNames:
135+
kind: ""
136+
plural: ""
137+
conditions: []
138+
storedVersions: []
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.8.0
7+
creationTimestamp: null
8+
name: ipaddresses.cluster.x-k8s.io
9+
spec:
10+
group: 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: Pool the address is from
22+
jsonPath: .spec.pool.name
23+
name: Pool Name
24+
type: string
25+
- description: Pool the address is from
26+
jsonPath: .spec.pool.kind
27+
name: Pool Kind
28+
type: string
29+
- description: Address
30+
jsonPath: .spec.address
31+
name: Address
32+
type: string
33+
name: v1beta1
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+
claim:
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 network the address
67+
is from.
68+
type: string
69+
pool:
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+
- kind
87+
- name
88+
type: object
89+
prefix:
90+
description: Prefix is the prefix of the address.
91+
type: integer
92+
required:
93+
- address
94+
- gateway
95+
- prefix
96+
type: object
97+
type: object
98+
served: true
99+
storage: true
100+
subresources:
101+
status: {}
102+
status:
103+
acceptedNames:
104+
kind: ""
105+
plural: ""
106+
conditions: []
107+
storedVersions: []

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/cluster.x-k8s.io_ipaddresses.yaml
16+
- bases/cluster.x-k8s.io_ipaddressclaims.yaml
1517
# +kubebuilder:scaffold:crdkustomizeresource
1618

1719
patchesStrategicMerge:

exp/api/v1beta1/ipam_types.go

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
Copyright 2021 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 v1beta1
18+
19+
import (
20+
corev1 "k8s.io/api/core/v1"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
23+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
24+
)
25+
26+
const (
27+
// IPPoolLabel is used to add the pool name to an IPAddressClaim and IPAddress.
28+
IPPoolLabel = "ipam.cluster.x-k8s.io/pool"
29+
)
30+
31+
// IPAddressSpec is the desired state of an IPAddress.
32+
type IPAddressSpec struct {
33+
// ClaimRef is a reference to the claim this IPAddress was created for.
34+
ClaimRef corev1.LocalObjectReference `json:"claim,omitempty"`
35+
36+
// PoolRef is a reference to the pool that this IPAddress was created from.
37+
PoolRef corev1.TypedLocalObjectReference `json:"pool,omitempty"`
38+
39+
// Address is the IP address.
40+
Address string `json:"address"`
41+
42+
// Prefix is the prefix of the address.
43+
Prefix int `json:"prefix"`
44+
45+
// Gateway is the network gateway of network the address is from.
46+
Gateway string `json:"gateway"`
47+
}
48+
49+
// +kubebuilder:object:root=true
50+
// +kubebuilder:resource:path=ipaddresses,scope=Namespaced,categories=cluster-api
51+
// +kubebuilder:subresource:status
52+
// +kubebuilder:storageversion
53+
// +kubebuilder:printcolumn:name="Pool Name",type="string",JSONPath=".spec.pool.name",description="Pool the address is from"
54+
// +kubebuilder:printcolumn:name="Pool Kind",type="string",JSONPath=".spec.pool.kind",description="Pool the address is from"
55+
// +kubebuilder:printcolumn:name="Address",type="string",JSONPath=".spec.address",description="Address"
56+
57+
// IPAddress is the Schema for the ipaddress API.
58+
type IPAddress struct {
59+
metav1.TypeMeta `json:",inline"`
60+
metav1.ObjectMeta `json:"metadata,omitempty"`
61+
62+
Spec IPAddressSpec `json:"spec,omitempty"`
63+
}
64+
65+
// +kubebuilder:object:root=true
66+
67+
// IPAddressList is a list of IPAddress.
68+
type IPAddressList struct {
69+
metav1.TypeMeta `json:",inline"`
70+
metav1.ListMeta `json:"metadata,omitempty"`
71+
Items []IPAddress `json:"items"`
72+
}
73+
74+
// IPAddressClaimSpec is the desired state of an IPAddressClaim.
75+
type IPAddressClaimSpec struct {
76+
// PoolRef is a reference to the pool from which an IP address should be created.
77+
PoolRef corev1.TypedLocalObjectReference `json:"pool,omitempty"`
78+
}
79+
80+
// IPAddressClaimStatus is the observed status of a IPAddressClaim.
81+
type IPAddressClaimStatus struct {
82+
// AddressRef is a reference to the address that was created for this claim.
83+
AddressRef corev1.LocalObjectReference `json:"address,omitempty"`
84+
85+
// Conditions summarises the current state of the IPAddressClaim
86+
// +optional
87+
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
88+
}
89+
90+
// +kubebuilder:object:root=true
91+
// +kubebuilder:resource:path=ipaddressclaims,scope=Namespaced,categories=cluster-api
92+
// +kubebuilder:subresource:status
93+
// +kubebuilder:storageversion
94+
// +kubebuilder:printcolumn:name="Pool Name",type="string",JSONPath=".spec.pool.name",description="Pool the address is from"
95+
// +kubebuilder:printcolumn:name="Pool Kind",type="string",JSONPath=".spec.pool.kind",description="Pool the address is from"
96+
97+
// IPAddressClaim is the Schema for the ipaddressclaim API.
98+
type IPAddressClaim struct {
99+
metav1.TypeMeta `json:",inline"`
100+
metav1.ObjectMeta `json:"metadata,omitempty"`
101+
102+
Spec IPAddressClaimSpec `json:"spec,omitempty"`
103+
Status IPAddressClaimStatus `json:"status,omitempty"`
104+
}
105+
106+
// +kubebuilder:object:root=true
107+
108+
// IPAddressClaimList is a list of IPAddressClaim.
109+
type IPAddressClaimList struct {
110+
metav1.TypeMeta `json:",inline"`
111+
metav1.ListMeta `json:"metadata,omitempty"`
112+
Items []IPAddressClaim `json:"items"`
113+
}
114+
115+
func init() {
116+
SchemeBuilder.Register(&IPAddress{}, &IPAddressList{})
117+
SchemeBuilder.Register(&IPAddressClaim{}, &IPAddressClaimList{})
118+
}

0 commit comments

Comments
 (0)