调用服务时MicroK8s Metallb随机错误

问题描述

我正在使用带有以下附加组件的microk8s使用scaleway机器(4cpu和8g内存)来建立一个k8s集群:

microk8s is running
high-availability: no
addons:
  enabled:
    dns                  # coredns
    helm3                # Helm 3 - Kubernetes package manager
    registry             # Private image registry exposed on localhost:32000
    storage              # Storage class; allocates storage from host directory
    Metallb              # Loadbalancer for your Kubernetes cluster

我使用helm部署了nodejs express API,并使用kubectl port forward

对其进行了测试。

现在,我正在尝试使用Metallb从Nginx进行访问,因此我部署了服务,然后得到以下信息:

my-api-service              LoadBalancer   10.152.183.14    10.64.140.43     8080:32668/TCP   34m

但是当我尝试通过服务访问它时:

  • 在禁用Metallb插件的情况下:我可以通过clusterIp访问它
  • 启用了Metallb插件:我可以通过externalIp访问它,但有时会重置连接:
greg@sd-69380:~$ curl 10.152.183.15:8080/
{"statusCode":404,"error":"Not Found","message":"Not Found"} # The API return a 404,excepted behavior
greg@sd-69380:~$ curl 10.152.183.15:8080/
{"statusCode":404,"message":"Not Found"}
greg@sd-69380:~$ curl 10.152.183.15:8080/
{"statusCode":404,"message":"Not Found"}
greg@sd-69380:~$ curl 10.152.183.15:8080/
curl: (7) Failed to connect to 10.152.183.15 port 8080: Connection refused # This is the problem
{"statusCode":404,"message":"Not Found"}
greg@sd-69380:~$ curl 10.152.183.15:8080/

因此,当我尝试使用Nginx发出请求时,有时会收到502,因为Nginx无法访问API。

使用端口转发时我没有问题,因此问题不在API端。

感谢您能给我任何帮助!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)