All Products
Document Center

Routing and Server Load Balancer

Last Updated: Feb 14, 2018

Swarm clusters support Layer-7 (aliyun.routing) and Layer-4 ( routing. Swarm mode clusters also support these two routing modes and use the same syntax, as shown in the following orchestration template.

  1. version: "3"
  2. services:
  3. nginx:
  4. image: nginx:latest
  5. ports:
  6. - 80
  7. deploy:
  8. mode: replicated
  9. replicas: 1
  10. labels:
  11. aliyun.routing.port_80: web
  12. tcp://slbtest:8080
  • aliyun.routing.port_80: web: Forward the web subdomain to port 80 of the Nginx service. This mode does not require to expose the container port to the host. If only this mode is enabled, the ports section can be omitted from the preceding template.

  • tcp://slbtest:8080: Bind port 8080 of the Server Load Balancer instance slbtest to port 80 of the Nginx service. Swarm clusters require you to manually bind a port to the slbtest backend, while this is not required for swarm mode clusters. Container Service automatically modifies the Server Load Balancer backend based on your exposed port. In swarm mode, different services of the same cluster can share a Server Load Balancer instance.