Login 24/7 Support Community tyk.io

Service Discovery Examples

Mesosphere Example

For integrating service discovery with Mesosphere, you can use the following configuration parameters:

  isNested = false
  isTargetList = true
  endpointReturnsList = false
  portSeperate = true
  dataPath = "host"
  parentPath = "tasks"
  portPath = "ports"

Eureka Example

For integrating service discovery with Eureka, you can use the following configuration parameters (this assumes that the endpoint will return JSON and not XML, this is achieved by creating an API Definition that injects the header that requests the data type and using this API Definition as the endpoint):

  isNested = false
  isTargetList = true
  endpointReturnsList = false
  portSeperate = true
  dataPath = "hostName"
  parentPath = "application.instance"
  portPath = "port.$"

Etcd Example

For integrating with etcd, you can use the following configurations:

  isNested = false
  isTargetList = false
  endpointReturnsList = false
  portSeperate = false
  dataPath = "node.value"
  parentPath = ""
  portPath = ""

Zookeeper Example

For this, you need to spin up a REST server that communicates with the Zookeeper instance. Here is one open source project, ZooREST, that does just that: https://github.com/Difrex/zoorest

With Zookeeper and ZooREST running, test the query endpoint. Don’t forget the +json:

$ curl http://zoorest:8889/v1/get/zk_tyk+json
{
  "data": {
      "path": "httpbin.org"
  },
  "error": "",
  "path": "/zk_tyk",
  "state": "OK",
  "zkstat": {}
}

Then, you can use the following Tyk SD configurations:

  isNested = false
  isTargetList = false
  endpointReturnsList = false
  portSeperate = false
  dataPath = "data.path"
  parentPath = ""
  portPath = ""

Consul Example

For integrating service discovery with Consul, you can use the following configuration parameters:

  isNested = false
  isTargetList = true
  endpointReturnsList = true
  portSeperate = true
  dataPath = "Address"
  parentPath = ""
  portPath = "ServicePort"

Linkerd Example

Note

This configuration is a Tyk Community Contribution.

To integrate Tyk with Linkerd perform the following:

Configure Linkerd

For integrating with Linkerd, you need to add the following configuration to your linkerd.yaml file, located in the config/ directory:

  routers:
  - protocol: http
    identifier:
      kind: io.l5d.header.token
      header: Custom-Header

Then, in your Tyk Dashboard:

  1. Select your API from the System Management > APIs section and click Edit.

  2. From the Core Settings tab, set the Target URL to the Linkerd http server host:port address.

  3. From the Endpoint Designer tab click Global Version Settings enter Custom-Header in the Add this header: field and the value of the Linkerd app-id in the Header value field.

  4. Click Update to save your changes.

This is needed since Tyk appends a “Host” header when proxying the request and the “Host” header is also the default header expected by Linkerd.

For further Linkerd information, see:

Linkerd - HTTP proxy documentation (Alternatives Section)

Linkered - Header Token Identifier documentation

The original Community Contribution