Create Target Associated to a Specific Upstream
POST {{gateway}}/upstreams/:upstreamHost:portOriI/targets
Create Target Associated to a Specific Upstream konghq
A target is an ip address/hostname with a port that identifies an instance of a backend service. Every upstream can have many targets, and the targets can be dynamically added. Changes are effectuated on the fly.
Because the upstream maintains a history of target changes, the targets cannot be deleted or modified. To disable a target, post a new one with weight=0; alternatively, use the DELETE convenience method to accomplish the same.
The current target object definition is the one with the latest created_at.
Targets can be both tagged and filtered by tags.
Attributes | Mandatory | Type | Description |
---|---|---|---|
upstream host:port or id | required | path | The unique identifier or the host:port attribute of the Upstream that should be associated to the newly-created Target. |
Request Body
Attributes | Mandatory | Type | Description |
---|---|---|---|
target | required | body | The target address (ip or hostname) and port. If the hostname resolves to an SRV record, the port value will be overridden by the value from the DNS record. |
weight | optional | body | The weight this target gets within the upstream loadbalancer (0-1000). If the hostname resolves to an SRV record, the weight value will be overridden by the value from the DNS record. Defaults to 100. |
tags | optional | body | An optional set of strings associated with the Target, for grouping and filtering. |
Request Body
{"upstream"=>{"id"=>"885a0392-ef1b-4de3-aacf-af3f1697ce2c"}, "target"=>"example.com:8000", "weight"=>100, "tags"=>["user-level", "low-priority"]}
HEADERS
Key | Datatype | Required | Description |
---|---|---|---|
Content-Type | string |
RESPONSES
status: Created
{"id":"a3395f66-2af6-4c79-bea2-1b6933764f80","created_at":1422386534,"upstream":{"id":"885a0392-ef1b-4de3-aacf-af3f1697ce2c"},"target":"example.com:8000","weight":100,"tags":["user-level","low-priority"]}