Skip to content

Commit a71da52

Browse files
committed
RosaNetwork
1 parent e9f2823 commit a71da52

11 files changed

+732
-0
lines changed

PROJECT

+3
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
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+
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+
region:
85+
description: The AWS region in which the components of ROSA network
86+
infrastruture are to be crated
87+
type: string
88+
required:
89+
- cidrBlock
90+
- region
91+
type: object
92+
status:
93+
description: RosaNetworkStatus defines the observed state of RosaNetwork
94+
properties:
95+
conditions:
96+
description: Conditions specifies the conditions for RosaNetwork
97+
items:
98+
description: Condition defines an observation of a Cluster API resource
99+
operational state.
100+
properties:
101+
lastTransitionTime:
102+
description: |-
103+
Last time the condition transitioned from one status to another.
104+
This should be when the underlying condition changed. If that is not known, then using the time when
105+
the API field changed is acceptable.
106+
format: date-time
107+
type: string
108+
message:
109+
description: |-
110+
A human readable message indicating details about the transition.
111+
This field may be empty.
112+
type: string
113+
reason:
114+
description: |-
115+
The reason for the condition's last transition in CamelCase.
116+
The specific API may choose whether or not this field is considered a guaranteed API.
117+
This field may be empty.
118+
type: string
119+
severity:
120+
description: |-
121+
severity provides an explicit classification of Reason code, so the users or machines can immediately
122+
understand the current situation and act accordingly.
123+
The Severity field MUST be set only when Status=False.
124+
type: string
125+
status:
126+
description: status of the condition, one of True, False, Unknown.
127+
type: string
128+
type:
129+
description: |-
130+
type of condition in CamelCase or in foo.example.com/CamelCase.
131+
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
132+
can be useful (see .node.status.conditions), the ability to deconflict is important.
133+
type: string
134+
required:
135+
- lastTransitionTime
136+
- status
137+
- type
138+
type: object
139+
type: array
140+
resources:
141+
description: Resources created in the cloudformation stack
142+
items:
143+
description: CFResource groups information pertaining to a resource
144+
created as a part of a cloudformation stack
145+
properties:
146+
ID:
147+
description: Identified of the created resource. Will be filled
148+
in once the resource is created & ready
149+
type: string
150+
reason:
151+
description: Message pertaining to the status of the resource
152+
type: string
153+
resource:
154+
description: 'Name of the created resource: NATGateway1, VPC,
155+
SecurityGroup, ...'
156+
type: string
157+
status:
158+
description: 'Status of the resource: CREATE_IN_PROGRESS, CREATE_COMPLETE,
159+
...'
160+
type: string
161+
required:
162+
- ID
163+
- reason
164+
- resource
165+
- status
166+
type: object
167+
type: array
168+
subnets:
169+
description: Array of created private, public subnets and availability
170+
zones, grouped by availability zones
171+
items:
172+
description: RosaNetworkSubnet groups public and private subnet
173+
and the availability zone in which the two subnets got created
174+
properties:
175+
availabilityZone:
176+
description: Availability zone of the subnet pair
177+
type: string
178+
privateSubnet:
179+
description: ID of the private subnet
180+
type: string
181+
publicSubnet:
182+
description: ID of the public subnet
183+
type: string
184+
required:
185+
- availabilityZone
186+
- privateSubnet
187+
- publicSubnet
188+
type: object
189+
type: array
190+
required:
191+
- resources
192+
- subnets
193+
type: object
194+
type: object
195+
served: true
196+
storage: true

config/crd/kustomization.yaml

+3
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.
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
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

+2
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

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

0 commit comments

Comments
 (0)