3

我正在使用带有以下附加组件的 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,"error":"Not Found","message":"Not Found"}
greg@sd-69380:~$ curl 10.152.183.15:8080/
{"statusCode":404,"error":"Not Found","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,"error":"Not Found","message":"Not Found"}
greg@sd-69380:~$ curl 10.152.183.15:8080/
{"statusCode":404,"error":"Not Found","message":"Not Found"}
greg@sd-69380:~$ curl 10.152.183.15:8080/
{"statusCode":404,"error":"Not Found","message":"Not Found"}
greg@sd-69380:~$ curl 10.152.183.15:8080/

所以,当我尝试使用 nginx 发出请求时,有时我会得到 502,因为 nginx 无法访问 API。

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

我很感激你能给我的任何帮助!

4

0 回答 0