From 601009133a2ef085eac0656325c094af5bad0dfb Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Wed, 27 Sep 2023 14:09:27 +0200 Subject: [PATCH 1/4] remove enable OIDC issuer bootstrap step --- pkg/bootstrap/bootstrap.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pkg/bootstrap/bootstrap.go b/pkg/bootstrap/bootstrap.go index 9a0b07a0..1346146f 100644 --- a/pkg/bootstrap/bootstrap.go +++ b/pkg/bootstrap/bootstrap.go @@ -159,15 +159,6 @@ func getBootstrapSteps(runPlural ActionFunc, additionalFlags []string) ([]*Step, } }, }, - { - // TODO: Once https://github.com/kubernetes-sigs/cluster-api-provider-azure/issues/2498 - // will be done we can use it and remove this step. - Name: "Enable OIDC issuer", - Execute: func(_ []string) error { - return utils.Exec("az", "aks", "update", "-g", man.Project, "-n", man.Cluster, "--enable-oidc-issuer") - }, - Skip: man.Provider != api.ProviderAzure, - }, { Name: "Initialize kubeconfig for target cluster", Args: []string{"plural", "wkspace", "kube-init"}, From e229efebe2a6109dfa8dd5716a1cfba1d6bc28d9 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Thu, 28 Sep 2023 09:51:29 +0200 Subject: [PATCH 2/4] fix linter issues --- pkg/bootstrap/check.go | 1 - pkg/scaffold/helm.go | 4 ++-- pkg/utils/map.go | 13 +++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/bootstrap/check.go b/pkg/bootstrap/check.go index 8bb452c8..5a528ebd 100644 --- a/pkg/bootstrap/check.go +++ b/pkg/bootstrap/check.go @@ -64,7 +64,6 @@ func IsClusterPhase(context, name, namespace string, phase capi.ClusterPhase) (b return c.Status.GetTypedPhase() == phase, nil } - // CheckClusterReadiness checks if Cluster API cluster is in ready state. func CheckClusterReadiness(name, namespace string) (bool, error) { utils.Highlight("Checking cluster status") diff --git a/pkg/scaffold/helm.go b/pkg/scaffold/helm.go index 0f9eb373..ecb2240a 100644 --- a/pkg/scaffold/helm.go +++ b/pkg/scaffold/helm.go @@ -222,8 +222,8 @@ func (s *Scaffold) buildChartValues(w *wkspace.Workspace) error { } // TODO: Remove this after testing. It is deprecated as values.yaml migration should not longer be required. - //mapValues, err := getValues(valuesFile) - //if err != nil { + // mapValues, err := getValues(valuesFile) + // if err != nil { // return err //} //patchValues, err := utils.PatchInterfaceMap(defaultValues, mapValues) diff --git a/pkg/utils/map.go b/pkg/utils/map.go index e20b5727..787bf2f2 100644 --- a/pkg/utils/map.go +++ b/pkg/utils/map.go @@ -94,9 +94,10 @@ var ( // if needed by passing custom DiffCondition function. // // Example: -// A: {a: 1, b: 1, c: 2} -// B: {a: 1, d: 2, c: 3} -// Result: {b: 1, c: 2} +// +// A: {a: 1, b: 1, c: 2} +// B: {a: 1, d: 2, c: 3} +// Result: {b: 1, c: 2} // // Note: It does not remove null value keys by default. func DiffMap(base, diff map[string]interface{}, conditions ...DiffCondition) map[string]interface{} { @@ -108,17 +109,17 @@ func DiffMap(base, diff map[string]interface{}, conditions ...DiffCondition) map } for k, v := range base { - switch v.(type) { + switch f := v.(type) { case map[string]interface{}: dValue, _ := diff[k].(map[string]interface{}) - if dMap := DiffMap(v.(map[string]interface{}), dValue, conditions...); len(dMap) > 0 { + if dMap := DiffMap(f, dValue, conditions...); len(dMap) > 0 { result[k] = dMap break } delete(result, k) default: - diffV, _ := diff[k] + diffV := diff[k] for _, condition := range append(conditions, equalDiffCondition) { if condition(k, v, diffV) { delete(result, k) From a3a0a6d50f796f9ffb728f3ecb0a44bcdb926fc4 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Wed, 4 Oct 2023 18:24:09 +0200 Subject: [PATCH 3/4] update bootstrapMode flags --- pkg/bootstrap/common.go | 1 + pkg/bootstrap/migrate.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/pkg/bootstrap/common.go b/pkg/bootstrap/common.go index bad08176..26063478 100644 --- a/pkg/bootstrap/common.go +++ b/pkg/bootstrap/common.go @@ -147,6 +147,7 @@ func getBootstrapFlags(prov string) []string { case api.ProviderAzure: return []string{ "--set", "cluster-api-cluster.cluster.azure.clusterIdentity.bootstrapMode=true", + "--set", "cluster-api-provider-azure.cluster-api-provider-azure.bootstrapMode=true", "--set", "bootstrap.external-dns.enabled=false", "--set", "plural-certmanager-webhook.enabled=false", } diff --git a/pkg/bootstrap/migrate.go b/pkg/bootstrap/migrate.go index 6be1bbcc..98325fbc 100644 --- a/pkg/bootstrap/migrate.go +++ b/pkg/bootstrap/migrate.go @@ -243,6 +243,10 @@ func getMigrationFlags(prov string) []string { return []string{ "--set", "cluster-api-provider-aws.cluster-api-provider-aws.bootstrapMode=false", } + case api.ProviderAzure: + return []string{ + "--set", "cluster-api-provider-azure.cluster-api-provider-azure.bootstrapMode=false", + } case api.ProviderGCP: return []string{ "--set", "cluster-api-provider-gcp.cluster-api-provider-gcp.bootstrapMode=false", From ad5af3c297004e816bcdce8828b79b6c2e35f237 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Thu, 5 Oct 2023 12:24:36 +0200 Subject: [PATCH 4/4] update asoControllerSettings --- pkg/bootstrap/common.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/bootstrap/common.go b/pkg/bootstrap/common.go index 26063478..e2ecefb3 100644 --- a/pkg/bootstrap/common.go +++ b/pkg/bootstrap/common.go @@ -281,9 +281,12 @@ func RunWithTempCredentials(function ActionFunc) error { } pathPrefix := "cluster-api-cluster.cluster.azure.clusterIdentity.bootstrapCredentials" + asoPathPrefix := "cluster-api-provider-azure.cluster-api-provider-azure.asoControllerSettings" flags = []string{ "--set", fmt.Sprintf("%s.%s=%s", pathPrefix, "clientID", clientId), "--set", fmt.Sprintf("%s.%s=%s", pathPrefix, "clientSecret", clientSecret), + "--set", fmt.Sprintf("%s.%s=%s", asoPathPrefix, "azureClientId", clientId), + "--set", fmt.Sprintf("%s.%s=%s", asoPathPrefix, "azureClientSecret", clientSecret), } defer func(as *azure.AuthService) {