Skip to content

Commit 3435873

Browse files
committed
RosaNetwork
1 parent c470da2 commit 3435873

File tree

11 files changed

+609
-0
lines changed

11 files changed

+609
-0
lines changed

PROJECT

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@ resources:
5858
- group: infrastructure
5959
version: v1beta2
6060
kind: AWSManagedCluster
61+
- group: infrastructure
62+
kind: RosaNetwork
63+
version: v1beta2
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.16.5
7+
name: rosanetworks.infrastructure.cluster.x-k8s.io
8+
spec:
9+
group: infrastructure.cluster.x-k8s.io
10+
names:
11+
categories:
12+
- cluster-api
13+
kind: RosaNetwork
14+
listKind: RosaNetworkList
15+
plural: rosanetworks
16+
shortNames:
17+
- rosanet
18+
singular: rosanetwork
19+
scope: Namespaced
20+
versions:
21+
- name: v1beta2
22+
schema:
23+
openAPIV3Schema:
24+
description: RosaNetwork is the Schema for the rosanetworks API
25+
properties:
26+
apiVersion:
27+
description: |-
28+
APIVersion defines the versioned schema of this representation of an object.
29+
Servers should convert recognized schemas to the latest internal value, and
30+
may reject unrecognized values.
31+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
32+
type: string
33+
kind:
34+
description: |-
35+
Kind is a string value representing the REST resource this object represents.
36+
Servers may infer this from the endpoint the client submits requests to.
37+
Cannot be updated.
38+
In CamelCase.
39+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
40+
type: string
41+
metadata:
42+
type: object
43+
spec:
44+
description: RosaNetworkSpec defines the desired state of RosaNetwork
45+
properties:
46+
availabilityZoneCount:
47+
default: 1
48+
description: |-
49+
The number of availability zones to be used for creation of the network infrastructure.
50+
You can specify anything between one and four, depending on the chosen AWS region.
51+
type: integer
52+
availabilityZones:
53+
description: |-
54+
The list of availability zones to be used for creation of the network infrastructure.
55+
You can specify anything between one and four valid availability zones from a given region.
56+
Should you specify both the availabilityZoneCount and availabilityZones, the list of availability zones takes preference.
57+
items:
58+
type: string
59+
type: array
60+
cidrBlock:
61+
description: CIDR block to be used for the VPC
62+
format: cidr
63+
type: string
64+
region:
65+
description: The AWS region in which the components of ROSA network
66+
infrastruture are to be crated
67+
type: string
68+
required:
69+
- cidrBlock
70+
- region
71+
type: object
72+
status:
73+
description: RosaNetworkStatus defines the observed state of RosaNetwork
74+
properties:
75+
conditions:
76+
description: Conditions specifies the conditions for RosaNetwork
77+
items:
78+
description: Condition defines an observation of a Cluster API resource
79+
operational state.
80+
properties:
81+
lastTransitionTime:
82+
description: |-
83+
Last time the condition transitioned from one status to another.
84+
This should be when the underlying condition changed. If that is not known, then using the time when
85+
the API field changed is acceptable.
86+
format: date-time
87+
type: string
88+
message:
89+
description: |-
90+
A human readable message indicating details about the transition.
91+
This field may be empty.
92+
type: string
93+
reason:
94+
description: |-
95+
The reason for the condition's last transition in CamelCase.
96+
The specific API may choose whether or not this field is considered a guaranteed API.
97+
This field may be empty.
98+
type: string
99+
severity:
100+
description: |-
101+
severity provides an explicit classification of Reason code, so the users or machines can immediately
102+
understand the current situation and act accordingly.
103+
The Severity field MUST be set only when Status=False.
104+
type: string
105+
status:
106+
description: status of the condition, one of True, False, Unknown.
107+
type: string
108+
type:
109+
description: |-
110+
type of condition in CamelCase or in foo.example.com/CamelCase.
111+
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
112+
can be useful (see .node.status.conditions), the ability to deconflict is important.
113+
type: string
114+
required:
115+
- lastTransitionTime
116+
- status
117+
- type
118+
type: object
119+
type: array
120+
resources:
121+
description: Resources created in the cloudformation stack
122+
items:
123+
description: CFResource groups information pertaining to a resource
124+
created as a part of a cloudformation stack
125+
properties:
126+
ID:
127+
description: Identified of the created resource. Will be filled
128+
in once the resource is created & ready
129+
type: string
130+
reason:
131+
description: Message pertaining to the status of the resource
132+
type: string
133+
resource:
134+
description: 'Name of the created resource: NATGateway1, VPC,
135+
SecurityGroup, ...'
136+
type: string
137+
status:
138+
description: 'Status of the resource: CREATE_IN_PROGRESS, CREATE_COMPLETE,
139+
...'
140+
type: string
141+
required:
142+
- ID
143+
- reason
144+
- resource
145+
- status
146+
type: object
147+
type: array
148+
subnets:
149+
description: Array of created private, public subnets and availability
150+
zones, grouped by availability zones
151+
items:
152+
description: RosaNetworkSubnet groups public and private subnet
153+
and the availability zone in which the two subnets got created
154+
properties:
155+
availabilityZone:
156+
description: Availability zone of the subnet pair
157+
type: string
158+
privateSubnet:
159+
description: ID of the private subnet
160+
type: string
161+
publicSubnet:
162+
description: ID of the public subnet
163+
type: string
164+
required:
165+
- availabilityZone
166+
- privateSubnet
167+
- publicSubnet
168+
type: object
169+
type: array
170+
required:
171+
- resources
172+
- subnets
173+
type: object
174+
type: object
175+
served: true
176+
storage: true

config/crd/kustomization.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ resources:
2424
- bases/controlplane.cluster.x-k8s.io_rosacontrolplanes.yaml
2525
- bases/infrastructure.cluster.x-k8s.io_rosaclusters.yaml
2626
- bases/infrastructure.cluster.x-k8s.io_rosamachinepools.yaml
27+
- bases/infrastructure.cluster.x-k8s.io_rosanetworks.yaml
2728
# +kubebuilder:scaffold:crdkustomizeresource
2829

2930
patchesStrategicMerge:
@@ -38,6 +39,7 @@ patchesStrategicMerge:
3839
- patches/webhook_in_awsmanagedcontrolplanes.yaml
3940
- patches/webhook_in_eksconfigs.yaml
4041
- patches/webhook_in_eksconfigtemplates.yaml
42+
#- patches/webhook_in_rosanetworks.yaml
4143
# +kubebuilder:scaffold:crdkustomizewebhookpatch
4244

4345
# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.
@@ -52,6 +54,7 @@ patchesStrategicMerge:
5254
- patches/cainjection_in_awsmanagedclusters.yaml
5355
- patches/cainjection_in_eksconfigs.yaml
5456
- patches/cainjection_in_eksconfigtemplates.yaml
57+
#- patches/cainjection_in_rosanetworks.yaml
5558
# +kubebuilder:scaffold:crdkustomizecainjectionpatch
5659

5760
# [LABEL] To enable label, uncomment all the sections with [LABEL] prefix.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# The following patch adds a directive for certmanager to inject CA into the CRD
2+
# CRD conversion requires k8s 1.13 or later.
3+
apiVersion: apiextensions.k8s.io/v1beta1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
8+
name: rosanetworks.infrastructure.cluster.x-k8s.io
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# The following patch enables conversion webhook for CRD
2+
# CRD conversion requires k8s 1.13 or later.
3+
apiVersion: apiextensions.k8s.io/v1beta1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
name: rosanetworks.infrastructure.cluster.x-k8s.io
7+
spec:
8+
conversion:
9+
strategy: Webhook
10+
webhookClientConfig:
11+
# this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank,
12+
# but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager)
13+
caBundle: Cg==
14+
service:
15+
namespace: system
16+
name: webhook-service
17+
path: /convert

config/rbac/role.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ rules:
176176
- awsfargateprofiles/status
177177
- rosaclusters/status
178178
- rosamachinepools/status
179+
- rosanetworks/status
179180
verbs:
180181
- get
181182
- patch
@@ -197,6 +198,7 @@ rules:
197198
- infrastructure.cluster.x-k8s.io
198199
resources:
199200
- awsmachines
201+
- rosanetworks
200202
verbs:
201203
- create
202204
- delete

exp/api/v1beta2/rosanetwork_types.go

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
Copyright 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 v1beta2
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
22+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
23+
)
24+
25+
// RosaNetworkSpec defines the desired state of RosaNetwork
26+
type RosaNetworkSpec struct {
27+
// The AWS region in which the components of ROSA network infrastruture are to be crated
28+
// +immutable
29+
Region string `json:"region"`
30+
31+
// The number of availability zones to be used for creation of the network infrastructure.
32+
// You can specify anything between one and four, depending on the chosen AWS region.
33+
// +kubebuilder:default=1
34+
// +optional
35+
// +immutable
36+
AvailabilityZoneCount int `json:"availabilityZoneCount"`
37+
38+
// The list of availability zones to be used for creation of the network infrastructure.
39+
// You can specify anything between one and four valid availability zones from a given region.
40+
// Should you specify both the availabilityZoneCount and availabilityZones, the list of availability zones takes preference.
41+
// +optional
42+
// +immutable
43+
AvailabilityZones []string `json:"availabilityZones"`
44+
45+
// CIDR block to be used for the VPC
46+
// +kubebuilder:validation:Format=cidr
47+
// +immutable
48+
CIDRBlock string `json:"cidrBlock"`
49+
}
50+
51+
// RosaNetworkSubnet groups public and private subnet and the availability zone in which the two subnets got created
52+
type RosaNetworkSubnet struct {
53+
// Availability zone of the subnet pair
54+
AvailabilityZone string `json:"availabilityZone"`
55+
56+
// ID of the public subnet
57+
PublicSubnet string `json:"publicSubnet"`
58+
59+
// ID of the private subnet
60+
PrivateSubnet string `json:"privateSubnet"`
61+
}
62+
63+
// CFResource groups information pertaining to a resource created as a part of a cloudformation stack
64+
type CFResource struct {
65+
// Name of the created resource: NATGateway1, VPC, SecurityGroup, ...
66+
Resource string `json:"resource"`
67+
68+
// Identified of the created resource. Will be filled in once the resource is created & ready
69+
ID string `json:"ID"`
70+
71+
// Status of the resource: CREATE_IN_PROGRESS, CREATE_COMPLETE, ...
72+
Status string `json:"status"`
73+
74+
// Message pertaining to the status of the resource
75+
Reason string `json:"reason"`
76+
}
77+
78+
// RosaNetworkStatus defines the observed state of RosaNetwork
79+
type RosaNetworkStatus struct {
80+
// Array of created private, public subnets and availability zones, grouped by availability zones
81+
Subnets []RosaNetworkSubnet `json:"subnets"`
82+
83+
// Resources created in the cloudformation stack
84+
Resources []CFResource `json:"resources"`
85+
86+
// Conditions specifies the conditions for RosaNetwork
87+
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
88+
}
89+
90+
// +kubebuilder:object:root=true
91+
// +kubebuilder:resource:path=rosanetworks,shortName=rosanet,scope=Namespaced,categories=cluster-api
92+
93+
// RosaNetwork is the Schema for the rosanetworks API
94+
type RosaNetwork struct {
95+
metav1.TypeMeta `json:",inline"`
96+
metav1.ObjectMeta `json:"metadata,omitempty"`
97+
98+
Spec RosaNetworkSpec `json:"spec,omitempty"`
99+
Status RosaNetworkStatus `json:"status,omitempty"`
100+
}
101+
102+
// +kubebuilder:object:root=true
103+
104+
// RosaNetworkList contains a list of RosaNetwork
105+
type RosaNetworkList struct {
106+
metav1.TypeMeta `json:",inline"`
107+
metav1.ListMeta `json:"metadata,omitempty"`
108+
Items []RosaNetwork `json:"items"`
109+
}
110+
111+
func init() {
112+
SchemeBuilder.Register(&RosaNetwork{}, &RosaNetworkList{})
113+
}

0 commit comments

Comments
 (0)