Kong 服务和路由的添加

管理服务

这里参考DB-less-Mode,因为使用的是yaml配置文件的形式,所以所有的相关配置只需要往初始化的kong.yml文件中添加就可以了,就像nginx的配置文件

DB-less-Mode

创建服务

vim /etc/kong/kong.yml

yaml 复制代码
services:
- name: my-service  # 服务名称
  url: localhost:8801  # 这里填写backend服务地址
  tags:
   - test-service
  routes:
  - name: ngrok-mep-server  # 路由名称
    paths:
    - /test-service  # 路由后缀名称


# 下面是初始化的建议配置
 services:
 - name: example-service
   url: http://example.com
   # Entities can store tags as metadata
   tags:
   - example
   # Entities that have a foreign-key relationship can be nested:
   routes:
   - name: example-route
     paths:
     - /
   plugins:
   - name: key-auth
 - name: another-service
   url: https://example.org

检查文件

shell 复制代码
kong config -c kong.conf parse kong.yml

Response:

复制代码
parse successful

加载文件

复制代码
kong start -c kong.conf
已启动的使用
kong restart -c kong.conf

校验服务是否正常

我们可以在kong的8000端口后加上路由后缀/test-service查看服务是否正常

复制代码
curl -i localhost:8000/test-service

这里由于项目路径原因显示404,但其实后端已经收到请求了

相关推荐
A叶子叶7 天前
Kong网关部署研究
python·spring cloud·微服务·gateway·kong
甜可儿8 天前
Gateway实战入门(四)、断言-请求头以及请求权重分流等
java·spring cloud·gateway
INFINI Labs8 天前
实现极限网关(INFINI Gateway)配置动态加载
gateway
观测云12 天前
Kong 可观测性最佳实践
kong
brhhh_sehe13 天前
【Java面试系列】初识GateWay网关
java·面试·gateway
程序媛学姐13 天前
SpringCloud网关:Gateway路由配置与过滤器链
java·spring cloud·gateway
天草二十六_简村人14 天前
微信小程序的业务域名配置(通过ingress网关的注解)
后端·微服务·微信小程序·小程序·k8s·kong
时雨h15 天前
微服务架构-网关学习 以Spring Cloud Gateway为例 详细功能模块解读
微服务·架构·gateway
ronshi18 天前
Spring Cloud Gateway 使用ribbon以及nacos实现灰度发布
ribbon·nacos·gateway·灰度
carfied-feifei19 天前
云安全相关博客阅读(四)
云原生·gateway·云安全