Elastic Container Instance provides the data caching feature for Kubernetes users based on DataCache custom resource definitions (CRDs). Kubernetes users can use the data caching feature to pull large-scale data in advance. This topic describes how to deploy a DataCache CRD in a Kubernetes cluster.
Billing
If you deploy a DataCache CRD in a Container Service for Kubernetes (ACK) cluster, the DataCache CRD is deployed on an existing Elastic Compute Service (ECS) node in the cluster by default. You are not charged for the CRD.
If you deploy a DataCache CRD in an ACK Serverless cluster, a pod that provides 0.25 vCPU and 0.5 GiB of memory is generated after the DataCache CRD is deployed. You are charged based on the pod. The price is calculated based on the following formula: Price = (0.25 × Unit price of vCPUs + 0.5 × Unit price of memory) × Running duration of the pod. For more information about the billing of pods and the unit prices of vCPUs and memory, see Billing of elastic container instances.
Prerequisites
An AccessKey ID and an AccessKey secret are obtained. For more information about how to obtain an AccessKey pair, see Create an AccessKey pair.
ImportantMake sure that the Alibaba Cloud account or Resource Access Management (RAM) user to which the AccessKey pair belongs has the permissions to call API operations related to DataCaches.
The ID of the region in which the cluster resides is obtained.
(Recommended) Deploy a DataCache CRD by using Helm
Connect to the Kubernetes cluster.
Obtain the version of Helm.
helm version
Deploy a DataCache CRD by using one of the following methods based on the version of Helm:
Helm 3.7.0 or later
If the version of Helm is 3.7.x, you must enable experimental features.
If the version of Helm is 3.8.0 or later, skip this step.
export HELM_EXPERIMENTAL_OCI=1
Configure environment variables.
NoteSet the REPO parameter to
oci://eci-release-registry.cn-hangzhou.cr.aliyuncs.com/datacache/datacache-operator
. You do not need to change the region ID.export REPO="oci://eci-release-registry.cn-hangzhou.cr.aliyuncs.com/datacache/datacache-operator" export AK='<AccessKey ID>' export SK='<AccessKey Secret>' export REGION='<Region ID>'
Deploy the DataCache CRD.
helm install datacache-operator $REPO --set accessKey=$AK --set secretKey=$SK --set regionId=$REGION
Helm version earlier than 3.7.0
Install a Container Registry plug-in.
helm plugin install https://github.com/AliyunContainerService/helm-acr
If you can access GitHub, run the preceding command to install the Container Registry plug-in. If the network condition is unstable, refer to the following commands to install the Container Registry plug-in.
git clone https://github.com/AliyunContainerService/helm-acr.git sed -i 's/github.com/helm-acr-releases.oss-cn-hangzhou.aliyuncs.com/g' helm-acr/scripts/install_plugin.sh helm plugin install helm-acr
Add the Helm repository to the on-premises Helm client.
helm repo add datacache acr://eci-release-chart.cn-hangzhou.cr.aliyuncs.com/datacache/datacache-operator helm repo update
Configure environment variables.
export REPO="datacache/datacache-operator" export AK='<AccessKey ID>' export SK='<AccessKey Secret>' export REGION='<Region ID>'
Deploy the DataCache CRD.
helm install datacache-operator $REPO --set accessKey=$AK --set secretKey=$SK --set regionId=$REGION
Deploy a DataCache CRD by using a YAML file
Connect to the Kubernetes cluster.
Prepare a YAML configuration file named aliyun-datacache-controller.yaml for the DataCache CRD.
The following template provides the content of the YAML configuration file. Enter actual values for AccessKey ID (line 13), AccessKey secret (line 14), and region ID (line 211) in the template.
Deploy the DataCache CRD.
kubectl apply -f aliyun-datacache-controller.yaml