From 5aaf06c94502cc2d0b4bd4a0176d3b6a04190c0d Mon Sep 17 00:00:00 2001 From: Venkatreddy KP Date: Mon, 12 Jun 2023 21:00:37 +0530 Subject: [PATCH] fix k8s client init --- internal/client/k8s.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/internal/client/k8s.go b/internal/client/k8s.go index 8839b3f9..5699a412 100644 --- a/internal/client/k8s.go +++ b/internal/client/k8s.go @@ -2,7 +2,6 @@ package client import ( "context" - "path/filepath" "strings" "github.com/intelops/go-common/logging" @@ -10,8 +9,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" - "k8s.io/client-go/tools/clientcmd" - "k8s.io/client-go/util/homedir" + "k8s.io/client-go/rest" ) type K8SClient struct { @@ -20,11 +18,7 @@ type K8SClient struct { } func NewK8SClient(log logging.Logger) (*K8SClient, error) { - var kubeconfig string - if home := homedir.HomeDir(); home != "" { - kubeconfig = filepath.Join(home, ".kube", "config") - } - config, err := clientcmd.BuildConfigFromFlags("", kubeconfig) + config, err := rest.InClusterConfig() if err != nil { return nil, err }