-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ add clusterclass #55
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
Copyright 2024 IONOS Cloud. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// IonosCloudClusterTemplateSpec defines the desired state of IonosCloudClusterTemplate. | ||
type IonosCloudClusterTemplateSpec struct { | ||
Template IonosCloudClusterTemplateResource `json:"template"` | ||
} | ||
|
||
// IonosCloudClusterTemplateResource describes the data for creating a IonosCloudCluster from a template. | ||
type IonosCloudClusterTemplateResource struct { | ||
Spec IonosCloudClusterSpec `json:"spec"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// IonosCloudClusterTemplate is the Schema for the ionoscloudclustertemplates API. | ||
type IonosCloudClusterTemplate struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec IonosCloudClusterTemplateSpec `json:"spec,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// IonosCloudClusterTemplateList contains a list of IonosCloudClusterTemplate. | ||
type IonosCloudClusterTemplateList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []IonosCloudCluster `json:"items"` | ||
} | ||
|
||
func init() { | ||
objectTypes = append(objectTypes, &IonosCloudClusterTemplate{}, &IonosCloudClusterTemplateList{}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.14.0 | ||
name: ionoscloudclustertemplates.infrastructure.cluster.x-k8s.io | ||
spec: | ||
group: infrastructure.cluster.x-k8s.io | ||
names: | ||
kind: IonosCloudClusterTemplate | ||
listKind: IonosCloudClusterTemplateList | ||
plural: ionoscloudclustertemplates | ||
singular: ionoscloudclustertemplate | ||
scope: Namespaced | ||
versions: | ||
- name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: IonosCloudClusterTemplate is the Schema for the ionoscloudclustertemplates | ||
API. | ||
properties: | ||
apiVersion: | ||
description: |- | ||
APIVersion defines the versioned schema of this representation of an object. | ||
Servers should convert recognized schemas to the latest internal value, and | ||
may reject unrecognized values. | ||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | ||
type: string | ||
kind: | ||
description: |- | ||
Kind is a string value representing the REST resource this object represents. | ||
Servers may infer this from the endpoint the client submits requests to. | ||
Cannot be updated. | ||
In CamelCase. | ||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | ||
type: string | ||
metadata: | ||
type: object | ||
spec: | ||
description: IonosCloudClusterTemplateSpec defines the desired state of | ||
IonosCloudClusterTemplate. | ||
properties: | ||
template: | ||
description: IonosCloudClusterTemplateResource describes the data | ||
for creating a IonosCloudCluster from a template. | ||
properties: | ||
spec: | ||
description: IonosCloudClusterSpec defines the desired state of | ||
IonosCloudCluster. | ||
properties: | ||
contractNumber: | ||
description: Contract number is the contract number of the | ||
IONOS Cloud account. | ||
type: string | ||
x-kubernetes-validations: | ||
- message: contractNumber is immutable | ||
rule: self == oldSelf | ||
controlPlaneEndpoint: | ||
description: |- | ||
ControlPlaneEndpoint represents the endpoint used to communicate with the control plane. | ||
TODO(gfariasalves): as of now, IP must be provided by the user as we still don't insert the | ||
provider-provided block IP into the kube-vip manifest. | ||
properties: | ||
host: | ||
description: The hostname on which the API server is serving. | ||
type: string | ||
port: | ||
description: The port on which the API server is serving. | ||
format: int32 | ||
type: integer | ||
required: | ||
- host | ||
- port | ||
type: object | ||
x-kubernetes-validations: | ||
- message: control plane endpoint host cannot be updated | ||
rule: self.host == oldSelf.host || oldSelf.host == '' | ||
- message: control plane endpoint port cannot be updated | ||
rule: self.port == oldSelf.port || oldSelf.port == 0 | ||
credentialsRef: | ||
description: CredentialsRef is a reference to the secret containing | ||
the credentials to access the IONOS Cloud API. | ||
properties: | ||
name: | ||
description: |- | ||
Name of the referent. | ||
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names | ||
TODO: Add other useful fields. apiVersion, kind, uid? | ||
type: string | ||
type: object | ||
x-kubernetes-map-type: atomic | ||
x-kubernetes-validations: | ||
- message: credentialsRef.name must be provided | ||
rule: has(self.name) && self.name != '' | ||
location: | ||
description: Location is the location where the data centers | ||
should be located. | ||
example: de/txl | ||
minLength: 1 | ||
type: string | ||
x-kubernetes-validations: | ||
- message: location is immutable | ||
rule: self == oldSelf | ||
required: | ||
- contractNumber | ||
- credentialsRef | ||
- location | ||
type: object | ||
required: | ||
- spec | ||
type: object | ||
required: | ||
- template | ||
type: object | ||
type: object | ||
served: true | ||
storage: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
apiVersion: cluster.x-k8s.io/v1beta1 | ||
kind: Cluster | ||
metadata: | ||
labels: | ||
cluster.x-k8s.io/cluster-name: '${CLUSTER_NAME}' | ||
name: '${CLUSTER_NAME}' | ||
namespace: '${NAMESPACE}' | ||
spec: | ||
topology: | ||
class: '${CLUSTER_CLASS_NAME}' | ||
controlPlane: | ||
replicas: ${CONTROL_PLANE_MACHINE_COUNT} | ||
variables: | ||
- name: sshKey | ||
value: '${VSPHERE_SSH_AUTHORIZED_KEY}' | ||
- name: controlPlaneIpAddr | ||
value: ${CONTROL_PLANE_ENDPOINT_IP} | ||
- name: controlPlanePort | ||
value: ${CONTROL_PLANE_ENDPOINT_PORT:-6443} | ||
- name: credsSecretName | ||
value: '${CLUSTER_NAME}' | ||
- name: datacenterID | ||
value: '${IONOSCLOUD_DATACENTER_ID}' | ||
- name: contractNumber | ||
value: '${IONOSCLOUD_CONTRACT_NUMBER}' | ||
- name: location | ||
value: '${CONTROL_PLANE_ENDPOINT_LOCATION}' | ||
version: '${KUBERNETES_VERSION}' | ||
workers: | ||
machineDeployments: | ||
- class: ${CLUSTER_CLASS_NAME}-worker | ||
metadata: {} | ||
name: md-0 | ||
replicas: ${WORKER_MACHINE_COUNT} | ||
--- | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: "${CLUSTER_NAME}-credentials" | ||
namespace: '${NAMESPACE}' | ||
type: Opaque | ||
stringData: | ||
token: "${IONOS_TOKEN}" | ||
apiURL: "${IONOS_API_URL:-https://api.ionos.com/cloudapi/v6}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We aim to have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tend to work with editorconfig everywhere. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy pasta.
Also we can provide multiple ssh keys with
${IONOSCLOUD_MACHINE_SSH_KEYS}
. So you might want to use the plural form for the variable