Skip to content

Latest commit

 

History

History
137 lines (110 loc) · 3.65 KB

3.06.Service-Registry.md

File metadata and controls

137 lines (110 loc) · 3.65 KB

Service Registry

Easegress servers as a reverse proxy. It can easily integrate with mainstream Service Registries.

Basic: Load Balance

name: pipeline-reverse-proxy
kind: Pipeline
flow:
  - filter: proxy
filters:
  - name: proxy
    kind: Proxy
    pools:
    - servers:
      - url: http://127.0.0.1:9095
      - url: http://127.0.0.1:9096
      - url: http://127.0.0.1:9097
      loadBalance:
        policy: roundRobin

Dynamic: Integration with Service Registry

We integrate Proxy with service registries such as Consul, Etcd, Zookeeper, Eureka. You need to create one of them to connect the external service registry. The service registry config takes higher priority than static servers. If the dynamic servers pulling failed, it will use static servers if there are.

Zookeeper

  1. First we need to create a ZookeeperServiceRegistry in Easegress
kind: ZookeeperServiceRegistry
name: zookeeper-001
zkservices: [127.0.0.1:2181]
prefix: /services
conntimeout: 6s
syncInterval: 10s
  1. Create a pipeline and set its serviceRegistry field into zookeeper-001 and it will look up the zookeeper configuration for the service named springboot-application-order as in field serviceName.
name: pipeline-reverse-proxy
kind: Pipeline
flow:
  - filter: proxy
filters:
  - name: proxy
    kind: Proxy
    pools:
    - servers:
      - url: http://127.0.0.1:9095
      - url: http://127.0.0.1:9096
      - url: http://127.0.0.1:9097
      serviceRegistry: zookeeper-001              # +
      serviceName: springboot-application-order   # +
      loadBalance:
        policy: roundRobin

Consul

  1. First we need to create a ConsulServiceRegistry in Easegress
kind: ConsulServiceRegistry
name: consul-001
address: '127.0.0.1:8500'
scheme: http
syncInterval: 10s
  1. Create a pipeline and set its serviceRegistry field into consul-001 and it will look up the consul configuration for the service named springboot-application-order as in field serviceName.
name: pipeline-reverse-proxy
kind: Pipeline
flow:
  - filter: proxy
filters:
  - name: proxy
    kind: Proxy
    pools:
    - servers:
      - url: http://127.0.0.1:9095
      - url: http://127.0.0.1:9096
      - url: http://127.0.0.1:9097
      serviceRegistry: consul-001              # +
      serviceName: springboot-application-order   # +
      loadBalance:
        policy: roundRobin

Eureka

  1. First we need to create a EurekaServiceRegistry in Easegress
kind: EurekaServiceRegistry
name: eureka-001
endpoints: ['http://127.0.0.1:8761/eureka']
syncInterval: 10s
  1. Create a pipeline and set its serviceRegistry field into eureka-001 and it will look up the eureka configuration for the service named springboot-application-order as in field serviceName.
name: pipeline-reverse-proxy
kind: Pipeline
flow:
  - filter: proxy
filters:
  - name: proxy
    kind: Proxy
    pools:
    - servers:
      - url: http://127.0.0.1:9095
      - url: http://127.0.0.1:9096
      - url: http://127.0.0.1:9097
      serviceRegistry: eureka-001              # +
      serviceName: springboot-application-order   # +
      loadBalance:
        policy: roundRobin