Skip to content
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

HOSTEDCP-1960: Add KubeAPIExteralName api #5458

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions api/hypershift/v1beta1/hosted_controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ type HostedControlPlaneSpec struct {
// +optional
KubeConfig *KubeconfigSecretRef `json:"kubeconfig,omitempty"`

// CustomKubeConfig specifies the name and key for the External Custom kubeconfig secret
// +optional
CustomKubeConfig *KubeconfigSecretRef `json:"customKubeConfig,omitempty"`

// kubeApiExternalName 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:MaxLength=100
// +kubebuilder:validation:MinLength=1
// +kubebuilder:example: "api.example.com"
// +optional
KubeAPIExternalName string `json:"kubeApiExternalName,omitempty"`

// Services defines metadata about how control plane services are published
// in the management cluster.
// +kubebuilder:validation:MaxItems=6
Expand Down Expand Up @@ -300,6 +313,10 @@ type HostedControlPlaneStatus struct {
// for this control plane.
KubeConfig *KubeconfigSecretRef `json:"kubeConfig,omitempty"`

// CustomKubeConfig specifies the name and key for the External Custom kubeconfig secret
// +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
11 changes: 11 additions & 0 deletions api/hypershift/v1beta1/hostedcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,13 @@ type HostedClusterSpec struct {
// +required
Platform PlatformSpec `json:"platform"`

// kubeApiExternalName specifies the external name for the Kube API Server service.
// +kubebuilder:validation:MaxLength=100
// +kubebuilder:validation:MinLength=1
// +kubebuilder:example: "api.example.com"
// +optional
KubeAPIExternalName string `json:"kubeApiExternalName,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kubeApiExternalName -> kubeAPIExternalName

Copy link
Member

@enxebre enxebre Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://github.com/openshift/hypershift/pull/5458/files#r1930322503
What happens if I set this field? What need to be done out of band?...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use same cel regex validation we do for BaseDomain and others


// 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 +1430,10 @@ type HostedClusterStatus struct {
// +optional
KubeConfig *corev1.LocalObjectReference `json:"kubeconfig,omitempty"`

// CustomKubeConfig specifies the name and key for the External Custom kubeconfig secret
Copy link
Member

@enxebre enxebre Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use lower case by convention for api field docs so gdocs generation result in the serialized version of the field, i.e. "customKubeConfig"
Let's document what happens if I set and don't set this field day 1 and day 2.
E.g. "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.... When removed day 2...."

Is the underlying business logic tied with the .kubeAPIExternalName? If so let's have cel validation here to capture that. Also we can probably put both fields behind the same struct so we preserve the ability to organically grow this semantic.

we use "custom" term here but "external..." above can we consolidate on using a single one all the time.

// +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
15 changes: 15 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,12 @@ spec:
rule: self == oldSelf
- message: issuerURL must be a valid absolute URL
rule: isURL(self)
kubeApiExternalName:
description: kubeApiExternalName specifies the external name for the
Kube API Server service.
maxLength: 100
minLength: 1
type: string
networking:
default:
clusterNetwork:
Expand Down Expand Up @@ -4170,6 +4176,21 @@ spec:
- host
- port
type: object
customKubeConfig:
description: CustomKubeConfig specifies the name and key for the External
Custom kubeconfig secret
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,12 @@ spec:
rule: self == oldSelf
- message: issuerURL must be a valid absolute URL
rule: isURL(self)
kubeApiExternalName:
description: kubeApiExternalName specifies the external name for the
Kube API Server service.
maxLength: 100
minLength: 1
type: string
networking:
default:
clusterNetwork:
Expand Down Expand Up @@ -4415,6 +4421,21 @@ spec:
- host
- port
type: object
customKubeConfig:
description: CustomKubeConfig specifies the name and key for the External
Custom kubeconfig secret
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,12 @@ spec:
rule: self == oldSelf
- message: issuerURL must be a valid absolute URL
rule: isURL(self)
kubeApiExternalName:
description: kubeApiExternalName specifies the external name for the
Kube API Server service.
maxLength: 100
minLength: 1
type: string
networking:
default:
clusterNetwork:
Expand Down Expand Up @@ -4203,6 +4209,21 @@ spec:
- host
- port
type: object
customKubeConfig:
description: CustomKubeConfig specifies the name and key for the External
Custom kubeconfig secret
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,12 @@ spec:
rule: self == oldSelf
- message: issuerURL must be a valid absolute URL
rule: isURL(self)
kubeApiExternalName:
description: kubeApiExternalName specifies the external name for the
Kube API Server service.
maxLength: 100
minLength: 1
type: string
networking:
default:
clusterNetwork:
Expand Down Expand Up @@ -4179,6 +4185,21 @@ spec:
- host
- port
type: object
customKubeConfig:
description: CustomKubeConfig specifies the name and key for the External
Custom kubeconfig secret
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,12 @@ spec:
rule: self == oldSelf
- message: issuerURL must be a valid absolute URL
rule: isURL(self)
kubeApiExternalName:
description: kubeApiExternalName specifies the external name for the
Kube API Server service.
maxLength: 100
minLength: 1
type: string
networking:
default:
clusterNetwork:
Expand Down Expand Up @@ -4400,6 +4406,21 @@ spec:
- host
- port
type: object
customKubeConfig:
description: CustomKubeConfig specifies the name and key for the External
Custom kubeconfig secret
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,12 @@ spec:
rule: self == oldSelf
- message: issuerURL must be a valid absolute URL
rule: isURL(self)
kubeApiExternalName:
description: kubeApiExternalName specifies the external name for the
Kube API Server service.
maxLength: 100
minLength: 1
type: string
labels:
additionalProperties:
type: string
Expand Down Expand Up @@ -4171,6 +4177,21 @@ spec:
- host
- port
type: object
customKubeConfig:
description: CustomKubeConfig specifies the name and key for the External
Custom kubeconfig secret
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 @@ -2495,6 +2495,12 @@ spec:
rule: self == oldSelf
- message: issuerURL must be a valid absolute URL
rule: isURL(self)
kubeApiExternalName:
description: kubeApiExternalName specifies the external name for the
Kube API Server service.
maxLength: 100
minLength: 1
type: string
networking:
default:
clusterNetwork:
Expand Down Expand Up @@ -4310,6 +4316,21 @@ spec:
- host
- port
type: object
customKubeConfig:
description: CustomKubeConfig specifies the name and key for the External
Custom kubeconfig secret
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,12 @@ spec:
rule: self == oldSelf
- message: issuerURL must be a valid absolute URL
rule: isURL(self)
kubeApiExternalName:
description: kubeApiExternalName specifies the external name for the
Kube API Server service.
maxLength: 100
minLength: 1
type: string
networking:
default:
clusterNetwork:
Expand Down Expand Up @@ -4646,6 +4652,21 @@ spec:
- host
- port
type: object
customKubeConfig:
description: CustomKubeConfig specifies the name and key for the External
Custom kubeconfig secret
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