edit-icon download-icon

Simple routing - supports HTTP and HTTPS

Last Updated: Feb 14, 2018

Scenarios

  • Simple Layer-7 protocol load balancing
  • Web routing service
  • Services in a container cluster access each other using Layer-7 protocol by means of communication proxy and Server Load Balancer

Principles

See the following figure. When you create a cluster, a Server Load Balancer instance is assigned to the cluster by default. The Server Load Balancer instance adds all the nodes in the cluster to the backend. Port 80 is exposed at the frontend, and port 9080 is exposed on the machines of all the backend nodes. Container Service starts a routing application acsrouting, namely, the Alibaba Cloud Container Service Routing. This routing application has only one service, the routing service. The routing service is global, which means a copy of this service (or image), namely, a container, is deployed on each node (a node is also called a host or a virtual machine (VM) instance of Elastic Compute Service (ECS)). Each node uses this container to route HTTP services or HTTPS services.

1

As shown in the preceding figure, for HTTP services, the mapping between Server Load Balancer instance frontend and backend ports is 80:9080, and the port mapping between the host and the container used for routing is 9080:80, indicating that port 80 is exposed on the containers used for routing. Any ports can be exposed on the other containers used as the web service. After you set the port mapping between host and container during container startup, the routing service can obtain the corresponding port for request routing.

Setup methods

Note: Make sure that the following kernel parameters (in the /etc/sysctl.conf file) of the related Container Service nodes are set to 0. Otherwise, the nodes might not be accessed.

  1. net.ipv4.conf.default.rp_filter = 0
  2. net.ipv4.conf.all.rp_filter = 0
  3. net.ipv4.conf.eth0.rp_filter = 0

Set in the Container Service console

Set by Services > Update

  1. Log on to the Container Service console.

  2. Click Services in the left-side navigation pane.

  3. Select the cluster in which the service to be exposed resides from the Cluster list.

  4. Click Update at the right of the service to be exposed (wordpress_web in this example).

    1

  5. Configure the port mapping between host and container on the Update Service page.

    The host port is empty, indicating that a random port on the host is exposed (when HTTP or HTTPS services are exposed, you do not need to know what port is exposed on the host, because the container port can be directly accessed by using an overlay network or Virtual Private Cloud (VPC) network). The container port is 80. Use port 80 of the wordpress_web service to provide the HTTP service. The protocol used is TCP and the mode is Ingress.

    1

  6. Use Container Label to configure the routing. In this example, expose the service by using a domain name. Specify the port to be exposed (port 80 of the wordpress_web service in this example).

    1

    Enter the domain name prefix in the Domain field. If the domain name prefix is XXX, the domain name XXX.$cluster_id.$region_id.alicontainer.com is obtained for testing. In this example, the domain name wordpress.c501315da4d894f3fa7793be85b207f50.cn-hangzhou.alicontainer.com is obtained. You can enter your own domain name, which needs to add the resolution to the IP address of the corresponding Server Load Balancer instance. For how to configure the container port used for routing and the domain name of HTTP services, see routing label.

  7. Click Update after completing the configurations.

  8. Click the application name on the Application List page and then click the Routes tab.

  9. Click the route address to access the wordpress welcome page.

    1

Set by application template editor

  1. Log on to the Container Service console.

  2. Click Applications in the left-side navigation pane.

  3. Select the cluster from the Cluster list.

  4. Click Update at the right of the application (wordpress in this example).

    1

  5. Add a routing label in Template, define the corresponding domain name or domain name prefix, update the application version, and confirm whether or not to pull the latest Docker image. Then, click OK to update the domain name.

    1

  6. Click the application name on the Application List page and then click the Routes tab.

  7. Click the route address to access the wordpress welcome page.

Set by client

Thank you! We've received your feedback.