Skip to content

Commit a2f5bc5

Browse files
committed
Add Scaleway managed Kubernetes
1 parent d988356 commit a2f5bc5

File tree

76 files changed

+11872
-322
lines changed

Some content is hidden

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

76 files changed

+11872
-322
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
@@ -142,12 +142,6 @@ type ControlPlaneLoadBalancerSpec struct {
142142
Private *bool `json:"private,omitempty"`
143143
}
144144

145-
// CIDR is an IP address range in CIDR notation (for example, "10.0.0.0/8" or "fd00::/8").
146-
// +kubebuilder:validation:XValidation:rule="isCIDR(self)",message="value must be a valid CIDR network address"
147-
// +kubebuilder:validation:MaxLength:=43
148-
// +kubebuilder:validation:MinLength:=1
149-
type CIDR string
150-
151145
type ControlPlaneDNSSpec struct {
152146
// Domain is the DNS Zone that this record should live in. It must be pre-existing in your Scaleway account.
153147
// The format must be a string that conforms to the definition of a subdomain in DNS (RFC 1123).
@@ -173,44 +167,13 @@ type ControlPlanePrivateDNSSpec struct {
173167
// +kubebuilder:validation:XValidation:rule="has(self.id) && !has(self.subnet) || !has(self.id)",message="subnet cannot be set when id is set"
174168
// +kubebuilder:validation:XValidation:rule="has(self.id) && !has(self.vpcID) || !has(self.id)",message="vpcID cannot be set when id is set"
175169
type PrivateNetworkSpec struct {
170+
PrivateNetworkParams `json:",inline"`
171+
176172
// Set to true to automatically attach machines to a Private Network.
177173
// The Private Network is automatically created if no existing Private
178174
// Network ID is provided.
179175
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
180176
Enabled bool `json:"enabled"`
181-
182-
// Set a Private Network ID to reuse an existing Private Network.
183-
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
184-
// +optional
185-
ID *string `json:"id,omitempty"`
186-
187-
// Set the VPC ID where the new Private Network will be created.
188-
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
189-
// +optional
190-
VPCID *string `json:"vpcID,omitempty"`
191-
192-
// Optional subnet for the Private Network. Only used on newly created Private Networks.
193-
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
194-
// +optional
195-
Subnet *string `json:"subnet,omitempty"`
196-
}
197-
198-
// PublicGatewaySpec defines Public Gateway settings for the cluster.
199-
type PublicGatewaySpec struct {
200-
// Public Gateway commercial offer type.
201-
// +kubebuilder:default="VPC-GW-S"
202-
// +optional
203-
Type *string `json:"type,omitempty"`
204-
205-
// IP to use when creating a Public Gateway.
206-
// +kubebuilder:validation:Format=ipv4
207-
// +optional
208-
IP *string `json:"ip,omitempty"`
209-
210-
// Zone where to create the Public Gateway. Must be in the same region as the
211-
// cluster. Defaults to the first zone of the region.
212-
// +optional
213-
Zone *string `json:"zone,omitempty"`
214177
}
215178

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

0 commit comments

Comments
 (0)