Container Service for Kubernetes (ACK) uses the cloud controller manager (CCM) to add route entries to the route table of the virtual private cloud (VPC) where the cluster is deployed. This enables network connectivity between pods in the cluster. You can update the cloud-config file 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.
  • The Flannel network plug-in is used in the ACK 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 system components.

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 system components.

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

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

  1. Log on to the ACK console.
  2. In the left-side navigation pane of the ACK console, click Clusters.
  3. On the Clusters page, find the cluster that you want to manage and choose More > Manage Components in the Actions column.
  4. On the Add-ons page, find the CCM and click Configuration.
  5. In the RouteTableIDS section, enter the IDs of route tables for the VPC and click OK.
    You must enter the ID of the system route table for the VPC and separate the route table IDs with commas (,). Example: vtb-t4n788888****,vtb-t4n7k6u3m0n840799****.

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

You can configure multiple route tables for the VPC where the 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 Connect to ACK clusters by using kubectl.

  1. Update the cloud-config file.

    Run the kubectl edit cm -n kube-system cloud-config command to edit the cloud-config file. Replace ${ROUTE_TABLES_IDS} with the IDs of 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****.

    The following cloud-config file is provided as an example.
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: cloud-config
      namespace: kube-system
    data:
      cloud-config.conf: |-
        {
            "Global": {
                "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, you can find that the route entries of the cluster nodes are displayed in the specified route tables.

In the ACK console

  1. Log on to the ACK console.
  2. In the left-side navigation pane of the ACK console, click Clusters.
  3. On the Clusters page, find the cluster that you want to manage and click the name of the cluster or click Details in the Actions column. The details page of the cluster appears.
  4. In the left-side navigation pane of the details page, choose Configurations > ConfigMaps.
  5. Select the kube-system namespace. Find the cloud-config ConfigMap and click Edit YAML in the Actions column.
  6. In the View in YAML panel, set routeTableIDs to the IDs of 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
  7. In the left-side navigation pane of the details page, choose Workloads > DaemonSets.
  8. Select the kube-system namespace. Find the cloud-controller-manager DaemonSet and choose More > Redeploy in the Actions column.
    After the redeployment is completed, you can find that the route entries of the cluster nodes are displayed in the specified route tables.