From 36bc06c27a045bed9ad3c4a07a3687d94460d011 Mon Sep 17 00:00:00 2001 From: Quentin Bisson Date: Wed, 20 Sep 2023 16:17:13 +0200 Subject: [PATCH] Fix API Server url for Managed EKS (#1375) Signed-off-by: QuentinBisson --- CHANGELOG.md | 4 ++++ service/key/key.go | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 570ee5fc2..c178f6780 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Fix api server url in case the CAPI provider sets https prefix in the CAPI CR status. + ## [4.48.0] - 2023-09-19 ### Changed diff --git a/service/key/key.go b/service/key/key.go index 743cbed29..3b1f0781d 100644 --- a/service/key/key.go +++ b/service/key/key.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "math" + "strings" "github.com/giantswarm/k8sclient/v7/pkg/k8sclient" "github.com/giantswarm/microerror" @@ -272,7 +273,8 @@ func APIUrl(obj interface{}) string { case *v1.Service: return "kubernetes.default:443" case *capi.Cluster: - return fmt.Sprintf("%s:%d", v.Spec.ControlPlaneEndpoint.Host, v.Spec.ControlPlaneEndpoint.Port) + // We remove any https:// prefix from the api-server host due to a bug in CAPA Managed EKS clusters (cf. https://gigantic.slack.com/archives/C02HLSDH3DZ/p1695213116360889) + return fmt.Sprintf("%s:%d", strings.TrimPrefix(v.Spec.ControlPlaneEndpoint.Host, "https://"), v.Spec.ControlPlaneEndpoint.Port) case metav1.Object: return fmt.Sprintf("master.%s:443", v.GetName()) }