Skip to content

Commit 7aaeedb

Browse files
authored
minikube: use cluster name to find minikube profile (#6528)
this ensures that if a user has renamed their kube context, we still find the right profile. fixes #6510 Signed-off-by: Nick Santos <[email protected]>
1 parent 7021574 commit 7aaeedb

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

internal/cli/wire_gen.go

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

internal/controllers/core/cluster/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ func KubernetesClientFromEnv(ctx context.Context, contextOverride k8s.KubeContex
5656
portForwardClient := k8s.ProvidePortForwardClient(restConfigOrError, clientsetOrError)
5757
namespace := k8s.ProvideConfigNamespace(clientConfig)
5858
kubeContext := k8s.ProvideKubeContext(apiConfigOrError)
59-
minikubeClient := k8s.ProvideMinikubeClient(kubeContext)
6059
clusterName := k8s.ProvideClusterName(apiConfigOrError)
60+
minikubeClient := k8s.ProvideMinikubeClient(clusterName)
6161
client := k8s.ProvideK8sClient(ctx, env, restConfigOrError, clientsetOrError, portForwardClient, kubeContext, clusterName, namespace, minikubeClient, apiConfigOrError, clientConfig)
6262
_, err := client.CheckConnected(ctx)
6363
if err != nil {

internal/k8s/minikube.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,17 @@ type MinikubeClient interface {
3232
}
3333

3434
type minikubeClient struct {
35-
context KubeContext
35+
// The minikube client needs to know which minikube profile to talk to.
36+
//
37+
// When minikube creates a cluster, it sets the kubeconfig context name and
38+
// the cluster nameto the name of the profile.
39+
//
40+
// The cluster name is better because users
41+
// don't usually rename it.
42+
context ClusterName
3643
}
3744

38-
func ProvideMinikubeClient(context KubeContext) MinikubeClient {
45+
func ProvideMinikubeClient(context ClusterName) MinikubeClient {
3946
return minikubeClient{context: context}
4047
}
4148

0 commit comments

Comments
 (0)