Skip to content

Commit 90afcc8

Browse files
committed
HOSTEDCP-1960: Add KubeAPIExteralName api
This new API changes the value of the Kubeconfig External URL to points to your desired one Signed-off-by: Juan Manuel Parrilla Madrid <jparrill@redhat.com>
1 parent 7c9455f commit 90afcc8

32 files changed

+259
-11
lines changed

Diff for: api/hypershift/v1beta1/hosted_controlplane.go

+6
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ type HostedControlPlaneSpec struct {
115115
// +optional
116116
KubeConfig *KubeconfigSecretRef `json:"kubeconfig,omitempty"`
117117

118+
// kubeApiExternalName specifies the external name for the Kube API Server service.
119+
// +kubebuilder:validation:MaxLength=100
120+
// +kubebuilder:validation:MinLength=1
121+
// +optional
122+
KubeAPIExternalName string `json:"kubeApiExternalName,omitempty"`
123+
118124
// Services defines metadata about how control plane services are published
119125
// in the management cluster.
120126
// +kubebuilder:validation:MaxItems=6

Diff for: api/hypershift/v1beta1/hostedcluster_types.go

+6
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,12 @@ type HostedClusterSpec struct {
432432
// +required
433433
Platform PlatformSpec `json:"platform"`
434434

435+
// kubeApiExternalName specifies the external name for the Kube API Server service.
436+
// +kubebuilder:validation:MaxLength=100
437+
// +kubebuilder:validation:MinLength=1
438+
// +optional
439+
KubeAPIExternalName string `json:"kubeApiExternalName,omitempty"`
440+
435441
// controllerAvailabilityPolicy specifies the availability policy applied to critical control plane components like the Kube API Server.
436442
// Possible values are HighlyAvailable and SingleReplica. The default value is HighlyAvailable.
437443
// +optional

Diff for: api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/AAA_ungated.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2347,6 +2347,12 @@ spec:
23472347
rule: self == oldSelf
23482348
- message: issuerURL must be a valid absolute URL
23492349
rule: isURL(self)
2350+
kubeApiExternalName:
2351+
description: kubeApiExternalName specifies the external name for the
2352+
Kube API Server service.
2353+
maxLength: 100
2354+
minLength: 1
2355+
type: string
23502356
networking:
23512357
default:
23522358
clusterNetwork:

Diff for: api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/AROHCPManagedIdentities.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2343,6 +2343,12 @@ spec:
23432343
rule: self == oldSelf
23442344
- message: issuerURL must be a valid absolute URL
23452345
rule: isURL(self)
2346+
kubeApiExternalName:
2347+
description: kubeApiExternalName specifies the external name for the
2348+
Kube API Server service.
2349+
maxLength: 100
2350+
minLength: 1
2351+
type: string
23462352
networking:
23472353
default:
23482354
clusterNetwork:

Diff for: api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/AutoNodeKarpenter.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2388,6 +2388,12 @@ spec:
23882388
rule: self == oldSelf
23892389
- message: issuerURL must be a valid absolute URL
23902390
rule: isURL(self)
2391+
kubeApiExternalName:
2392+
description: kubeApiExternalName specifies the external name for the
2393+
Kube API Server service.
2394+
maxLength: 100
2395+
minLength: 1
2396+
type: string
23912397
networking:
23922398
default:
23932399
clusterNetwork:

Diff for: api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/DynamicResourceAllocation.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2364,6 +2364,12 @@ spec:
23642364
rule: self == oldSelf
23652365
- message: issuerURL must be a valid absolute URL
23662366
rule: isURL(self)
2367+
kubeApiExternalName:
2368+
description: kubeApiExternalName specifies the external name for the
2369+
Kube API Server service.
2370+
maxLength: 100
2371+
minLength: 1
2372+
type: string
23672373
networking:
23682374
default:
23692375
clusterNetwork:

Diff for: api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/ExternalOIDC.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2585,6 +2585,12 @@ spec:
25852585
rule: self == oldSelf
25862586
- message: issuerURL must be a valid absolute URL
25872587
rule: isURL(self)
2588+
kubeApiExternalName:
2589+
description: kubeApiExternalName specifies the external name for the
2590+
Kube API Server service.
2591+
maxLength: 100
2592+
minLength: 1
2593+
type: string
25882594
networking:
25892595
default:
25902596
clusterNetwork:

Diff for: api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/HCPPodsLabels.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2343,6 +2343,12 @@ spec:
23432343
rule: self == oldSelf
23442344
- message: issuerURL must be a valid absolute URL
23452345
rule: isURL(self)
2346+
kubeApiExternalName:
2347+
description: kubeApiExternalName specifies the external name for the
2348+
Kube API Server service.
2349+
maxLength: 100
2350+
minLength: 1
2351+
type: string
23462352
labels:
23472353
additionalProperties:
23482354
type: string

Diff for: api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/NetworkDiagnosticsConfig.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2495,6 +2495,12 @@ spec:
24952495
rule: self == oldSelf
24962496
- message: issuerURL must be a valid absolute URL
24972497
rule: isURL(self)
2498+
kubeApiExternalName:
2499+
description: kubeApiExternalName specifies the external name for the
2500+
Kube API Server service.
2501+
maxLength: 100
2502+
minLength: 1
2503+
type: string
24982504
networking:
24992505
default:
25002506
clusterNetwork:

Diff for: api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedclusters.hypershift.openshift.io/OpenStack.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2343,6 +2343,12 @@ spec:
23432343
rule: self == oldSelf
23442344
- message: issuerURL must be a valid absolute URL
23452345
rule: isURL(self)
2346+
kubeApiExternalName:
2347+
description: kubeApiExternalName specifies the external name for the
2348+
Kube API Server service.
2349+
maxLength: 100
2350+
minLength: 1
2351+
type: string
23462352
networking:
23472353
default:
23482354
clusterNetwork:

Diff for: api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/AAA_ungated.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2245,6 +2245,12 @@ spec:
22452245
default value is kubernetes.default.svc, which only works for in-cluster
22462246
validation.
22472247
type: string
2248+
kubeApiExternalName:
2249+
description: kubeApiExternalName specifies the external name for the
2250+
Kube API Server service.
2251+
maxLength: 100
2252+
minLength: 1
2253+
type: string
22482254
kubeconfig:
22492255
description: KubeConfig specifies the name and key for the kubeconfig
22502256
secret

Diff for: api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/AROHCPManagedIdentities.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2241,6 +2241,12 @@ spec:
22412241
default value is kubernetes.default.svc, which only works for in-cluster
22422242
validation.
22432243
type: string
2244+
kubeApiExternalName:
2245+
description: kubeApiExternalName specifies the external name for the
2246+
Kube API Server service.
2247+
maxLength: 100
2248+
minLength: 1
2249+
type: string
22442250
kubeconfig:
22452251
description: KubeConfig specifies the name and key for the kubeconfig
22462252
secret

Diff for: api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/AutoNodeKarpenter.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2286,6 +2286,12 @@ spec:
22862286
default value is kubernetes.default.svc, which only works for in-cluster
22872287
validation.
22882288
type: string
2289+
kubeApiExternalName:
2290+
description: kubeApiExternalName specifies the external name for the
2291+
Kube API Server service.
2292+
maxLength: 100
2293+
minLength: 1
2294+
type: string
22892295
kubeconfig:
22902296
description: KubeConfig specifies the name and key for the kubeconfig
22912297
secret

Diff for: api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/DynamicResourceAllocation.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2262,6 +2262,12 @@ spec:
22622262
default value is kubernetes.default.svc, which only works for in-cluster
22632263
validation.
22642264
type: string
2265+
kubeApiExternalName:
2266+
description: kubeApiExternalName specifies the external name for the
2267+
Kube API Server service.
2268+
maxLength: 100
2269+
minLength: 1
2270+
type: string
22652271
kubeconfig:
22662272
description: KubeConfig specifies the name and key for the kubeconfig
22672273
secret

Diff for: api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/ExternalOIDC.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2483,6 +2483,12 @@ spec:
24832483
default value is kubernetes.default.svc, which only works for in-cluster
24842484
validation.
24852485
type: string
2486+
kubeApiExternalName:
2487+
description: kubeApiExternalName specifies the external name for the
2488+
Kube API Server service.
2489+
maxLength: 100
2490+
minLength: 1
2491+
type: string
24862492
kubeconfig:
24872493
description: KubeConfig specifies the name and key for the kubeconfig
24882494
secret

Diff for: api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/NetworkDiagnosticsConfig.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2393,6 +2393,12 @@ spec:
23932393
default value is kubernetes.default.svc, which only works for in-cluster
23942394
validation.
23952395
type: string
2396+
kubeApiExternalName:
2397+
description: kubeApiExternalName specifies the external name for the
2398+
Kube API Server service.
2399+
maxLength: 100
2400+
minLength: 1
2401+
type: string
23962402
kubeconfig:
23972403
description: KubeConfig specifies the name and key for the kubeconfig
23982404
secret

Diff for: api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/hostedcontrolplanes.hypershift.openshift.io/OpenStack.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2241,6 +2241,12 @@ spec:
22412241
default value is kubernetes.default.svc, which only works for in-cluster
22422242
validation.
22432243
type: string
2244+
kubeApiExternalName:
2245+
description: kubeApiExternalName specifies the external name for the
2246+
Kube API Server service.
2247+
maxLength: 100
2248+
minLength: 1
2249+
type: string
22442250
kubeconfig:
22452251
description: KubeConfig specifies the name and key for the kubeconfig
22462252
secret

Diff for: client/applyconfiguration/hypershift/v1beta1/hostedclusterspec.go

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: client/applyconfiguration/hypershift/v1beta1/hostedcontrolplanespec.go

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: cmd/install/assets/hypershift-operator/zz_generated.crd-manifests/hostedclusters-CustomNoUpgrade.crd.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2806,6 +2806,12 @@ spec:
28062806
rule: self == oldSelf
28072807
- message: issuerURL must be a valid absolute URL
28082808
rule: isURL(self)
2809+
kubeApiExternalName:
2810+
description: kubeApiExternalName specifies the external name for the
2811+
Kube API Server service.
2812+
maxLength: 100
2813+
minLength: 1
2814+
type: string
28092815
labels:
28102816
additionalProperties:
28112817
type: string

Diff for: cmd/install/assets/hypershift-operator/zz_generated.crd-manifests/hostedclusters-Default.crd.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2761,6 +2761,12 @@ spec:
27612761
rule: self == oldSelf
27622762
- message: issuerURL must be a valid absolute URL
27632763
rule: isURL(self)
2764+
kubeApiExternalName:
2765+
description: kubeApiExternalName specifies the external name for the
2766+
Kube API Server service.
2767+
maxLength: 100
2768+
minLength: 1
2769+
type: string
27642770
networking:
27652771
default:
27662772
clusterNetwork:

Diff for: cmd/install/assets/hypershift-operator/zz_generated.crd-manifests/hostedclusters-TechPreviewNoUpgrade.crd.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2806,6 +2806,12 @@ spec:
28062806
rule: self == oldSelf
28072807
- message: issuerURL must be a valid absolute URL
28082808
rule: isURL(self)
2809+
kubeApiExternalName:
2810+
description: kubeApiExternalName specifies the external name for the
2811+
Kube API Server service.
2812+
maxLength: 100
2813+
minLength: 1
2814+
type: string
28092815
labels:
28102816
additionalProperties:
28112817
type: string

Diff for: cmd/install/assets/hypershift-operator/zz_generated.crd-manifests/hostedcontrolplanes-CustomNoUpgrade.crd.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2704,6 +2704,12 @@ spec:
27042704
default value is kubernetes.default.svc, which only works for in-cluster
27052705
validation.
27062706
type: string
2707+
kubeApiExternalName:
2708+
description: kubeApiExternalName specifies the external name for the
2709+
Kube API Server service.
2710+
maxLength: 100
2711+
minLength: 1
2712+
type: string
27072713
kubeconfig:
27082714
description: KubeConfig specifies the name and key for the kubeconfig
27092715
secret

Diff for: cmd/install/assets/hypershift-operator/zz_generated.crd-manifests/hostedcontrolplanes-Default.crd.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2659,6 +2659,12 @@ spec:
26592659
default value is kubernetes.default.svc, which only works for in-cluster
26602660
validation.
26612661
type: string
2662+
kubeApiExternalName:
2663+
description: kubeApiExternalName specifies the external name for the
2664+
Kube API Server service.
2665+
maxLength: 100
2666+
minLength: 1
2667+
type: string
26622668
kubeconfig:
26632669
description: KubeConfig specifies the name and key for the kubeconfig
26642670
secret

Diff for: cmd/install/assets/hypershift-operator/zz_generated.crd-manifests/hostedcontrolplanes-TechPreviewNoUpgrade.crd.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2704,6 +2704,12 @@ spec:
27042704
default value is kubernetes.default.svc, which only works for in-cluster
27052705
validation.
27062706
type: string
2707+
kubeApiExternalName:
2708+
description: kubeApiExternalName specifies the external name for the
2709+
Kube API Server service.
2710+
maxLength: 100
2711+
minLength: 1
2712+
type: string
27072713
kubeconfig:
27082714
description: KubeConfig specifies the name and key for the kubeconfig
27092715
secret

Diff for: control-plane-operator/controllers/hostedcontrolplane/hostedcontrolplane_controller.go

+20-6
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,12 @@ func (r *HostedControlPlaneReconciler) reconcile(ctx context.Context, hostedCont
11111111
// Reconcile kube apiserver
11121112
r.Log.Info("Reconciling Kube API Server")
11131113
kubeAPIServerDeployment := manifests.KASDeployment(hostedControlPlane.Namespace)
1114-
if err := r.reconcileKubeAPIServer(ctx, hostedControlPlane, releaseImageProvider, userReleaseImageProvider, infraStatus.APIHost, infraStatus.APIPort, infraStatus.OAuthHost, infraStatus.OAuthPort, createOrUpdate, kubeAPIServerDeployment); err != nil {
1114+
apiAddress := infraStatus.APIHost
1115+
if len(hostedControlPlane.Spec.KubeAPIExternalName) > 0 {
1116+
apiAddress = hostedControlPlane.Spec.KubeAPIExternalName
1117+
}
1118+
1119+
if err := r.reconcileKubeAPIServer(ctx, hostedControlPlane, releaseImageProvider, userReleaseImageProvider, apiAddress, infraStatus.APIPort, infraStatus.OAuthHost, infraStatus.OAuthPort, createOrUpdate, kubeAPIServerDeployment); err != nil {
11151120
return fmt.Errorf("failed to reconcile kube apiserver: %w", err)
11161121
}
11171122

@@ -2977,14 +2982,23 @@ func (r *HostedControlPlaneReconciler) reconcileKubeAPIServer(ctx context.Contex
29772982
return fmt.Errorf("failed to reconcile localhost kubeconfig secret: %w", err)
29782983
}
29792984

2980-
externalKubeconfigSecret := manifests.KASExternalKubeconfigSecret(hcp.Namespace, hcp.Spec.KubeConfig)
2981-
if _, err := createOrUpdate(ctx, r, externalKubeconfigSecret, func() error {
2985+
if util.IsExtApiSet(hcp) {
2986+
externalKubeconfigSecret := manifests.KASExternalKubeconfigSecret(hcp.Namespace, hcp.Spec.KubeConfig)
2987+
if _, err := createOrUpdate(ctx, r, externalKubeconfigSecret, func() error {
2988+
return kas.ReconcileExternalKubeconfigSecret(externalKubeconfigSecret, clientCertSecret, rootCA, p.OwnerRef, p.ExternalURL(), p.ExternalKubeconfigKey())
2989+
}); err != nil {
2990+
return fmt.Errorf("failed to reconcile external kubeconfig secret: %w", err)
2991+
}
2992+
}
2993+
2994+
internalKubeconfigSecret := manifests.KASInternalKubeconfigSecret(hcp.Namespace, hcp.Spec.KubeConfig)
2995+
if _, err := createOrUpdate(ctx, r, internalKubeconfigSecret, func() error {
29822996
if !util.IsPublicHCP(hcp) && !util.IsRouteKAS(hcp) {
2983-
return kas.ReconcileExternalKubeconfigSecret(externalKubeconfigSecret, clientCertSecret, rootCA, p.OwnerRef, p.InternalURL(), p.ExternalKubeconfigKey())
2997+
return kas.ReconcileExternalKubeconfigSecret(internalKubeconfigSecret, clientCertSecret, rootCA, p.OwnerRef, p.InternalURL(), p.ExternalKubeconfigKey())
29842998
}
2985-
return kas.ReconcileExternalKubeconfigSecret(externalKubeconfigSecret, clientCertSecret, rootCA, p.OwnerRef, p.ExternalURL(), p.ExternalKubeconfigKey())
2999+
return kas.ReconcileExternalKubeconfigSecret(internalKubeconfigSecret, clientCertSecret, rootCA, p.OwnerRef, p.ExternalURL(), p.ExternalKubeconfigKey())
29863000
}); err != nil {
2987-
return fmt.Errorf("failed to reconcile external kubeconfig secret: %w", err)
3001+
return fmt.Errorf("failed to reconcile internal kubeconfig secret: %w", err)
29883002
}
29893003

29903004
bootstrapKubeconfigSecret := manifests.KASBootstrapKubeconfigSecret(hcp.Namespace)

0 commit comments

Comments
 (0)