[英]Express-gateway config for Kubernetes services
Im trying to configure api-gateway for my micro service study.我正在尝试为我的微服务研究配置 api-gateway。 I created a pod as a auth-depl and auth-src service for this pod.我创建了一个 pod 作为该 pod 的 auth-depl 和 auth-src 服务。 Also I have another pod&service as links-depl and links-serv.我还有另一个 pod&service 作为 links-depl 和 links-serv。 And I want to make a api-gateway for.我想为它制作一个 api-gateway。 these services.这些服务。
The output for " kubeectl get pods" : “ kubeectl get pods”的 output :
NAME READY STATUS RESTARTS AGE
api-gateway-depl-88b4c8b77-zdgjw 1/1 Running 0 10m
auth-depl-7cb78c4dcf-wxrwd 1/1 Running 0 10m
links-depl-69d749955d-5xf9b 1/1 Running 0 6m3s
The output for " kubectl get services ": “ kubectl get services ”的 output:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
api-gateway-srv NodePort 10.98.213.62 <none> 8080:30623/TCP 12m
auth-srv ClusterIP 10.98.214.62 <none> 3000/TCP 12m
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 25h
links-srv ClusterIP 10.99.37.46 <none> 3001/TCP 12m
And my express-gateway config file like that:我的 express-gateway 配置文件是这样的:
http:
port: 8080
admin:
port: 9876
host: localhost
apiEndpoints:
api:
host: localhost
paths: '/ip'
user:
host: localhost
paths: '/user/signup'
serviceEndpoints:
httpbin:
url: 'https://httpbin.org'
usersrv:
url: 'http://auth-srv:3000/user/signup'
policies:
- basic-auth
- cors
- expression
- key-auth
- log
- oauth2
- proxy
- rate-limit
pipelines:
default:
apiEndpoints:
- api
policies:
- proxy:
- action:
serviceEndpoint: httpbin
changeOrigin: true
I just tried to reach auth service with api-gateway, but I cannot do this.我只是尝试使用 api-gateway 访问身份验证服务,但我不能这样做。 For this, I send this request:为此,我发送此请求:
POST http://localhost:30623/user/signup
and I get "Cannot POST /user/signup error我得到“无法发布/用户/注册错误
but when I send a request to GET http://localhost:30624/ip
I can receive the response.但是当我向GET http://localhost:30624/ip
发送请求时,我可以收到响应。
How can I configure this gateway.config.yaml file for solving my issue.如何配置此 gateway.config.yaml 文件来解决我的问题。
In Express Gateway, you need to have a pipeline defined for each of your ApiEndpoints.在 Express Gateway 中,您需要为每个 ApiEndpoint 定义一个管道。 You have a pipeline which maps the (outside-facing) "api" endpoint to the service endpoint "httpbin", but you are missing one to map the "user" endpoint to your signup endpoint.您有一个将(面向外部的)“api”端点映射到服务端点“httpbin”的管道,但是您缺少一个到 map 的“用户”端点到您的注册端点。
You need to add a pipeline for this to your "pipelines" section:您需要为此添加一个管道到您的“管道”部分:
pipelines:
# Existing "default" pipeline
user:
apiEndpoints:
- user
policies:
- proxy:
- action:
serviceEndpoint: usersrv
changeOrigin: true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.