Skip to content

Commit 3b0895f

Browse files
committed
RosaNetwork: new CRD & reconciler to provision net infra for ROSA-HCP
1 parent 8d4c7f2 commit 3b0895f

15 files changed

+1058
-1
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: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.17.3
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+
identityRef:
65+
description: |-
66+
IdentityRef is a reference to an identity to be used when reconciling rosa network.
67+
If no identity is specified, the default identity for this controller will be used.
68+
properties:
69+
kind:
70+
description: Kind of the identity.
71+
enum:
72+
- AWSClusterControllerIdentity
73+
- AWSClusterRoleIdentity
74+
- AWSClusterStaticIdentity
75+
type: string
76+
name:
77+
description: Name of the identity.
78+
minLength: 1
79+
type: string
80+
required:
81+
- kind
82+
- name
83+
type: object
84+
name:
85+
description: The name of the cloudformation stack under which the
86+
network infrastructure would be created
87+
type: string
88+
region:
89+
description: The AWS region in which the components of ROSA network
90+
infrastruture are to be crated
91+
type: string
92+
required:
93+
- cidrBlock
94+
- name
95+
- region
96+
type: object
97+
status:
98+
description: RosaNetworkStatus defines the observed state of RosaNetwork
99+
properties:
100+
conditions:
101+
description: Conditions specifies the conditions for RosaNetwork
102+
items:
103+
description: Condition defines an observation of a Cluster API resource
104+
operational state.
105+
properties:
106+
lastTransitionTime:
107+
description: |-
108+
lastTransitionTime is the last time the condition transitioned from one status to another.
109+
This should be when the underlying condition changed. If that is not known, then using the time when
110+
the API field changed is acceptable.
111+
format: date-time
112+
type: string
113+
message:
114+
description: |-
115+
message is a human readable message indicating details about the transition.
116+
This field may be empty.
117+
maxLength: 10240
118+
minLength: 1
119+
type: string
120+
reason:
121+
description: |-
122+
reason is the reason for the condition's last transition in CamelCase.
123+
The specific API may choose whether or not this field is considered a guaranteed API.
124+
This field may be empty.
125+
maxLength: 256
126+
minLength: 1
127+
type: string
128+
severity:
129+
description: |-
130+
severity provides an explicit classification of Reason code, so the users or machines can immediately
131+
understand the current situation and act accordingly.
132+
The Severity field MUST be set only when Status=False.
133+
maxLength: 32
134+
type: string
135+
status:
136+
description: status of the condition, one of True, False, Unknown.
137+
type: string
138+
type:
139+
description: |-
140+
type of condition in CamelCase or in foo.example.com/CamelCase.
141+
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
142+
can be useful (see .node.status.conditions), the ability to deconflict is important.
143+
maxLength: 256
144+
minLength: 1
145+
type: string
146+
required:
147+
- lastTransitionTime
148+
- status
149+
- type
150+
type: object
151+
type: array
152+
resources:
153+
description: Resources created in the cloudformation stack
154+
items:
155+
description: CFResource groups information pertaining to a resource
156+
created as a part of a cloudformation stack
157+
properties:
158+
logicalId:
159+
description: LogicalResourceID of the created resource.
160+
type: string
161+
physicalId:
162+
description: PhysicalResourceID of the created resource.
163+
type: string
164+
reason:
165+
description: Message pertaining to the status of the resource
166+
type: string
167+
resource:
168+
description: 'Type of the created resource: AWS::EC2::VPC, AWS::EC2::Subnet,
169+
...'
170+
type: string
171+
status:
172+
description: 'Status of the resource: CREATE_IN_PROGRESS, CREATE_COMPLETE,
173+
...'
174+
type: string
175+
required:
176+
- logicalId
177+
- physicalId
178+
- reason
179+
- resource
180+
- status
181+
type: object
182+
type: array
183+
subnets:
184+
description: Array of created private, public subnets and availability
185+
zones, grouped by availability zones
186+
items:
187+
description: RosaNetworkSubnet groups public and private subnet
188+
and the availability zone in which the two subnets got created
189+
properties:
190+
availabilityZone:
191+
description: Availability zone of the subnet pair, for example
192+
us-west-2a
193+
type: string
194+
privateSubnet:
195+
description: ID of the private subnet, for example subnet-07a20d6c41af2b725
196+
type: string
197+
publicSubnet:
198+
description: ID of the public subnet, for example subnet-0f7e49a3ce68ff338
199+
type: string
200+
required:
201+
- availabilityZone
202+
- privateSubnet
203+
- publicSubnet
204+
type: object
205+
type: array
206+
type: object
207+
type: object
208+
served: true
209+
storage: true
210+
subresources:
211+
status: {}

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/v1
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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
service:
12+
namespace: system
13+
name: webhook-service
14+
path: /convert

config/rbac/role.yaml

Lines changed: 3 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
@@ -209,5 +211,6 @@ rules:
209211
- infrastructure.cluster.x-k8s.io
210212
resources:
211213
- rosamachinepools/finalizers
214+
- rosanetworks/finalizers
212215
verbs:
213216
- update

exp/api/v1beta2/conditions_consts.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,23 @@ const (
129129
// RosaMachinePoolReconciliationFailedReason used to report failures while reconciling ROSAMachinePool.
130130
RosaMachinePoolReconciliationFailedReason = "ReconciliationFailed"
131131
)
132+
133+
const (
134+
// RosaNetworkReadyCondition condition reports on the successful reconciliation of RosaNetwork.
135+
RosaNetworkReadyCondition clusterv1.ConditionType = "RosaNetworkReady"
136+
137+
// RosaNetworkCreatingReason used when RosaNetwork is being created.
138+
RosaNetworkCreatingReason = "Creating"
139+
140+
// RosaNetworkCreatedReason used when RosaNetwork is created.
141+
RosaNetworkCreatedReason = "Created"
142+
143+
// RosaNetworkFailedReason used when rosaNetwork creation failed.
144+
RosaNetworkFailedReason = "Failed"
145+
146+
// RosaNetworkDeletingReason used when RosaNetwork is being deleted.
147+
RosaNetworkDeletingReason = "Deleting"
148+
149+
// RosaNetworkDeletionFailedReason used to report failures while deleting RosaNetwork.
150+
RosaNetworkDeletionFailedReason = "DeletionFailed"
151+
)

0 commit comments

Comments
 (0)