apache / apisix

The Cloud-Native API Gateway
https://apisix.apache.org/blog/
Apache License 2.0
14.58k stars 2.52k forks source link

help request: Cannot find upstream nodes in Kubernetes discovery #10251

Open liuzhiyong1982 opened 1 year ago

liuzhiyong1982 commented 1 year ago

Description

I deployed the APISIX from official Helm apisix chart v2.2.0. Below image is the overlay values for enabling Kubernetes service discovery. image

what I have done:

however, I still got 503 when I attempt to open the site and was told 'failed to set upstream: no valid upstream node: nil' image

Did I missed something?

Environment

shreemaan-abhishek commented 1 year ago

Did you configure the service_name in the following format?

function: nodes(service_name)

description: nodes() function attempts to look up the ngx.shared.DICT for nodes corresponding to servicename, \ servicename should match pattern: [namespace]/[name]:[portName]

ref: https://apisix.apache.org/docs/apisix/discovery/kubernetes/#single-cluster-mode-query-interface

liuzhiyong1982 commented 1 year ago

@shreemaan-abhishek , yes, I am using the right serivce_name format in apisix upstream setting.

image

image

monkeyDluffy6017 commented 11 months ago

@liuzhiyong1982 have you solved your problem?

ray1888 commented 10 months ago

want help also, meeting the same issue

rdouman commented 9 months ago

I just got stuck with this same issue. I managed to resolve this by using the port name defined for this service (http in my instance) as oppose to the port number ( 80 in your example above). I hope this helps :)

image

Snippet from the service definition: spec: ports:

From the manual: image

mozhata commented 6 months ago

met the same issue, the service not be set port name, then trying to use the port number, I get the same error log:

2024/05/16 09:14:23 [error] 386#386: *7955311 [lua] init.lua:548: handle_upstream(): failed to set upstream: no valid upstream node: nil, client: 10.77.101.0, server: _, request: "POST /xxx

additional: I set another route for a service which has port name, that succeed

mozhata commented 6 months ago

met the same issue, the service not be set port name, then trying to use the port number, I get the same error log:

2024/05/16 09:14:23 [error] 386#386: *7955311 [lua] init.lua:548: handle_upstream(): failed to set upstream: no valid upstream node: nil, client: 10.77.101.0, server: _, request: "POST /xxx

additional: I set another route for a service which has port name, that succeed

use target port number instead port number, fixed

Thilip707 commented 5 months ago

pls give example format for this target port number instead port number

luistilingue commented 4 months ago
apiVersion: apisix.apache.org/v2
kind: ApisixUpstream
metadata:
  name: httpbin-upstream
  namespace: default
spec:
  loadbalancer:
    type: ewma
  discovery:
    type: kubernetes
    serviceName: default/httpbin:http

that way works for me.