A component template defines the container image address, network protocol, communications port, memory capacity, CPU capacity, volumes, and environment variables.
You can create a component template using the container image you have uploaded.
A component template name must:
Name and version number of the container image that will be used to create the component template.
Container images are classified into two types:
Network protocol and listening port used by the component. A maximum of 10 ports can be added.
Memory capacity and CPU capacity of the component.
CPU capacity is measured in mcores. 1 core is equal to 1000 mcores.
The memory capacity and CPU capacity defined in a component template cannot exceed those of the node on which the containerized application will run. Otherwise, creating the containerized application will fail.
If only one container supports uncapped CPU, the container can use available resources on the node, in addition to the CPU capacity of the container.
If multiple containers support uncapped CPU, they can additionally share available resources on the node on a percentage basis. For example, if the CPU capacity of container A is 100 mcores and the CPU capacity of container B is 300 mcores, then they share available resources on the node at a ratio of 1:3.
A volume mounts an absolute path on a host (also called a node) into a path on a container, thereby achieving sharing between hosts and containers. A maximum of 10 volumes can be configured.
The current CCE version supports only EVS plug-ins.
There are two ways to define a volume:
For example, to mount the /src/webapp directory on a host to the /opt/webapp directory on the frontend container, run the following command:
docker run -d -P --name frontend -v /src/webapp:/opt/webapp frontend
If the Volumes parameter is configured, storage will be added for the application when the application is being created from the component template. The application's storage space is the host path on the node where the application is deployed
Another way to add storage for the application is to use APIs to create the application and then add storage.
PersistentVolume is a storage resource. CCE supports three PersistentVolume types: hostpath, nfs, and hwsElasticVolumeService. The PersistentVolumes of hostpath type deliver the same functions as the Volumes configured on the CCE console. For details about PersistentVolumes of nfs and hwsElasticVolumeService types and related APIs, see Cloud Container Engine API Reference.
An environment variable refers to a container runtime variable. A maximum of 30 environment variables can be defined in a component template. The variables of a containerized application can be modified even after the application is deployed, allowing for great flexibility in application management.
There are two ways to define an environment variable:
For details, see 2 in Creating a Component Template.
The "Template modified successfully" message is then displayed.
Information about the component template is then displayed.