Kong DB-LESS的安装部署

Kong DB-LESS的安装部署

1、新建安装目录

mkdir -p /kong
mkdir -p /log/kong

2、上传安装包到

/kong

3、安装Kong

rpm -ivh --prefix=/kong kong-2.0.3.el7.amd64.rpm

4、修改kong.conf配置文件中的相关配置

配置文件目录:/kong/etc/kong

prefix =/kong
database = off
declarative_config = /kong/etc/kong/kong.yml
admin_listen = = 0.0.0.0:8001, 0.0.0.0:8444 ssl
proxy_listen = 0.0.0.0:8080, 0.0.0.0:8443 ssl

5、kong.yml的配置模板

5.1 常规配置模板

host路由方式

services:
- name: service1
  url: 实际地址
  # Entities can store tags as metadata
  tags:
    - service1
    # Entities that have a foreign-key relationship can be nested:
  routes:
    - name: service1-route
   # Relationships can also be specified between top-level entities,
   # either by name or by id
      service: service1
      hosts: [服务域名]
- name: service2
  url: xx.xx.xx.xx
  tags:
    - service2
  routes:
    - name: service2-route
      service: service2
      hosts: [服务域名]

Path的路由方式

services:
- host: xx.xx.xx.xx
  name: example-service
  port: xxxxxx
  protocol: http
  # Entities can store tags as metadata
  tags:
    - example
    # Entities that have a foreign-key relationship can be nested:
  routes:
    - name: example-route
      paths:
      - /mock

负载均衡的配置模板

services:
- host: upstream
  name: example-service
  port: xxxx
  protocol: http
  # Entities can store tags as metadata
  tags:
    - example
    # Entities that have a foreign-key relationship can be nested:
  routes:
    - name: example-route
      paths:
      - /mock
upstreams:
- name: upstream
  targets:
    - target: xx.xx.xx.xx(实际地址)
      weight: 100
    - target: xx.xx.xx.xx(实际地址)
      weight: 100

6、启动、停止、重启kong

启动: kong start -c kong.conf
停止: kong stop
重启: kong restart -c kong.conf
检查kong的状态: kong check

7、验证

7.1、hostname方式的验证
通过浏览器,记得将host改成对应的域名。
修改host的路径:C:\Windows\System32\drivers\etc

http://域名/

7.1、curl方式的验证
curl -i -X GET http://:8000/mock/request

8、参考文档

https://docs.konghq.com/getting-started-guide/2.1.x/expose-services/

你可能感兴趣的:(Kong DB-LESS的安装部署)