Skip to content

Commit 2f86495

Browse files
committed
Add Scaleway managed Kubernetes
1 parent 1caa5a2 commit 2f86495

File tree

64 files changed

+7911
-318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+7911
-318
lines changed

PROJECT

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,31 @@ resources:
4242
kind: ScalewayMachineTemplate
4343
path: github.com/scaleway/cluster-api-provider-scaleway/api/v1alpha1
4444
version: v1alpha1
45+
- api:
46+
crdVersion: v1
47+
namespaced: true
48+
controller: true
49+
domain: cluster.x-k8s.io
50+
group: infrastructure
51+
kind: ScalewayManagedCluster
52+
path: github.com/scaleway/cluster-api-provider-scaleway/api/v1alpha1
53+
version: v1alpha1
54+
- api:
55+
crdVersion: v1
56+
namespaced: true
57+
controller: true
58+
domain: cluster.x-k8s.io
59+
group: infrastructure
60+
kind: ScalewayManagedControlPlane
61+
path: github.com/scaleway/cluster-api-provider-scaleway/api/v1alpha1
62+
version: v1alpha1
63+
- api:
64+
crdVersion: v1
65+
namespaced: true
66+
controller: true
67+
domain: cluster.x-k8s.io
68+
group: infrastructure
69+
kind: ScalewayManagedMachinePool
70+
path: github.com/scaleway/cluster-api-provider-scaleway/api/v1alpha1
71+
version: v1alpha1
4572
version: "3"

api/v1alpha1/scalewaycluster_types.go

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,6 @@ type ControlPlaneLoadBalancerSpec struct {
149149
Private *bool `json:"private,omitempty"`
150150
}
151151

152-
// CIDR is an IP address range in CIDR notation (for example, "10.0.0.0/8" or "fd00::/8").
153-
// +kubebuilder:validation:XValidation:rule="isCIDR(self)",message="value must be a valid CIDR network address"
154-
// +kubebuilder:validation:MaxLength:=43
155-
// +kubebuilder:validation:MinLength:=1
156-
type CIDR string
157-
158152
type ControlPlaneDNSSpec struct {
159153
// Domain is the DNS Zone that this record should live in. It must be pre-existing in your Scaleway account.
160154
// The format must be a string that conforms to the definition of a subdomain in DNS (RFC 1123).
@@ -180,44 +174,13 @@ type ControlPlanePrivateDNSSpec struct {
180174
// +kubebuilder:validation:XValidation:rule="has(self.id) && !has(self.subnet) || !has(self.id)",message="subnet cannot be set when id is set"
181175
// +kubebuilder:validation:XValidation:rule="has(self.id) && !has(self.vpcID) || !has(self.id)",message="vpcID cannot be set when id is set"
182176
type PrivateNetworkSpec struct {
177+
PrivateNetworkParams `json:",inline"`
178+
183179
// Set to true to automatically attach machines to a Private Network.
184180
// The Private Network is automatically created if no existing Private
185181
// Network ID is provided.
186182
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
187183
Enabled bool `json:"enabled"`
188-
189-
// Set a Private Network ID to reuse an existing Private Network.
190-
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
191-
// +optional
192-
ID *string `json:"id,omitempty"`
193-
194-
// Set the VPC ID where the new Private Network will be created.
195-
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
196-
// +optional
197-
VPCID *string `json:"vpcID,omitempty"`
198-
199-
// Optional subnet for the Private Network. Only used on newly created Private Networks.
200-
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
201-
// +optional
202-
Subnet *string `json:"subnet,omitempty"`
203-
}
204-
205-
// PublicGatewaySpec defines Public Gateway settings for the cluster.
206-
type PublicGatewaySpec struct {
207-
// Public Gateway commercial offer type.
208-
// +kubebuilder:default="VPC-GW-S"
209-
// +optional
210-
Type *string `json:"type,omitempty"`
211-
212-
// IP to use when creating a Public Gateway.
213-
// +kubebuilder:validation:Format=ipv4
214-
// +optional
215-
IP *string `json:"ip,omitempty"`
216-
217-
// Zone where to create the Public Gateway. Must be in the same region as the
218-
// cluster. Defaults to the first zone of the region.
219-
// +optional
220-
Zone *string `json:"zone,omitempty"`
221184
}
222185

223186
// ScalewayClusterStatus defines the observed state of ScalewayCluster.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
package v1alpha1
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
6+
)
7+
8+
const ManagedClusterFinalizer = "scalewaycluster.infrastructure.cluster.x-k8s.io/smc-protection"
9+
10+
// ScalewayManagedClusterSpec defines the desired state of ScalewayManagedCluster
11+
//
12+
// +kubebuilder:validation:XValidation:rule="(has(self.network) && has(self.network.privateNetwork)) == (has(oldSelf.network) && has(oldSelf.network.privateNetwork))",message="privateNetwork cannot be added or removed"
13+
type ScalewayManagedClusterSpec struct {
14+
// Region where the managed cluster will be created.
15+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
16+
Region string `json:"region"`
17+
18+
// ProjectID in which the managed cluster will be created.
19+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
20+
ProjectID string `json:"projectID"`
21+
22+
// ScalewaySecretName is the name of the secret that contains the Scaleway client parameters.
23+
// The following keys are required: SCW_ACCESS_KEY, SCW_SECRET_KEY, SCW_DEFAULT_PROJECT_ID.
24+
// The following key is optional: SCW_API_URL.
25+
ScalewaySecretName string `json:"scalewaySecretName"`
26+
27+
// Network defines the network configuration of the managed cluster.
28+
// +optional
29+
Network *ManagedNetworkSpec `json:"network,omitempty"`
30+
31+
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
32+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
33+
// +optional
34+
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint,omitempty,omitzero"`
35+
}
36+
37+
// ManagedNetworkSpec defines the network configuration of a managed cluster.
38+
type ManagedNetworkSpec struct {
39+
// PrivateNetwork allows attaching machines of the cluster to a Private Network.
40+
// +kubebuilder:validation:XValidation:rule="has(self.vpcID) == has(oldSelf.vpcID)",message="vpcID cannot be added or removed"
41+
// +kubebuilder:validation:XValidation:rule="has(self.id) == has(oldSelf.id)",message="id cannot be added or removed"
42+
// +kubebuilder:validation:XValidation:rule="has(self.subnet) == has(oldSelf.subnet)",message="subnet cannot be added or removed"
43+
// +kubebuilder:validation:XValidation:rule="has(self.id) && !has(self.subnet) || !has(self.id)",message="subnet cannot be set when id is set"
44+
// +kubebuilder:validation:XValidation:rule="has(self.id) && !has(self.vpcID) || !has(self.id)",message="vpcID cannot be set when id is set"
45+
// +optional
46+
PrivateNetwork *PrivateNetworkParams `json:"privateNetwork,omitempty"`
47+
48+
// PublicGateways allows to create Public Gateways that will be attached to the
49+
// Private Network of the cluster.
50+
// +kubebuilder:validation:MaxItems=6
51+
// +optional
52+
PublicGateways []PublicGatewaySpec `json:"publicGateways,omitempty"`
53+
}
54+
55+
// ScalewayManagedClusterStatus defines the observed state of ScalewayManagedCluster.
56+
type ScalewayManagedClusterStatus struct {
57+
// Ready denotes that the Scaleway managed cluster infrastructure is fully provisioned.
58+
// NOTE: this field is part of the Cluster API contract and it is used to orchestrate provisioning.
59+
// The value of this field is never updated after provisioning is completed.
60+
// +optional
61+
Ready bool `json:"ready"`
62+
63+
// Network contains information about currently provisioned network resources.
64+
// +optional
65+
Network *ManagedNetworkStatus `json:"network,omitempty"`
66+
}
67+
68+
// ManagedNetworkStatus contains information about currently provisioned network resources.
69+
type ManagedNetworkStatus struct {
70+
// PrivateNetworkID is the ID of the Private Network that is attached to the cluster.
71+
// +optional
72+
PrivateNetworkID *string `json:"privateNetworkID,omitempty"`
73+
}
74+
75+
// +kubebuilder:object:root=true
76+
// +kubebuilder:resource:path=scalewaymanagedclusters,scope=Namespaced,categories=cluster-api,shortName=smc
77+
// +kubebuilder:subresource:status
78+
// +kubebuilder:storageversion
79+
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this ScalewayManagedCluster belongs"
80+
// +kubebuilder:printcolumn:name="Ready",type="boolean",JSONPath=".status.ready",description="Ready is true when the managed cluster is fully provisioned"
81+
// +kubebuilder:printcolumn:name="Region",type="string",JSONPath=".spec.region",description="Region of the managed cluster"
82+
// +kubebuilder:printcolumn:name="Host",type="string",JSONPath=".spec.controlPlaneEndpoint.host",description="Host of the control plane"
83+
// +kubebuilder:printcolumn:name="Port",type="integer",JSONPath=".spec.controlPlaneEndpoint.port",description="Port of the control plane"
84+
85+
// ScalewayManagedCluster is the Schema for the scalewaymanagedclusters API
86+
// +kubebuilder:validation:XValidation:rule="self.metadata.name.size() <= 63",message="name must be between 1 and 63 characters"
87+
// +kubebuilder:validation:XValidation:rule="self.metadata.name.matches('^[a-z0-9]([-a-z0-9]*[a-z0-9])?$')",message="name must be a valid DNS label"
88+
type ScalewayManagedCluster struct {
89+
metav1.TypeMeta `json:",inline"`
90+
91+
// metadata is a standard object metadata
92+
// +optional
93+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
94+
95+
// spec defines the desired state of ScalewayManagedCluster
96+
// +required
97+
Spec ScalewayManagedClusterSpec `json:"spec"`
98+
99+
// status defines the observed state of ScalewayManagedCluster
100+
// +optional
101+
Status ScalewayManagedClusterStatus `json:"status,omitempty,omitzero"`
102+
}
103+
104+
// +kubebuilder:object:root=true
105+
106+
// ScalewayManagedClusterList contains a list of ScalewayManagedCluster
107+
type ScalewayManagedClusterList struct {
108+
metav1.TypeMeta `json:",inline"`
109+
metav1.ListMeta `json:"metadata,omitempty"`
110+
Items []ScalewayManagedCluster `json:"items"`
111+
}
112+
113+
func init() {
114+
SchemeBuilder.Register(&ScalewayManagedCluster{}, &ScalewayManagedClusterList{})
115+
}

0 commit comments

Comments
 (0)