alibaba / nacos

an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
https://nacos.io
Apache License 2.0
30.33k stars 12.85k forks source link

Using ingress as nacos load balancing error reporting, current status: STARTING #11664

Closed zjf88865 closed 9 months ago

zjf88865 commented 10 months ago

Describe the bug A clear and concise description of what the bug is.

Expected behavior A clear and concise description of what you expected to happen.

I used the official k8s to build a nacos cluster, which is located in git clone https://github.com/nacos-group/nacos-k8s.git. When I built it successfully, I used ingress to map it to a domain name, nacos .corp.com, and forward 8848 to port 80, and I configured my DNS server so that I can access nacos.corp.com through ping and curl for load balancing.

Actually behavior A clear and concise description of what you actually to happen.

But when my program is linked up, it keeps reporting an error: com.alibaba.nacos.api.exception.NacosException: Client not connected, current status:STARTING com.alibaba.nacos.api.exception.NacosException: Client not connected, current status:STARTING

How to Reproduce Steps to reproduce the behavior:

  1. git clone https://github.com/nacos-group/nacos-k8s.git 2 .cd nacos-k8s chmod +x quick-startup.sh ./quick-startup.sh 3.Then you will see that my k8s nacos cluster was successfully built.
  2. vi ingress.ymal apiVersion: networking.k8s.io/v1 kind: Ingress metadata: creationTimestamp: '2024-01-13T08:12:25Z' generation: 1 managedFields:
    • apiVersion: networking.k8s.io/v1 name: ingress-nacos namespace: all-pre-cluster spec: defaultBackend: service: name: nacos-headless port: number: 8848 ingressClassName: nginx rules:
    • host: nacos.corp.com http: paths:
      • backend: service: name: nacos-headless port: number: 8848 path: / pathType: Prefix status: loadBalancer: {}
  3. kubectl apply -f ingress.ymal
  4. Then my program uses this ingress link, and my code configuration is as follows server: port: 8080 servlet: context-path: /test-demo spring: profiles: active: prod application: name: test-demo

    nacos配置

    cloud: nacos: server-addr: nacos.corp.com config: file-extension: yml namespace: ${spring.profiles.active} group: prod discovery: service: ${spring.application.name} namespace: ${spring.profiles.active} group: prod

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

I saw online that since grpc was added in version 2, what should I do to solve this problem? Because I want to use ingress as my balanced load. Of course, I don’t have to worry about security issues because we use double-layer nginx. Exposing nacos to the public network

KomachiSion commented 10 months ago

see https://nacos.io/docs/latest/upgrading/200-compatibility/

2.X need more ports such as 9848.

zjf88865 commented 10 months ago

see https://nacos.io/docs/latest/upgrading/200-compatibility/

2.X need more ports such as 9848. What do I need to do? I want my ingress to be used as a load balancer. How can I change port 9848 to 443 in my program? I want to connect 9848. Does 9848 have to be connected via socket stream? How do I hang 9848 on port 443 to ingress?

KomachiSion commented 10 months ago

8848 is http port for console and nacos 1.x client. 9848 is grpc port for nacos 2.x client.

you should export the two ports let your app connect.

the document show the ports relationship with the main port which can be set in application.properties in nacos-server. and also show how you can do the port transfer by vip/slb. Maybe you should understand them and deploy in your env.

zjf88865 commented 9 months ago

8848 is http port for console and nacos 1.x client. 9848 is grpc port for nacos 2.x client.

you should export the two ports let your app connect.

the document show the ports relationship with the main port which can be set in application.properties in nacos-server. and also show how you can do the port transfer by vip/slb. Maybe you should understand them and deploy in your env.

  1. I want to modify 9848 in my program, but I haven't seen any cases in the official documentation

  2. I want to convert my ingress into an SLB and make 9848 one of the ports mapped to the ingress because I don't want to add another machine, which will increase my architecture complexity, operation and maintenance costs, and hardware machine costs

KomachiSion commented 9 months ago
  1. client and server 9848 port is calculate from main port, default 8848. When you set your server.port in nacos-server as 8848, the grpc port is 9848, and if server.port is 4000, the grpc port is 5000. Same with client, such as server-addr=xxxx:4000 the main port is 4000 and the grpc port is 5000. It describes in document.

  2. you can set your slb transfer port like 1443 to 9848. And 443 to 8848.

KomachiSion commented 9 months ago

No more response from author, It seems usage problem.

freshgeek commented 2 months ago

2. you can set your slb transfer port like 1443 to 9848. And 443 to 8848.

Is there a sample code reference for this step?