Tencent Kubernetes Engine (TKE) is a highly scalable high-performance container management service that allows you to easily run applications on hosted CVM instance clusters. This document describes how to use TKE to quickly create and manage container clusters and how to quickly and flexibly deploy your services in the clusters.
Creating a cluster
At first, you need to create a cluster. A cluster is a collection of cloud resources required for running containers, including several CVMs and CLBs. The following describes how to create a custom cluster.
- Log in to the Tencent Cloud TKE console and click Clusters in the left sidebar.
- On the Cluster Management page, click Create above the cluster list.
- On the Create Cluster page, set the basic cluster information and click Next, as shown in the figure below.
- Cluster Name: the name of the cluster to be created, with a length limited to 60 characters.
- Project of New-added Resource*: newly added resources will be automatically assigned to this project.
- Kubernetes Version: multiple Kubernetes versions are available. To compare the features of these versions, see Supported Versions of the Kubernetes Documentation.
- Runtime Component: choose docker or containerd. For details, see How to Choose Containerd and Docker.
- Region: the region where the cluster will be created. We recommend that you select a region close to your customers to minimize the access latency and improve the download speed.
- Cluster Network: assigns IP addresses that are within the node IP range to CVMs in the cluster. For details, see Network Settings for Containers and Nodes.
- Container Network: assigns IP addresses that are within the container network address range to containers in the cluster. For details, see Network Settings for Containers and Nodes.
- Operating System: select an operating system based on your actual requirements.
- Cluster Description: enter information about the cluster, which will be displayed on the Cluster information page.
- Advanced Settings: you can set IPVS.
IPVS applies to scenarios where large-scale services are run on a cluster, and it cannot be disabled once enabled. For details, see Enabling IPVS for a Cluster.
- Select a model based on the following information and click Next, as shown in the figure below.
- Node Source: there are two options: Add node and Existing nodes. Choose one based on your actual requirements.
- Master Node: the deployment mode of the Master node determines the management mode of your cluster. Two cluster modes Hosting and Independent deployment are available. For details, see Cluster Overview.
- Billing Mode: pay-as-you-go and monthly subscription are supported. For details, see Billing Modes.
- Worker Configuration: here, Node Source is set to New Node. The settings under the component are the same as above by default. You can change them based on actual needs.
- Configure the CVM based on the following information and click Next, as shown in the figure below.
- Container Directory: by default, this option is not selected. If it is selected, you can set the container and image storage directory. We recommend that you store containers and images in data disks.
- Security Group: the security group works as a firewall to control network access of the CVM. The following settings are supported:
- Create and bind the default security group. You can preview the default security group rules.
- Click Add Security Group to configure custom security group rules according to your actual needs.
For details, see TKE Security Group Settings.
- Login Methods: three login methods are available.
- SSH Key Pair: a key pair is a pair of parameters generated by an algorithm. Compared to regular passwords, it is a more secure way to log in to a CVM. For details, see SSH Key.
- Random Password: an automatically generated password will be sent to your Message Center.
- Custom Password: set a password as prompted.
- Confirm the configuration information, and click Complete.
- After the cluster is created, it will appear in the cluster list, as shown in the figure below.
Creating a service
After a cluster is created, you can create a service as instructed below. A service is a microservice comprised of multiple containers with the same configuration and the rules used to access these containers.
On the Cluster Management page, click the ID of the cluster for which you want to create a service.
On the Workload -> Deployment page of the cluster, click Create, as shown in the figure below.
On the Create Workload page, set basic workload information, as shown in the figure below.
- Workload Name: enter the name of the workload to be created.
- Description: enter relevant workload information.
key = value. This is a key value pair, and the default label value in this document is
k8s-app = workloadname.
- Namespace: select a namespace based on your actual requirements.
- Type: select a type based on your actual requirements.
(Optional) Set the volume. Click Add Volume if you need to specify a path to which a container is mounted, as shown in the figure below. For details, see Volume Management.
If no source path is specified, a temporary path is assigned by default.
- Type: seven volume types are supported: temp directory, CVM path, NFS disk, existing PVC, Tencent Cloud block storage, ConfigMap, and Secret. For details, see Volume Management.
Set containers in the pod based on the following information.
- Name: enter the name of the container to be created.
- Image: click Select an image to select an image from My Images, My Favorites, Shared Image, or DockerHub Image.
- Image Tag: the default image tag for TKE. To use a different image tag, click the input box and select one from the list.
- CPU/memory limit: request is used to pre-allocate resources. When the nodes in the cluster do not have enough resources for the request, the container will fail to be created. limit specifies the maximum usage of resources by containers to avoid excessive consumption of node resources in case of exceptions.
- GPU limit: set the limit based on your actual requirements.
- Environment Variable: a variable name can only contain uppercase and lowercase letters, numbers, and underscores and cannot start with a number.
Set the number of pods based on the following information, as shown in the following figure.
- Manual adjustment: set the number of pods. The number of pods in this example is set to 1. You can click
- to change the number of pods.
- Auto adjustment: automatically adjust the number of pods if any of the set conditions are met. For details, see Automatic Scaling Basic Operations.
Configure access settings based on the following information.
- Service: select Enable.
- Service Access: the service access method determines the network attributes of a service. Different access methods offer different network capabilities. For details, see Service Access.
- Load Balancer: select the value as required.
- Port Mapping: select a protocol and enter the Target port and Port.
Click Create workload. After the service is created, it will appear in the service list.
By now, you have created a cluster and a service. The following steps describe how to view resources that have been successfully created.
- Click Clusters in the left sidebar and choose a cluster ID on the Cluster Management page.
- Enter the default Deployment management page. The features in the left menu bar are as follows:
- Basic Info: displays the basic cluster information.
- Node Management: a node is a CVM registered to the cluster. You can create a node, add an existing node, and create scaling rules here.
- Namespace: a namespace is an abstract collection of a group of resources and objects. You can create and delete namespaces here.
- Workload, Service, Configuration Management, Storage: these are common Kubernetes resource objects. For details, see Types of Objects.
- Logs: displays related log information.
- Event: you are redirected to this page when creating a service. It displays the service creation details.
- Click Clusters in the left sidebar and choose a cluster ID on the Cluster Management page.
- On the Deployment management page, choose Service > Service, as shown in the following figure.
- Choose a service name in the Service list to go to the service details page, where you can view the following information:
- Details: displays basic information and advanced settings of the service.
- Event: displays information about events that occurred in the last hour.
- YAML: you can edit YAML to update a service.
In this document, cluster and service resources are enabled. The following steps describe how to clear all resources to avoid unnecessary costs.
Deleting a service
- Click Clusters in the left sidebar to go to the Cluster Management page and click the ID of the cluster for which you want to delete services.
- On the Deployment management page, choose Service > Service.
- On the Service management page, click Delete to the right on the row where the service to be deleted is located.
- Click OK in the pop-up box to delete the service.
Deleting a cluster
- Click Clusters in the left sidebar. On the Cluster Management page, choose More > Delete to the right on the row where the cluster to be deleted is located, as shown in the following figure.
- After confirming the information in the pop-up box, click OK to delete the cluster.
- The cluster stops providing services once the deletion process starts, so please prepare in advance.
- If a cluster is deleted, the services in the cluster will also be deleted.
In this document, you have learned how to configure, deploy, and delete services in Tencent Cloud TKE. With Tencent Cloud TKE, you don't need to install, operate, maintain, or expand your cluster management infrastructure. You can enable and disable Docker applications, query cluster statuses, and use various cloud services by simply calling APIs.
Go to the next tutorial to learn about the basic concepts and operations of Cloud Load Balancer and Image Repository Overview and quickly build services by viewing Examples for Getting Started.