All Products
Search
Document Center

Connect Kubernetes to Elastic Container Instance

Last Updated: Sep 08, 2021

Elastic Container Instance can be used to provide a basic runtime environment of pods for Kubernetes clusters. Other capabilities such as dependencies between business, load balancing, auto scaling, and regular scheduling must still be provided by Kubernetes. This topic describes how to connect Kubernetes to Elastic Container Instance and use Elastic Container Instance to run pods.

Connection methods

Elastic Container Instance provides a hierarchical solution to manage Kubernetes resources. Elastic Container Instance schedules and manages pods at the infrastructure layer, whereas Kubernetes manages workloads such as Deployments, Services, StatefulSets, and CronJobs on the platform layer.

After you connect Elastic Container Instance to Kubernetes, Elastic Container Instance takes over the management of pods, including the infrastructure and resource availability. Kubernetes no longer needs to manage the lifecycle and resources of the underlying virtual machines (VMs).

Elastic Container Instance seamlessly connects to Kubernetes by using virtual nodes based on Virtual Kubelet provided by the Kubernetes community. Elastic Container Instance provides high elasticity to Kubernetes clusters, which allows you to break free from the limits of the computing capacities of the clusters on which Kubernetes is deployed. For more information, visit Virtual Kubelet.

You can use one of the following methods to connect Elastic Container Instance to Kubernetes:

Connection method

Description

Run Kubernetes pods exclusively on Elastic Container Instance

You need to deploy a serverless Kubernetes (ASK) cluster, and then the entire ASK cluster runs on Elastic Container Instance. This deployment method eliminates the need to focus on O&M and capacity issues of the underlying VMs.

Run Kubernetes pods on both Elastic Container Instance and traditional servers

Elastic Container Instance connects to Kubernetes clusters as virtual nodes. You can use this method to improve the resource usage and elasticity of clusters and reduce running costs.

Run Kubernetes pods exclusively on Elastic Container Instance by deploying an ASK cluster

In this deployment method, all Kubernetes pods run on Elastic Container Instance, which manages the underlying infrastructure. Kubernetes needs only to manage workloads to ensure the reliability of the business.

If you choose this deployment method, we recommend that you select an ASK cluster. ASK is optimized to run entirely on Elastic Container Instance. It is a fully managed and cost-effective Kubernetes environment that is suitable for online and offline business, simulation environments, and development and test environments.

For more information about how to use Elastic Container Instance to deploy ASK clusters, see Use Elastic Container Instance in ASK clusters.

Run Kubernetes pods on both Elastic Container Instance and traditional servers

If you have an existing Kubernetes cluster, you can add Elastic Container Instance as a virtual node to the cluster. You can schedule the excess traffic of long-running business loads to Elastic Container Instance. This allows you to reduce idle resources and ensure fast and flexible scalability. When business traffic decreases, the Kubernetes cluster can release the pods deployed in Elastic Container Instance to reduce costs.

You can use one of the following methods to connect to Elastic Container Instance based on your existing Kubernetes clusters:

Management tools

You can use the following methods to manage Kubernetes and view the running status of elastic container instances:

  • Elastic Container Instance console

    You can view the running status of elastic container instances in the Elastic Container Instance console. Perform the following steps:

    1. Log on to the Elastic Container Instance console.

    2. In the top navigation bar, select a region.

    3. The Container Group page appears. You can view the elastic container instances that are created in the selected region.

  • ACK console

    You can manage ASK or ACK clusters and view the running status of elastic container instances in the ACK console. To view the running status of elastic container instances, perform the following steps:

    1. Log on to the ACK console.

    2. In the left-side navigation pane, click Clusters.

    3. In the cluster list, find the cluster that you want to view and click the cluster ID to go the details page.

    4. In the left-side navigation pane, choose Workloads > Pods.

    5. On the Pods page, select a namespace from the drop-down list. Then, you can view elastic container instances of the namespace.

  • Cloud Shell

    You can manage Kubernetes clusters by using Cloud Shell provided by Alibaba Cloud. For more information, see Use kubectl on Cloud Shell to manage ACK clusters.

  • kubectl client

    You can use the kubectl client to connect to a remote Kubernetes cluster from your computer. For more information, see Connect to ACK clusters by using kubectl.

Limits

Elastic Container Instance does not support some Kubernetes features such as hostPaths and DaemonSets due to security limits of Alibaba Cloud public cloud and limits imposed by virtual nodes. The following table describes the unsupported features.

Item

Description

Recommended alternative

HostPath

Allows you to mount files from on-premises hosts to containers.

Use emptyDir volumes, disks, or Apsara File Storage NAS (NAS) file systems.

HostNetwork

Allows you to map a host port to a container.

Create a Service of the LoadBalancer type.

DaemonSet

Allows you to deploy a static pod on the host of a container.

Deploy multiple images in a pod by using sidecar containers.

Privileged permissions

Allows you to grant privileged permissions to a container.

Use a security context to grant permissions to a pod.

Service of the NodePort type

Allows you to map a host port to a container.

Create a Service of the LoadBalancer type.

If you deploy Kubernetes exclusively on Elastic Container Instance or use virtual nodes to expand the scalability of your Kubernetes cluster, take note of the following items:

  • ASK clusters share an image repository with Kubernetes clusters. To simplify image pulling, you can upload your container images to the image repository in advance. We recommend that you use Alibaba Cloud Container Registry (ACR) and the image address (registry-vpc.xxx) in virtual private cloud (VPC) to upload your container images.

  • Both deployment methods support common controllers such as Deployments, ReplicaSets, Jobs, CronJobs, and StatefulSets. Applications of these types can run directly on ASK and Kubernetes clusters.

  • Both deployment methods use PrivateZone to implement service discovery. We recommend that you enable PrivateZone when you create a cluster.

  • Both deployment methods support loading balancing, which indicates that the type of Service is LoadBalancer.