如何解决调用服务时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 举报,一经查实,本站将立刻删除。