Skip to content

Commit 1067870

Browse files
Merge pull request #8542 from r4f4/capi-kubeconfig-arg
OCPBUGS-35041: capi: do not override KUBECONFIG
2 parents d1e03dc + 26f988e commit 1067870

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pkg/clusterapi/system.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,13 @@ func (c *system) runController(ctx context.Context, ct *controller) error {
487487
templateData := map[string]string{
488488
"WebhookPort": fmt.Sprintf("%d", wh.LocalServingPort),
489489
"WebhookCertDir": wh.LocalServingCertDir,
490+
"KubeconfigPath": c.lcp.KubeconfigPath,
491+
}
492+
493+
// We cannot override KUBECONFIG, e.g., in case the user supplies a callback that needs to access the cluster,
494+
// such as via credential_process in the AWS config file. The kubeconfig path is set in the controller instead.
495+
if ct.Provider == nil || ct.Provider.Name != "azureaso" {
496+
ct.Args = append(ct.Args, "--kubeconfig={{.KubeconfigPath}}")
490497
}
491498

492499
args := make([]string, 0, len(ct.Args))
@@ -508,7 +515,10 @@ func (c *system) runController(ctx context.Context, ct *controller) error {
508515
ct.Env = map[string]string{}
509516
}
510517
// Override KUBECONFIG to point to the local control plane.
511-
ct.Env["KUBECONFIG"] = c.lcp.KubeconfigPath
518+
// azureaso doesn't support the --kubeconfig parameter.
519+
if ct.Provider != nil && ct.Provider.Name == "azureaso" {
520+
ct.Env["KUBECONFIG"] = c.lcp.KubeconfigPath
521+
}
512522
for key, value := range ct.Env {
513523
env = append(env, fmt.Sprintf("%s=%s", key, value))
514524
}

0 commit comments

Comments
 (0)