All Products
Search
Document Center

Container Service for Kubernetes:Configure multiple route tables for a VPC

Last Updated:Dec 21, 2023

Container Service for Kubernetes (ACK) uses the cloud controller manager (CCM) to add routes to the route table of the virtual private cloud (VPC) where a cluster is deployed. This enables network connectivity between pods in the cluster. You can update the cloud-config ConfigMap to configure multiple route tables for the VPC where an ACK cluster is deployed. This topic describes how to configure multiple route tables for the VPC where an ACK cluster is deployed.

Prerequisites

  • An ACK cluster is created.

    • Create an ACK managed cluster. For more information, see Create an ACK managed cluster.

      Note

      Only ACK managed clusters that run Kubernetes 1.18 or later allow you to configure multiple route tables. If the Kubernetes version of your ACK managed cluster is earlier than 1.18, submit a ticket.

    • Create an ACK dedicated cluster. For more information, see Create an ACK dedicated cluster.

  • The CCM version is later than v1.9.3.86-g4454991-aliyun. For more information about how to check the CCM version, see Manage components.

  • The Flannel network plug-in is used in the ACK cluster.

  • The VPC in which the cluster resides has multiple route tables.

    Note

    If the VPC has only one route table, you do not need to configure multiple route tables for the VPC.

Background information

If multiple route tables are configured for a VPC, you can associate Elastic Compute Service (ECS) instances with different route tables. Earlier versions of the CCM allow you to configure only one route table for each VPC. Therefore, you must update the CCM to the latest version in the ACK console. For more information about how to update the CCM version, see Manage components.

Configure multiple route tables for the VPC where an ACK managed cluster is deployed

You can configure multiple route tables for the VPC where an ACK managed cluster is deployed in the ACK console.

  1. Obtain the IDs of the route tables.

    1. Log on to the VPC console. In the left-side navigation pane, click Route Tables.

    2. On the Route Tables page, set the search condition to VPC ID, enter the ID of the VPC in which the cluster resides, and then click the search icon.

      路由表

  2. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  3. On the Clusters page, click the name of the cluster that you want to manage and choose Operations > Add-ons in the left-side navigation pane.

  4. On the Add-ons page, find the CCM and click Configuration.

    配置.png

  5. In the routeTableIDs field, enter the route table IDs obtained in Step 1 and click OK.

    You must enter the ID of the system route table of the VPC and separate the route table IDs with commas (,). Example: vtb-t4n788888****,vtb-t4n7k6u3m0n840799***.路由表.png

Configure multiple route tables for the VPC where an ACK dedicated cluster is deployed

You can configure multiple route tables for the VPC where an ACK dedicated cluster is deployed in the ACK console or by using kubectl.

Use kubectl

To use a kubectl client to configure multiple route tables for the VPC, make sure that the kubectl client is connected to the ACK dedicated cluster. For more information, see Obtain the kubeconfig file of a cluster and use kubectl to connect to the cluster.

  1. Update the cloud-config ConfigMap.

    Run the kubectl edit cm -n kube-system cloud-config command to modify the cloud-config ConfigMap. Replace ${ROUTE_TABLES_IDS} with the IDs of the route tables in the VPC. Make sure that the ID of the system route table is included. Separate multiple route table IDs with commas (,). Example: vtb-t4n788888****,vtb-t4n7k6u3m0n840799****.

    Important

    You need to modify only ${ROUTE_TABLES_IDS} in the cloud-config ConfigMap.

    "routeTableIDs": "${ROUTE_TABLES_IDS}"
  2. Run the following command to restart the pod that runs the CCM:

    kubectl -n kube-system delete po -lapp=cloud-controller-manager

    After the pod is restarted, the routes of the cluster nodes are displayed in the specified route tables.

Use the ACK console

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, click the name of the cluster that you want to manage and choose Configurations > ConfigMaps in the left-side navigation pane.

  3. Select the kube-system namespace. Find the cloud-config ConfigMap and click Edit YAML in the Actions column.

  4. In the View in YAML panel, set routeTableIDs to the IDs of the route tables in the VPC. Make sure that the ID of the system route table is included. Separate multiple route table IDs with commas (,). Example: vtb-t4n788888****,vtb-t4n7k6u3m0n840799****. Then, click OK.

    cloud-config

  5. In the left-side navigation pane of the details page, choose Workloads > DaemonSets.

  6. Select the kube-system namespace. Find the cloud-controller-manager DaemonSet and click Batch Redeploy in the lower part of the page.

    After the redeployment is completed, the routes of the cluster nodes are displayed in the specified route tables.