Skip to content

Commit

Permalink
HOSTEDCP-1960: Add KubeAPIExteralName api
Browse files Browse the repository at this point in the history
This new API changes the value of the Kubeconfig External URL to points to your desired one

Signed-off-by: Juan Manuel Parrilla Madrid <[email protected]>
  • Loading branch information
jparrill committed Jan 28, 2025
1 parent 7c9455f commit d6e3182
Show file tree
Hide file tree
Showing 42 changed files with 1,358 additions and 11 deletions.
30 changes: 30 additions & 0 deletions api/hypershift/v1beta1/hosted_controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ type HostedControlPlaneSpec struct {
// +optional
KubeConfig *KubeconfigSecretRef `json:"kubeconfig,omitempty"`

// KubeAPICustomKubeconfig is a group that encompasses an additional KAS server address and the customKubeconfig generated for the kube-apiserver.
// +optional
KubeAPICustomKubeconfig *KubeAPICustomKubeconfig `json:"kubeAPICustomKubeconfig,omitempty"`

// Services defines metadata about how control plane services are published
// in the management cluster.
// +kubebuilder:validation:MaxItems=6
Expand Down Expand Up @@ -202,6 +206,26 @@ type HostedControlPlaneSpec struct {
Labels map[string]string `json:"labels,omitempty"`
}

// KubeAPICustomKubeconfig is a group that englobes an additional KAS server address and the customKubeconfig generated for the kube-apiserver.
// +optional
type KubeAPICustomKubeconfig struct {
// CustomKubeConfig specifies the name and key for the External Custom kubeconfig secret.
// When set, it triggers the generation of a secret with the specified name containing a kubeconfig within the `HostedCluster` namespace.
// This kubeconfig will also be referenced in the `HostedCluster.status` as `customKubeconfig`.
// If removed during day-2 operations, all related secrets and status references will also be deleted.
// +optional
CustomKubeConfig *KubeconfigSecretRef `json:"customkubeconfig,omitempty"`

// kubeApiCustomName specifies the external name for the Kube API Server service.
// This is used to configure the Kube API Server service to use a different name, so
// the DNS should be configured to resolve the external name to the Kube API Server service.
// +kubebuilder:validation:XValidation:rule=`self == "" || self.matches('^(?:(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}|[a-zA-Z0-9-]+)$')`,message="kubeApiCustomName must be a valid URL name (e.g., api.example.com)"
// +kubebuilder:validation:MaxLength=253
// +kubebuilder:example: "api.example.com"
// +optional
KubeAPICustomName string `json:"kubeAPICustomName,omitempty"`
}

// availabilityPolicy specifies a high level availability policy for components.
// +kubebuilder:validation:Enum=HighlyAvailable;SingleReplica
type AvailabilityPolicy string
Expand Down Expand Up @@ -300,6 +324,12 @@ type HostedControlPlaneStatus struct {
// for this control plane.
KubeConfig *KubeconfigSecretRef `json:"kubeConfig,omitempty"`

// CustomKubeConfig specifies the name and key for the External Custom kubeconfig secret.
// This field is optional and only allowed if kubeApiExternalName is not empty. When set, they result in the generation of a secret with the given name containing a Kubeconfig within the hostedCluster namespace and a referenced by the hostedCluster.status object.
// When removed day 2 the secret will be deleted and the kubeconfig will be removed from the hostedCluster.status object.
// +optional
CustomKubeConfig *KubeconfigSecretRef `json:"customkubeconfig,omitempty"`

// KubeadminPassword is a reference to the secret containing the initial kubeadmin password
// for the guest cluster.
// +optional
Expand Down
16 changes: 16 additions & 0 deletions api/hypershift/v1beta1/hostedcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,15 @@ type HostedClusterSpec struct {
// +required
Platform PlatformSpec `json:"platform"`

// kubeApiCustomName specifies the external name for the Kube API Server service.
// This is used to configure the Kube API Server service to use a different name, so
// the DNS should be configured to resolve the external name to the Kube API Server service.
// +kubebuilder:validation:XValidation:rule=`self == "" || self.matches('^(?:(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}|[a-zA-Z0-9-]+)$')`,message="kubeApiCustomName must be a valid URL name (e.g., api.example.com)"
// +kubebuilder:validation:MaxLength=253
// +kubebuilder:example: "api.example.com"
// +optional
KubeAPICustomName string `json:"kubeAPICustomName,omitempty"`

// controllerAvailabilityPolicy specifies the availability policy applied to critical control plane components like the Kube API Server.
// Possible values are HighlyAvailable and SingleReplica. The default value is HighlyAvailable.
// +optional
Expand Down Expand Up @@ -1423,6 +1432,13 @@ type HostedClusterStatus struct {
// +optional
KubeConfig *corev1.LocalObjectReference `json:"kubeconfig,omitempty"`

// CustomKubeConfig specifies the name and key for the External Custom kubeconfig secret.
// When set, it triggers the generation of a secret with the specified name containing a kubeconfig within the `HostedCluster` namespace.
// This kubeconfig will also be referenced in the `HostedCluster.status` as `customKubeconfig`.
// If removed during day-2 operations, all related secrets and status references will also be deleted.
// +optional
CustomKubeConfig *corev1.LocalObjectReference `json:"customKubeConfig,omitempty"`

// KubeadminPassword is a reference to the secret that contains the initial
// kubeadmin user password for the guest cluster.
// +optional
Expand Down
35 changes: 35 additions & 0 deletions api/hypershift/v1beta1/zz_generated.deepcopy.go

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
Expand Up @@ -2347,6 +2347,16 @@ spec:
rule: self == oldSelf
- message: issuerURL must be a valid absolute URL
rule: isURL(self)
kubeAPICustomName:
description: |-
kubeApiCustomName specifies the external name for the Kube API Server service.
This is used to configure the Kube API Server service to use a different name, so
the DNS should be configured to resolve the external name to the Kube API Server service.
maxLength: 253
type: string
x-kubernetes-validations:
- message: kubeApiCustomName must be a valid URL name (e.g., api.example.com)
rule: self == "" || self.matches('^(?:(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}|[a-zA-Z0-9-]+)$')
networking:
default:
clusterNetwork:
Expand Down Expand Up @@ -4170,6 +4180,24 @@ spec:
- host
- port
type: object
customKubeConfig:
description: |-
CustomKubeConfig specifies the name and key for the External Custom kubeconfig secret.
When set, it triggers the generation of a secret with the specified name containing a kubeconfig within the `HostedCluster` namespace.
This kubeconfig will also be referenced in the `HostedCluster.status` as `customKubeconfig`.
If removed during day-2 operations, all related secrets and status references will also be deleted.
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
type: object
x-kubernetes-map-type: atomic
ignitionEndpoint:
description: |-
IgnitionEndpoint is the endpoint injected in the ign config userdata.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2343,6 +2343,16 @@ spec:
rule: self == oldSelf
- message: issuerURL must be a valid absolute URL
rule: isURL(self)
kubeAPICustomName:
description: |-
kubeApiCustomName specifies the external name for the Kube API Server service.
This is used to configure the Kube API Server service to use a different name, so
the DNS should be configured to resolve the external name to the Kube API Server service.
maxLength: 253
type: string
x-kubernetes-validations:
- message: kubeApiCustomName must be a valid URL name (e.g., api.example.com)
rule: self == "" || self.matches('^(?:(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}|[a-zA-Z0-9-]+)$')
networking:
default:
clusterNetwork:
Expand Down Expand Up @@ -4415,6 +4425,24 @@ spec:
- host
- port
type: object
customKubeConfig:
description: |-
CustomKubeConfig specifies the name and key for the External Custom kubeconfig secret.
When set, it triggers the generation of a secret with the specified name containing a kubeconfig within the `HostedCluster` namespace.
This kubeconfig will also be referenced in the `HostedCluster.status` as `customKubeconfig`.
If removed during day-2 operations, all related secrets and status references will also be deleted.
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
type: object
x-kubernetes-map-type: atomic
ignitionEndpoint:
description: |-
IgnitionEndpoint is the endpoint injected in the ign config userdata.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2388,6 +2388,16 @@ spec:
rule: self == oldSelf
- message: issuerURL must be a valid absolute URL
rule: isURL(self)
kubeAPICustomName:
description: |-
kubeApiCustomName specifies the external name for the Kube API Server service.
This is used to configure the Kube API Server service to use a different name, so
the DNS should be configured to resolve the external name to the Kube API Server service.
maxLength: 253
type: string
x-kubernetes-validations:
- message: kubeApiCustomName must be a valid URL name (e.g., api.example.com)
rule: self == "" || self.matches('^(?:(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}|[a-zA-Z0-9-]+)$')
networking:
default:
clusterNetwork:
Expand Down Expand Up @@ -4203,6 +4213,24 @@ spec:
- host
- port
type: object
customKubeConfig:
description: |-
CustomKubeConfig specifies the name and key for the External Custom kubeconfig secret.
When set, it triggers the generation of a secret with the specified name containing a kubeconfig within the `HostedCluster` namespace.
This kubeconfig will also be referenced in the `HostedCluster.status` as `customKubeconfig`.
If removed during day-2 operations, all related secrets and status references will also be deleted.
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
type: object
x-kubernetes-map-type: atomic
ignitionEndpoint:
description: |-
IgnitionEndpoint is the endpoint injected in the ign config userdata.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2364,6 +2364,16 @@ spec:
rule: self == oldSelf
- message: issuerURL must be a valid absolute URL
rule: isURL(self)
kubeAPICustomName:
description: |-
kubeApiCustomName specifies the external name for the Kube API Server service.
This is used to configure the Kube API Server service to use a different name, so
the DNS should be configured to resolve the external name to the Kube API Server service.
maxLength: 253
type: string
x-kubernetes-validations:
- message: kubeApiCustomName must be a valid URL name (e.g., api.example.com)
rule: self == "" || self.matches('^(?:(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}|[a-zA-Z0-9-]+)$')
networking:
default:
clusterNetwork:
Expand Down Expand Up @@ -4179,6 +4189,24 @@ spec:
- host
- port
type: object
customKubeConfig:
description: |-
CustomKubeConfig specifies the name and key for the External Custom kubeconfig secret.
When set, it triggers the generation of a secret with the specified name containing a kubeconfig within the `HostedCluster` namespace.
This kubeconfig will also be referenced in the `HostedCluster.status` as `customKubeconfig`.
If removed during day-2 operations, all related secrets and status references will also be deleted.
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
type: object
x-kubernetes-map-type: atomic
ignitionEndpoint:
description: |-
IgnitionEndpoint is the endpoint injected in the ign config userdata.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2585,6 +2585,16 @@ spec:
rule: self == oldSelf
- message: issuerURL must be a valid absolute URL
rule: isURL(self)
kubeAPICustomName:
description: |-
kubeApiCustomName specifies the external name for the Kube API Server service.
This is used to configure the Kube API Server service to use a different name, so
the DNS should be configured to resolve the external name to the Kube API Server service.
maxLength: 253
type: string
x-kubernetes-validations:
- message: kubeApiCustomName must be a valid URL name (e.g., api.example.com)
rule: self == "" || self.matches('^(?:(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}|[a-zA-Z0-9-]+)$')
networking:
default:
clusterNetwork:
Expand Down Expand Up @@ -4400,6 +4410,24 @@ spec:
- host
- port
type: object
customKubeConfig:
description: |-
CustomKubeConfig specifies the name and key for the External Custom kubeconfig secret.
When set, it triggers the generation of a secret with the specified name containing a kubeconfig within the `HostedCluster` namespace.
This kubeconfig will also be referenced in the `HostedCluster.status` as `customKubeconfig`.
If removed during day-2 operations, all related secrets and status references will also be deleted.
properties:
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
type: object
x-kubernetes-map-type: atomic
ignitionEndpoint:
description: |-
IgnitionEndpoint is the endpoint injected in the ign config userdata.
Expand Down
Loading

0 comments on commit d6e3182

Please sign in to comment.