-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
I am using the go-zero gRPC resolver with the k8s scheme for service discovery. My connection target is configured as k8s://namespace/service:port.
The Problem In the current implementation of resolver/internal/kubebuilder.go, the kubeBuilder.Build method relies on rest.InClusterConfig() to initialize the Kubernetes client。
When I attempt to run or debug my gRPC client locally (outside of a Kubernetes cluster), the application fails with the following error because the required service account tokens and environment variables
(KUBERNETES_SERVICE_HOST/KUBERNETES_SERVICE_PORT) are missing:
unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined
The problem can be solved by directly connecting through the service domain. However, switching between the two configuration files is a bit troublesome. I would like to know how to solve this problem when I am debugging locally.