Skip to content

Commit

Permalink
feat(api): introducing KamajiControlPlaneTemplate for ClusterClass su…
Browse files Browse the repository at this point in the history
…pport (#107)

Signed-off-by: Dario Tranchitella <[email protected]>
Co-authored-by: Roman Hros <[email protected]>
  • Loading branch information
chess-knight authored Jun 5, 2024
1 parent c82c1e4 commit d05ade0
Show file tree
Hide file tree
Showing 13 changed files with 13,834 additions and 39 deletions.
12 changes: 12 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Code generated by tool. DO NOT EDIT.
# This file is used to track the info used to scaffold your project
# and allow the plugins properly work.
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: cluster.x-k8s.io
layout:
- go.kubebuilder.io/v3
Expand All @@ -16,4 +20,12 @@ resources:
kind: KamajiControlPlane
path: github.com/clastix/cluster-api-control-plane-provider-kamaji/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
domain: cluster.x-k8s.io
group: controlplane
kind: KamajiControlPlaneTemplate
path: github.com/clastix/cluster-api-control-plane-provider-kamaji/api/v1alpha1
version: v1alpha1
version: "3"
56 changes: 30 additions & 26 deletions api/v1alpha1/kamajicontrolplane_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,36 @@ type CoreDNSAddonSpec struct {

// KamajiControlPlaneSpec defines the desired state of KamajiControlPlane.
type KamajiControlPlaneSpec struct {
KamajiControlPlaneFields `json:",inline"`
// Number of desired replicas for the given TenantControlPlane.
// Defaults to 2.
// +kubebuilder:default=2
Replicas *int32 `json:"replicas,omitempty"`
// Version defines the desired Kubernetes version.
// Use the semantic version without the `v` prefix, such as 1.27.0
Version string `json:"version"`
}

type DeploymentComponent struct {
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
RuntimeClassName string `json:"runtimeClassName,omitempty"`
// AdditionalMetadata refers to the additional labels and annotations attached
// to the resulting Deployment managed by Kamaji.
AdditionalMetadata kamajiv1alpha1.AdditionalMetadata `json:"additionalMetadata,omitempty"`
// PodAdditionalMetadata defines the additional labels and annotations that must be attached
// to the resulting Pods managed by the Deployment.
PodAdditionalMetadata kamajiv1alpha1.AdditionalMetadata `json:"podAdditionalMetadata,omitempty"`
ServiceAccountName string `json:"serviceAccountName,omitempty"`
Strategy appsv1.DeploymentStrategy `json:"strategy,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
ExtraInitContainers []corev1.Container `json:"extraInitContainers,omitempty"`
ExtraContainers []corev1.Container `json:"extraContainers,omitempty"`
ExtraVolumes []corev1.Volume `json:"extraVolumes,omitempty"`
}

type KamajiControlPlaneFields struct {
// The Kamaji DataStore to use for the given TenantControlPlane.
// Retrieve the list of the allowed ones by issuing "kubectl get datastores.kamaji.clastix.io".
DataStoreName string `json:"dataStoreName"`
Expand Down Expand Up @@ -102,32 +132,6 @@ type KamajiControlPlaneSpec struct {
Network NetworkComponent `json:"network,omitempty"`
// Configure how the TenantControlPlane Deployment object should be configured.
Deployment DeploymentComponent `json:"deployment,omitempty"`
// Number of desired replicas for the given TenantControlPlane.
// Defaults to 2.
// +kubebuilder:default=2
Replicas *int32 `json:"replicas,omitempty"`
// Version defines the desired Kubernetes version.
// Use the semantic version without the `v` prefix, such as 1.27.0
Version string `json:"version"`
}

type DeploymentComponent struct {
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
RuntimeClassName string `json:"runtimeClassName,omitempty"`
// AdditionalMetadata refers to the additional labels and annotations attached
// to the resulting Deployment managed by Kamaji.
AdditionalMetadata kamajiv1alpha1.AdditionalMetadata `json:"additionalMetadata,omitempty"`
// PodAdditionalMetadata defines the additional labels and annotations that must be attached
// to the resulting Pods managed by the Deployment.
PodAdditionalMetadata kamajiv1alpha1.AdditionalMetadata `json:"podAdditionalMetadata,omitempty"`
ServiceAccountName string `json:"serviceAccountName,omitempty"`
Strategy appsv1.DeploymentStrategy `json:"strategy,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
ExtraInitContainers []corev1.Container `json:"extraInitContainers,omitempty"`
ExtraContainers []corev1.Container `json:"extraContainers,omitempty"`
ExtraVolumes []corev1.Volume `json:"extraVolumes,omitempty"`
}

// KamajiControlPlaneStatus defines the observed state of KamajiControlPlane.
Expand Down
47 changes: 47 additions & 0 deletions api/v1alpha1/kamajicontrolplanetemplate_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2023 Clastix Labs
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

// KamajiControlPlaneTemplateSpec defines the desired state of KamajiControlPlaneTemplate.
type KamajiControlPlaneTemplateSpec struct {
Template KamajiControlPlaneTemplateResource `json:"template"`
}

//+kubebuilder:object:root=true
//+kubebuilder:resource:categories=cluster-api;kamaji,shortName=ktcpt

// KamajiControlPlaneTemplate is the Schema for the kamajicontrolplanetemplates API.
type KamajiControlPlaneTemplate struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec KamajiControlPlaneTemplateSpec `json:"spec,omitempty"`
}

//+kubebuilder:object:root=true

// KamajiControlPlaneTemplateList contains a list of KamajiControlPlaneTemplate.
type KamajiControlPlaneTemplateList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []KamajiControlPlaneTemplate `json:"items"`
}

func init() {
SchemeBuilder.Register(&KamajiControlPlaneTemplate{}, &KamajiControlPlaneTemplateList{})
}

// KamajiControlPlaneTemplateResource describes the data needed to create a KamajiControlPlane from a template.
type KamajiControlPlaneTemplateResource struct {
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
// +optional
ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"`
Spec KamajiControlPlaneFields `json:"spec"`
}
133 changes: 120 additions & 13 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d05ade0

Please sign in to comment.