apache / apisix-go-plugin-runner

Go Plugin Runner for APISIX
https://apisix.apache.org/
Apache License 2.0
167 stars 69 forks source link

bug: 在K8S的Pod中无法获取K8S的配置 #111

Open a11enhuang opened 1 year ago

a11enhuang commented 1 year ago

apisix-go-plugin-runner中使用了client-go作为K8S客户端,尝试从K8SConfigMaps中获取配置数据,用来初始化插件。

APISIX-SERVER部署在GKE中,并且配置文件中也指定了执行Go插件

ext-plugin:
        cmd: ["/plugins/go-runner", "run"]

但是在集群中启动时无法获取K8S的配置信息。

初始化代码如下:

config, err := rest.InClusterConfig()
2022/10/28 02:51:23 [warn] 65#65: *186 [lua] init.lua:913: W1028 02:51:23.682992 1084 client_config.go:617] Neither --kubeconfig nor --master was specified. Using the inClusterConfig. This might not work.
--
Fri, Oct 28 2022 10:51:23 am | , context: ngx.timer
Fri, Oct 28 2022 10:51:23 am | 2022/10/28 02:51:23 [warn] 65#65: *186 [lua] init.lua:913: W1028 02:51:23.683029 1084 client_config.go:622] error creating inClusterConfig, falling back to default config: unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined
Fri, Oct 28 2022 10:51:23 am | , context: ngx.timer
Fri, Oct 28 2022 10:51:23 am | 2022/10/28 02:51:23 [warn] 65#65: *186 [lua] init.lua:913: panic: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
soulbird commented 1 year ago

Looks like this is a problem unrelated to apisix-go-plugin-runner. Try to troubleshoot possible causes based on this error log:

Neither --kubeconfig nor --master was specified. Using the inClusterConfig. This might not work.