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