apache / apisix

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

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

Open liuzhiyong1982 opened 11 months ago

liuzhiyong1982 commented 11 months 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 11 months 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 11 months ago

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

image

image

monkeyDluffy6017 commented 8 months ago

@liuzhiyong1982 have you solved your problem?

ray1888 commented 7 months ago

want help also, meeting the same issue

rdouman commented 7 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 3 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 3 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 2 months ago

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

luistilingue commented 1 month 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.