Scenarios
This document describes how to use the base images provided by Tencent Cloud TKE to create custom images.
Note:
1. Base images refer to the public images supported by TKE. For the image list, see Image Overview. 2. Custom images are non-standard operating environments. The platform has not undergone compatibility adaptation, and users need to ensure the availability of images in Kubernetes environments on their own. For such images, TKE does not provide SLA services or technical support in principle.
Usage Instructions
Currently, only the creation of the same type of operating system images is supported. For example, using CentOS base images to create CentOS custom images.
If you use the custom image feature, please use the base images provided by TKE to create custom images.
If TKE plans to adjust the image logic later, it will notify users via in-site messages, SMS, and email at least one week in advance. Changes to the image logic may cause failures when creating new nodes with existing custom images. You need to recreate custom images accordingly. If your cluster uses node pools, you need to adjust the image configuration of the node pools.
If you need to use the custom image feature, please submit a ticket to apply. Must-Knows
Before custom images are created, be sure to carefully read the following notes. Custom images are considered non-standard environments. Tencent Cloud does not provide official support or ongoing maintenance for them.
Do not modify /etc/fstab at will.
After creating the image, promptly clean up the /var/lib/cloud directory.
If you have pre-installed runtime components in the custom image, node initialization will fail and report an error directly.
Before creating a custom image, be sure to complete node pre-cleaning via the cleanup script to avoid residual data on the current machine affecting the normal node initialization process. Do not run this on existing cluster nodes, as it may render them unavailable. Run the command as follows: curl --proto '=https' --tlsv1.2 -sSf https://mirrors.tencent.com/install/tke/clean-node.sh | bash
Note:
Do not use running normal nodes (CVM instances) in the cluster to create custom images. If you need to use them, first remove them from the cluster.
Please use the base images provided by TKE to create custom images.
Operation Steps
This document takes creating a Cloud Virtual Machine (CVM) using a base image as an example.
1. Create CVM
1. Log in to the CVM console, select New to go to the CVM purchase page. 2. In the Images section, select the TKE base image. Here we take the public image TencentOS Server 3.1 as an example.
2. Create a Custom Image
2. Run the following command to create a new test.txt file.
3. Press i to enter edit mode and write the following content.
this is customer cvm images test
4. Press Esc and enter :wq to save and exit.
3. Use Custom Image
Note:
The region of the custom image you create (or share) must match the region of the TKE cluster.
After the custom image is created, you can use this image to create a TKE cluster. On the Create Cluster page, select Custom Image in Image Provider, and then select the created custom image in Operating System.
4. Validate Custom Image
1. Log in to the TKE console and select Cluster in the left sidebar. 2. Select the cluster ID created using a custom image and go to the cluster details page.
3. On the Node Management page, select Node and record the node ID to log in to and verify.
4. Log in to the CVM console, enter the recorded node ID in the search box and click , you can see the created nodes. As shown in the following figure: 6. Run the following command to verify the custom image.
The returned result is as follows, which indicates that the node is using a custom image.
Summary of Usage
Custom images must be created using the base images provided by TKE. Custom images that do not meet this requirement will not be displayed on the TKE console.
If file protection (chattr +i /etc/resolv.conf) is set for the /etc/resolv.conf file in the custom image, it will cause cloud-init to fail. Since TKE depends on the successful status of cloud-init, this will eventually cause the node to fail to join the cluster.
Due to the inability to guarantee the execution sequence between rc.local and container_cluster_agent, data copied by the user's start_init.sh script may be lost. It is not recommended to execute start_init.sh in rc.local. Instead, it is advised to execute it in user-data.
If the /var/lib/cloud directory is retained on a node that has previously created an image, the config_scripts_user file in the /var/lib/cloud/instances/${instance-id}/sem directory will interfere with the normal execution of the cloud-init service. This will cause the modified hostname of the node to fail to take effect when the node joins the TKE cluster.
When a personal yum repository is added in a custom image, placing it in an inappropriate directory (such as /etc/yum.repos.d/) will cause container-cluster-agent to report errors when executing the yum install operation, resulting in the step being skipped and causing the agent to fail to install the yum repository.
FAQs
Possible Reasons Why Custom Images Cannot Be Seen on the TKE Console:
1. The base image you selected is not visible on the CVM console. This scenario requires you to submit a ticket to apply. 2. The base image you selected is not within the list of TKE-supported public images. For the image list, see Image Overview. 3. The region of the custom image you created (or shared) does not match the cluster region.