From ab6e73ab8dd0b9352ba57e6be4fc2def4b1ad026 Mon Sep 17 00:00:00 2001 From: Mahdi Mohammadi Date: Fri, 27 Oct 2017 13:29:13 +0000 Subject: [PATCH] Use minikube context instead of relying on current kubcetl context --- pkg/minikube/service/service.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/minikube/service/service.go b/pkg/minikube/service/service.go index 5489dcc0a0d4..e5d69904f447 100644 --- a/pkg/minikube/service/service.go +++ b/pkg/minikube/service/service.go @@ -36,6 +36,7 @@ import ( "text/template" "k8s.io/apimachinery/pkg/labels" + clientcmdapi "k8s.io/client-go/tools/clientcmd/api" "k8s.io/minikube/pkg/minikube/cluster" "k8s.io/minikube/pkg/util" ) @@ -63,7 +64,12 @@ func (k *K8sClientGetter) GetCoreClient() (corev1.CoreV1Interface, error) { func (*K8sClientGetter) GetClientset() (*kubernetes.Clientset, error) { loadingRules := clientcmd.NewDefaultClientConfigLoadingRules() - configOverrides := &clientcmd.ConfigOverrides{} + configOverrides := &clientcmd.ConfigOverrides{ + Context: clientcmdapi.Context{ + Cluster: "minikube", + AuthInfo: "minikube", + }, + } kubeConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, configOverrides) config, err := kubeConfig.ClientConfig() if err != nil {