1
0
mirror of https://github.com/docker/docs.git synced 2026-11-01 22:34:29 +03:00

Landing page info

This commit is contained in:
paigehargrave
2019-03-27 08:06:23 -04:00
committed by GitHub
parent 91948603d8
commit 9423fa9751

View File

@@ -1,20 +1,78 @@
---
title: Route traffic to a simple swarm service
description: Learn how to do canary deployments for your Docker swarm services
title: Route traffic to a swarm service
description: Learn how to deploy your Docker swarm services and applications
keywords: routing, proxy
redirect_from:
- /ee/ucp/interlock/deploy/configuration-reference/
- /ee/ucp/interlock/deploy/configure/
---
Once the [layer 7 routing solution is enabled](../deploy/index.md), you can
start using it in your swarm services.
## Deploying services and applications
After Interlock is deployed, you can launch and publish services and applications.
Use [Service Labels](https://docs.docker.com/engine/reference/commandline/service_create/#set-metadata-on-a-service--l-label)
to configure services to publish themselves to the load balancer.
In this example we'll deploy a simple service which:
**Note**: The following examples assume a DNS entry (or local hosts entry if you are testing locally) exists
for each of the applications.
## Publishing a service with four replicas
To publish, create a Docker Service using two labels:
- `com.docker.lb.hosts`
- `com.docker.lb.port`
The `com.docker.lb.hosts` label instructs Interlock where the service should be available.
The `com.docker.lb.port` label instructs what port the proxy service should use to access
the upstreams.
This example publishes a demo service to the host `demo.local`.
First, create an overlay network so that service traffic is isolated and secure:
```bash
$> docker network create -d overlay demo
1se1glh749q1i4pw0kf26mfx5
```
Next, deploy the application:
```bash
$> docker service create \
--name demo \
--network demo \
--label com.docker.lb.hosts=demo.local \
--label com.docker.lb.port=8080 \
ehazlett/docker-demo
6r0wiglf5f3bdpcy6zesh1pzx
```
Interlock detects when the service is available and publishes it. After tasks are running
and the proxy service is updated, the application is available via `http://demo.local`.
```bash
$> curl -s -H "Host: demo.local" http://127.0.0.1/ping
{"instance":"c2f1afe673d4","version":"0.1",request_id":"7bcec438af14f8875ffc3deab9215bc5"}
```
To increase service capacity, use the Docker Service [Scale](https://docs.docker.com/engine/swarm/swarm-tutorial/scale-service/) command:
```bash
$> docker service scale demo=4
demo scaled to 4
```
In this example, four service replicas are configured as upstreams. The load balancer balances traffic
across all service replicas.
-------------------------------ARE BOTH EXAMPLES NEEDED?-----------------------------------------------
## Publishing a service with a web interface
The next example deploys a simple service that:
* Has a JSON endpoint that returns the ID of the task serving the request.
* Has a web interface that shows how many tasks the service is running.
* Can be reached at `http://app.example.org`.
## Deploy the service
Create a `docker-compose.yml` file with:
```yaml
@@ -47,8 +105,6 @@ should attach to in order to be able to communicate with the demo service.
To use layer 7 routing, your services need to be attached to at least one network.
If your service is only attached to a single network, you don't need to add
a label to specify which network to use for routing. When using a common stack file for multiple deployments leveraging UCP Interlock / Layer 7 Routing, prefix `com.docker.lb.network` with the stack name to ensure traffic will be directed to the correct overlay network.
* The `com.docker.lb.port` label specifies which port the `ucp-interlock-proxy`
service should use to communicate with this demo service.
* Your service doesn't need to expose a port in the swarm routing mesh. All
@@ -64,7 +120,7 @@ docker stack deploy --compose-file docker-compose.yml demo
The `ucp-interlock` service detects that your service is using these labels
and automatically reconfigures the `ucp-interlock-proxy` service.
## Test using the CLI
### Test using the CLI
To test that requests are routed to the demo service, run:
@@ -84,7 +140,7 @@ If everything is working correctly, you should get a JSON result like:
{"instance":"63b855978452", "version":"0.1", "request_id":"d641430be9496937f2669ce6963b67d6"}
```
## Test using a browser
### Test using a browser
Since the demo service exposes an HTTP endpoint, you can also use your browser
to validate that everything is working.
@@ -95,3 +151,17 @@ able to start using the service from your browser.
![browser](../../images/route-simple-app-1.png){: .with-border }
## Next steps
- [Publishing a service as a canary instance](canary.md)
- [Using context or path-based routing](context.md)
- [Publishing a default host service](default-backend.md)
- [Specifying a routing mode](interlock-vip-mode)
- [Using routing labels](labels-reference.md)
- [Implementing redirects](redirects.md)
- [Implementing a service cluster](service-clusters.md)
- [Implementing persistent (sticky) sessions](sessions.md)
- [Implementing SSL](ssl.md)
- [Securing services with TLS](tls.md)
- [Configuring websockets](websockets.md)