func getKubernetesClient() (kubernetes.Interface, policiesClientSet.Interface, error) {
	config, err := getKubeConfig()
	if err != nil {
		zap.L().Fatal("Error creating a cluster config", zap.Error(err))
		return nil, nil, err
	}
	client, err := kubernetes.NewForConfig(config)
	if err != nil {
		zap.L().Fatal("Error creating a client set", zap.Error(err))
		return nil, nil, err
	}
	policiesClient, err := policiesClientSet.NewForConfig(config)
	if err != nil {
		zap.L().Fatal("Error creating a NewForConfig", zap.Error(err))
		return nil, nil, err
	}
	zap.L().Info("Successfully constructed k8s client")
	return client, policiesClient, nil
}
retrieve the Kubernetes cluster client from outside of the cluster
package initializer
import (
	"os"
	"os/signal"
	"syscall"
	"go.uber.org/zap"
	"github.com/ibm-cloud-security/app-identity-and-access-adapter/adapter/policy/store/policy"
	"k8s.io/client-go/kubernetes"
	_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
	"k8s.io/client-go/rest"
	"k8s.io/client-go/tools/cache"
	"k8s.io/client-go/tools/clientcmd"
	"k8s.io/client-go/util/workqueue"
	v1 "github.com/ibm-cloud-security/app-identity-and-access-adapter/adapter/pkg/apis/policies/v1"
	policiesClientSet "github.com/ibm-cloud-security/app-identity-and-access-adapter/adapter/pkg/client/clientset/versioned"
	policiesInformer "github.com/ibm-cloud-security/app-identity-and-access-adapter/adapter/pkg/client/informers/externalversions"
	policyController "github.com/ibm-cloud-security/app-identity-and-access-adapter/adapter/policy/controller"
	"github.com/ibm-cloud-security/app-identity-and-access-adapter/adapter/policy/handler"
)
type Initializer interface {
	GetHandler() handler.PolicyHandler
	GetKubeClient() kubernetes.Interface
}
type PolicyInitializer struct {
	KubeClient kubernetes.Interface
	Handler    handler.PolicyHandler
}
func (pi *PolicyInitializer) GetKubeClient() kubernetes.Interface {
	return pi.KubeClient
}
func (pi *PolicyInitializer) GetHandler() handler.PolicyHandler {
	return pi.Handler
}
func New(store policy.PolicyStore) (Initializer, error) {
	client, myresourceClient, err := getKubernetesClient()
	if err != nil {
		return nil, err
	}
	handler := handler.New(store, client)
	policyInitializer := &PolicyInitializer{Handler: handler, KubeClient: client}
	informerlist := policiesInformer.NewSharedInformerFactory(myresourceClient, 0)
	go initPolicyController(informerlist.Appid().V1().JwtConfigs().Informer(), client, policyInitializer.Handler, v1.JWTCONFIG)
	go initPolicyController(informerlist.Appid().V1().OidcConfigs().Informer(), client, policyInitializer.Handler, v1.OIDCCONFIG)
	go initPolicyController(informerlist.Appid().V1().Policies().Informer(), client, policyInitializer.Handler, v1.POLICY)
	return policyInitializer, nil
}
func getKubeConfig() (*rest.Config, error) {
	config, err := rest.InClusterConfig()
	if err != nil {
		zap.L().Warn("Error creating an in-cluster config. Attempting local config...", zap.Error(err))
		kubeConfigPath := os.Getenv("KUBECONFIG")
		if kubeConfigPath != "" {
			zap.L().Info("Using KubeConfig : " + kubeConfigPath)
		} else {
			zap.L().Info("Attempting to use minikube : " + os.Getenv("HOME"))
			kubeConfigPath = os.Getenv("HOME") + "/.kube/config"
		}
		config, err = clientcmd.BuildConfigFromFlags("", kubeConfigPath)
		if err != nil {
			zap.L().Error("Could not create local config", zap.Error(err))
			return nil, err
		}
	}
	return config, nil
}