Repository navigation
feat: add SKE managed cluster and node pool APIs #36
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
Draft
Rana-Ashar
wants to merge
3
commits into
main
Choose a base branch
from
feature/stackit-managed-specs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,165 @@ | ||
| /* | ||
| Copyright 2026. | ||
|
|
||
| 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 ( | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" | ||
| ) | ||
|
|
||
| // ManagedClusterFinalizer allows StackitManagedClusterReconciler to clean up | ||
| // external SKE resources before the StackitManagedCluster is removed from the | ||
| // API server. | ||
| const ( | ||
| ManagedClusterFinalizer = "infrastructure.cluster.x-k8s.io/stackitmanagedcluster" | ||
| LegacyManagedClusterFinalizer = "stackitmanagedcluster.infrastructure.cluster.x-k8s.io" | ||
| ) | ||
|
|
||
| // Condition types maintained by the StackitManagedClusterReconciler. | ||
| const ( | ||
| ManagedClusterReadyCondition = "Ready" | ||
| ) | ||
|
|
||
| // StackitManagedClusterSpec defines the desired state of StackitManagedCluster. | ||
| // +kubebuilder:validation:XValidation:rule="has(self.credentialsSecretRef.name) && size(self.credentialsSecretRef.name) > 0",message="credentialsSecretRef.name is required" | ||
| type StackitManagedClusterSpec struct { | ||
| // projectID is the STACKIT project that owns the cluster infrastructure. | ||
| // +required | ||
| // +kubebuilder:validation:MinLength=1 | ||
| // +kubebuilder:validation:Pattern=`^[0-9a-fA-F-]{36}$` | ||
| ProjectID string `json:"projectID"` | ||
|
|
||
| // region is the STACKIT region in which infrastructure is created. | ||
| // +required | ||
| // +kubebuilder:validation:MinLength=1 | ||
| // +kubebuilder:validation:Pattern=`^[a-z]{2}[0-9]{2}$` | ||
| Region string `json:"region"` | ||
|
|
||
| // clusterName is the SKE cluster name in STACKIT. | ||
| // +required | ||
| // +kubebuilder:validation:MinLength=1 | ||
| // +kubebuilder:validation:MaxLength=11 | ||
| // +kubebuilder:validation:Pattern=`^[a-z0-9]([a-z0-9-]{0,9}[a-z0-9])?$` | ||
| ClusterName string `json:"clusterName"` | ||
|
|
||
| // credentialsSecretRef references the Secret containing STACKIT credentials. | ||
| // +required | ||
| CredentialsSecretRef corev1.SecretReference `json:"credentialsSecretRef"` | ||
|
|
||
| // kubernetes configures the SKE cluster Kubernetes version. | ||
| // +required | ||
| Kubernetes StackitManagedClusterKubernetesSpec `json:"kubernetes"` | ||
|
|
||
| // network configures the STACKIT network for the SKE cluster. | ||
| // +optional | ||
| Network *StackitManagedClusterNetworkSpec `json:"network,omitempty"` | ||
|
|
||
| // controlPlaneEndpoint represents the endpoint used to communicate with the | ||
| // control plane. | ||
| // +optional | ||
| ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint,omitempty,omitzero"` | ||
|
|
||
| // labels are key-value pairs applied to the SKE cluster object. | ||
| // +optional | ||
| Labels map[string]string `json:"labels,omitempty"` | ||
| } | ||
|
|
||
| // StackitManagedClusterKubernetesSpec configures the Kubernetes version for an | ||
| // SKE cluster. | ||
| type StackitManagedClusterKubernetesSpec struct { | ||
| // version is the full Kubernetes version used for the cluster | ||
| // (major.minor.patch). | ||
| // +required | ||
| // +kubebuilder:validation:Pattern=`^[0-9]+\.[0-9]+\.[0-9]+$` | ||
| Version string `json:"version"` | ||
| } | ||
|
|
||
| // StackitManagedClusterNetworkSpec configures the STACKIT network for an SKE | ||
| // cluster. | ||
| type StackitManagedClusterNetworkSpec struct { | ||
| // id is the ID of the STACKIT network into which the cluster will be | ||
| // deployed. | ||
| // +required | ||
| // +kubebuilder:validation:MinLength=1 | ||
| // +kubebuilder:validation:Pattern=`^[0-9a-fA-F-]{36}$` | ||
| ID string `json:"id"` | ||
| } | ||
|
|
||
| // StackitManagedClusterStatus defines the observed state of StackitManagedCluster. | ||
| type StackitManagedClusterStatus struct { | ||
| // ready indicates that the infrastructure required for the cluster is ready. | ||
| // +optional | ||
| Ready bool `json:"ready,omitempty"` | ||
|
|
||
| // initialization provides Cluster API v1beta2 contract state. | ||
| // +optional | ||
| Initialization StackitManagedClusterInitializationStatus `json:"initialization,omitempty,omitzero"` | ||
|
|
||
| // conditions represent the current state of the StackitManagedCluster resource. | ||
| // +listType=map | ||
| // +listMapKey=type | ||
| // +optional | ||
| Conditions []metav1.Condition `json:"conditions,omitempty"` | ||
| } | ||
|
|
||
| // StackitManagedClusterInitializationStatus provides observations of the | ||
| // StackitManagedCluster initialization process. | ||
| // +kubebuilder:validation:MinProperties=1 | ||
| type StackitManagedClusterInitializationStatus struct { | ||
| // provisioned is true when the infrastructure provider reports that the | ||
| // cluster infrastructure is fully provisioned. | ||
| // +optional | ||
| Provisioned *bool `json:"provisioned,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:resource:path=stackitmanagedclusters,shortName=stmc,scope=Namespaced,categories=cluster-api | ||
| // +kubebuilder:subresource:status | ||
| // +kubebuilder:printcolumn:name="Ready",type=boolean,JSONPath=".status.ready" | ||
| // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=".metadata.creationTimestamp" | ||
| // +kubebuilder:storageversion | ||
|
|
||
| // StackitManagedCluster is the Schema for the stackitmanagedclusters API. | ||
| type StackitManagedCluster struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
|
|
||
| // metadata is a standard object metadata | ||
| // +optional | ||
| metav1.ObjectMeta `json:"metadata,omitzero"` | ||
|
|
||
| // spec defines the desired state of StackitManagedCluster | ||
| // +required | ||
| Spec StackitManagedClusterSpec `json:"spec"` | ||
|
|
||
| // status defines the observed state of StackitManagedCluster | ||
| // +optional | ||
| Status StackitManagedClusterStatus `json:"status,omitzero"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
|
|
||
| // StackitManagedClusterList contains a list of StackitManagedCluster. | ||
| type StackitManagedClusterList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitzero"` | ||
| Items []StackitManagedCluster `json:"items"` | ||
| } | ||
|
|
||
| func init() { | ||
| SchemeBuilder.Register(&StackitManagedCluster{}, &StackitManagedClusterList{}) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is this an official pattern you got from our stackit api docs?
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.
This pattern is not coming from the SKE api docs. I reused the existing validation from StackitClusterSpec.Region.