From 258e97473ea0e3f9a9562b1a7415d9a25b2bf557 Mon Sep 17 00:00:00 2001 From: enxebre Date: Thu, 12 Dec 2024 13:03:36 +0100 Subject: [PATCH] Add AutoNode Karpenter feature gated API support --- .../featureGate-Hypershift-Default.yaml | 3 ++ ...eGate-Hypershift-TechPreviewNoUpgrade.yaml | 3 ++ .../featureGate-SelfManagedHA-Default.yaml | 3 ++ ...te-SelfManagedHA-TechPreviewNoUpgrade.yaml | 3 ++ api/hypershift/v1beta1/hosted_controlplane.go | 4 ++ api/hypershift/v1beta1/hostedcluster_types.go | 45 +++++++++++++++++++ 6 files changed, 61 insertions(+) diff --git a/api/hypershift/v1beta1/featuregates/featureGate-Hypershift-Default.yaml b/api/hypershift/v1beta1/featuregates/featureGate-Hypershift-Default.yaml index 8576664946..1c370c8571 100644 --- a/api/hypershift/v1beta1/featuregates/featureGate-Hypershift-Default.yaml +++ b/api/hypershift/v1beta1/featuregates/featureGate-Hypershift-Default.yaml @@ -15,6 +15,9 @@ "featureGates": [ { "disabled": [ + { + "name": "AutoNodeKarpenter", + }, { "name": "AROHCPManagedIdentities" }, diff --git a/api/hypershift/v1beta1/featuregates/featureGate-Hypershift-TechPreviewNoUpgrade.yaml b/api/hypershift/v1beta1/featuregates/featureGate-Hypershift-TechPreviewNoUpgrade.yaml index c67a7d1639..1e26eceb21 100644 --- a/api/hypershift/v1beta1/featuregates/featureGate-Hypershift-TechPreviewNoUpgrade.yaml +++ b/api/hypershift/v1beta1/featuregates/featureGate-Hypershift-TechPreviewNoUpgrade.yaml @@ -16,6 +16,9 @@ { "disabled": [], "enabled": [ + { + "name": "AutoNodeKarpenter", + }, { "name": "AROHCPManagedIdentities" }, diff --git a/api/hypershift/v1beta1/featuregates/featureGate-SelfManagedHA-Default.yaml b/api/hypershift/v1beta1/featuregates/featureGate-SelfManagedHA-Default.yaml index 8576664946..1c370c8571 100644 --- a/api/hypershift/v1beta1/featuregates/featureGate-SelfManagedHA-Default.yaml +++ b/api/hypershift/v1beta1/featuregates/featureGate-SelfManagedHA-Default.yaml @@ -15,6 +15,9 @@ "featureGates": [ { "disabled": [ + { + "name": "AutoNodeKarpenter", + }, { "name": "AROHCPManagedIdentities" }, diff --git a/api/hypershift/v1beta1/featuregates/featureGate-SelfManagedHA-TechPreviewNoUpgrade.yaml b/api/hypershift/v1beta1/featuregates/featureGate-SelfManagedHA-TechPreviewNoUpgrade.yaml index c67a7d1639..6b9ca32850 100644 --- a/api/hypershift/v1beta1/featuregates/featureGate-SelfManagedHA-TechPreviewNoUpgrade.yaml +++ b/api/hypershift/v1beta1/featuregates/featureGate-SelfManagedHA-TechPreviewNoUpgrade.yaml @@ -16,6 +16,9 @@ { "disabled": [], "enabled": [ + { + "name": "AutoNodeKarpenter", + }, { "name": "AROHCPManagedIdentities" }, diff --git a/api/hypershift/v1beta1/hosted_controlplane.go b/api/hypershift/v1beta1/hosted_controlplane.go index 0c46641f8d..7dffc7e199 100644 --- a/api/hypershift/v1beta1/hosted_controlplane.go +++ b/api/hypershift/v1beta1/hosted_controlplane.go @@ -175,6 +175,10 @@ type HostedControlPlaneSpec struct { // +optional Autoscaling ClusterAutoscaling `json:"autoscaling,omitempty"` + // autoNode specifies the configuration for the autoNode feature. + // +openshift:enable:FeatureGate=AutoNodeKarpenter + AutoNode *AutoNode `json:"autoNode,omitempty"` + // NodeSelector when specified, must be true for the pods managed by the HostedCluster to be scheduled. // // +optional diff --git a/api/hypershift/v1beta1/hostedcluster_types.go b/api/hypershift/v1beta1/hostedcluster_types.go index da3e55f8b1..c541d9639b 100644 --- a/api/hypershift/v1beta1/hostedcluster_types.go +++ b/api/hypershift/v1beta1/hostedcluster_types.go @@ -460,6 +460,10 @@ type HostedClusterSpec struct { // +optional Autoscaling ClusterAutoscaling `json:"autoscaling,omitempty"` + // autoNode specifies the configuration for the autoNode feature. + // +openshift:enable:FeatureGate=AutoNodeKarpenter + AutoNode *AutoNode `json:"autoNode,omitempty"` + // etcd specifies configuration for the control plane etcd cluster. The // default managementType is Managed. Once set, the managementType cannot be // changed. @@ -1096,6 +1100,47 @@ type Release struct { Image string `json:"image"` } +// We expose here internal configuration knobs that won't be exposed to the service. +type AutoNode struct { + // provisioner is the implementation used for Node auto provisioning. + // +required + Provisioner *ProvisionerConfig `json:"provisionerConfig"` +} + +// ProvisionerConfig is a enum specifying the strategy for auto managing Nodes. +type ProvisionerConfig struct { + // name specifies the name of the provisioner to use. + // +required + // +kubebuilder:validation:Enum=Karpenter + Name Provisioner `json:"name"` + // karpenter specifies the configuration for the Karpenter provisioner. + // +optional + Karpenter *KarpenterConfig `json:"karpenter,omitempty"` +} + +type KarpenterConfig struct { + // platform specifies the platform-specific configuration for Karpenter. + // +required + Platform PlatformType `json:"platform"` + // aws specifies the AWS-specific configuration for Karpenter. + // +optional + AWS *KarpenterAWSConfig `json:"aws,omitempty"` +} + +type KarpenterAWSConfig struct { + //arn specifies the ARN of the Karpenter provisioner. + // +required + RoleARN string `json:"roleARN"` +} + +const ( + ProvisionerKarpeneter Provisioner = "Karpenter" +) + +// provisioner is a enum specifying the strategy for auto managing Nodes. +// +kubebuilder:validation:Enum=Karpenter +type Provisioner string + // ClusterAutoscaling specifies auto-scaling behavior that applies to all // NodePools associated with a control plane. type ClusterAutoscaling struct {