Descargar conjuntos de datos grandes en contenedores ECI suele provocar que el inicio del pod sea lento. El CRD de DataCache permite a los usuarios de Kubernetes descargar previamente los datos en una caché para que los contenedores inicien con la información ya disponible. En este tema se describe cómo desplegar el controlador del CRD de DataCache en un clúster de Kubernetes mediante Helm (recomendado) o un archivo YAML.
Facturación
|
Tipo de clúster |
Facturación |
|
Clúster de Container Service for Kubernetes (ACK) |
El CRD de DataCache se despliega en un nodo existente de Elastic Compute Service (ECS). No se aplican cargos adicionales. |
|
Clúster ACK Serverless |
Al desplegar el CRD de DataCache se crea un pod con 0.25 vCPU y 0.5 GiB de memoria. Este pod genera cargos: |
Requisitos previos
Antes de empezar, asegúrese de contar con lo siguiente:
-
Un AccessKey ID y un AccessKey secret con permisos para invocar las operaciones de la API de DataCache. Para más detalles, consulte Create an AccessKey pair
ImportanteLa cuenta de Alibaba Cloud o el usuario de RAM asociado al par de AccessKey debe tener permisos para invocar las operaciones de la API relacionadas con DataCache.
El identificador de la región del clúster
Despliegue con Helm (recomendado)
Helm es el método de despliegue recomendado. Gestiona las dependencias automáticamente y simplifica las actualizaciones.
Helm 3.7.0 o posterior
Conéctese al clúster de Kubernetes.
-
Compruebe su versión de Helm.
helm version -
Si usa la versión 3.7.x de Helm, habilite la compatibilidad con registros OCI.
export HELM_EXPERIMENTAL_OCI=1ImportanteHelm 3.7.x requiere esta bandera para extraer charts de registros compatibles con OCI. A partir de Helm 3.8.0, la compatibilidad con OCI viene habilitada de forma predeterminada; omita este paso si utiliza la versión 3.8.0 o posterior.
-
Establezca las variables de entorno.
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>'ImportanteEl valor
REPOapunta al registro de Container Registry de Alibaba Cloud que aloja el chart del operador de DataCache. No modifique el identificador de región incluido en la URL. -
Despliegue el CRD de DataCache.
helm install datacache-operator $REPO --set accessKey=$AK --set secretKey=$SK --set regionId=$REGION -
Compruebe el despliegue.
kubectl get pods -n datacache-controllerEl pod del controlador debe mostrar el estado
Running:NAME READY STATUS RESTARTS AGE aliyun-datacache-controller-xxxxxxxxx-xxxxx 1/1 Running 0 30s
Versiones de Helm anteriores a la 3.7.0
Conéctese al clúster de Kubernetes.
-
Compruebe su versión de Helm.
helm version -
Instale el plugin de Container Registry para Helm. Si tiene acceso a GitHub, ejecute el siguiente comando:
helm plugin install https://github.com/AliyunContainerService/helm-acrSi la conexión de red hacia GitHub es inestable, utilice el mirror de Alibaba Cloud:
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-acrImportanteEl comando
sedreemplaza la URL de descarga de GitHub en el script de instalación por una URL del mirror de Alibaba Cloud (helm-acr-releases.oss-cn-hangzhou.aliyuncs.com). Esta alternativa resulta más confiable en redes con acceso restringido a GitHub. -
Agregue el repositorio de Helm de DataCache.
helm repo add datacache acr://eci-release-chart.cn-hangzhou.cr.aliyuncs.com/datacache/datacache-operator helm repo update -
Establezca las variables de entorno.
export REPO="datacache/datacache-operator" export AK='<AccessKey ID>' export SK='<AccessKey secret>' export REGION='<Region ID>' -
Despliegue el CRD de DataCache.
helm install datacache-operator $REPO --set accessKey=$AK --set secretKey=$SK --set regionId=$REGION -
Compruebe el despliegue.
kubectl get pods -n datacache-controllerEl pod del controlador debe mostrar el estado
Running:NAME READY STATUS RESTARTS AGE aliyun-datacache-controller-xxxxxxxxx-xxxxx 1/1 Running 0 30s
Despliegue con un archivo YAML
Conéctese al clúster de Kubernetes.
-
Cree un archivo llamado
aliyun-datacache-controller.yamlcon el contenido que se muestra a continuación. Reemplace los tres valores de marcador de posición señalados con***en la plantilla: el AccessKey ID (línea 13), el AccessKey secret (línea 14) y el identificador de la región (línea 211).apiVersion: v1 kind: Namespace metadata: name: datacache-controller --- apiVersion: v1 kind: Secret metadata: name: accesskey.eci.aliyun.com namespace: datacache-controller type: Opaque stringData: accessKey: *** # Enter the AccessKey ID. secretKey: *** # Enter the AccessKey secret. --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: datacaches.eci.aliyun.com spec: group: eci.aliyun.com scope: Cluster names: kind: DataCache plural: datacaches singular: datacache shortNames: - edc categories: - all versions: - name: v1alpha1 served: true storage: true subresources: status: {} schema: openAPIV3Schema: type: object required: - spec properties: spec: type: object required: - path - dataSource properties: bucket: type: string default: default description: the name of a bucket. The default name is default. The bucket named eci-system is reserved to store common caches of Elastic Container Instance and cannot be used as a value. path: type: string description: the directory of the bucket. dataSource: type: object description: the cache data source. properties: type: type: string description: the property of the cache data source. Valid values: NAS, OSS, URL, and SNAPSHOT. options: type: object description: the options for a specific type of cache data source. For more information, see the DataCache documentation. x-kubernetes-preserve-unknown-fields: true size: type: integer default: 20 description: the size of the data cache. You must plan the size. Default value: 20 GiB, which is the minimum size of an elastic block storage (EBS). retentionDays: type: integer description: the retention period of the data cache. By default, data caches never expire. netConfig: type: object properties: securityGroupId: type: string description: the ID of the security group. vSwitchId: type: string description: the ID of the vSwitch. eipInstanceId: type: string description: the ID of the elastic IP address (EIP). If no source network address translation (SNAT) entry is created for the vSwitch, you can bind an EIP to pull Internet data. eipCreateParam: type: object description: the parameter that is used to create an EIP. You can specify EipInstanceId or EipCreateParam. properties: bandwidth: type: integer description: the public bandwidth. Unit: MB. Default value: 5. commonBandwidthPackage: type: string description: the EIP bandwidth plan. internetChargeType: type: string description: the billing method of the EIP. publicIpAddressPoolId: type: string description: the IP address pool. ISP: type: string description: the EIP line type. status: type: object properties: status: type: string progress: type: string snapshotId: type: string dataCacheId: type: string additionalPrinterColumns: - name: Age type: date jsonPath: .metadata.creationTimestamp - name: dataCacheId type: string jsonPath: .status.dataCacheId - name: Status type: string jsonPath: .status.status - name: Progress type: string jsonPath: .status.progress - name: Bucket type: string jsonPath: .spec.bucket - name: Path type: string jsonPath: .spec.path --- apiVersion: v1 kind: ServiceAccount metadata: name: aliyun-datacache-controller namespace: datacache-controller --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: aliyun-datacache-controller namespace: datacache-controller rules: - apiGroups: - "eci.aliyun.com" resources: - datacaches - datacaches/status verbs: - "*" - apiGroups: - "" resources: - events verbs: - create - patch - update - apiGroups: - "" resources: - configmaps verbs: - get --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: aliyun-datacache-controller roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: aliyun-datacache-controller subjects: - kind: ServiceAccount name: aliyun-datacache-controller namespace: datacache-controller --- apiVersion: apps/v1 kind: Deployment metadata: name: aliyun-datacache-controller namespace: datacache-controller spec: selector: matchLabels: app: aliyun-datacache-controller replicas: 1 template: metadata: labels: app: aliyun-datacache-controller spec: serviceAccountName: aliyun-datacache-controller containers: - name: datacache-operator image: eci-release-registry.cn-hangzhou.cr.aliyuncs.com/datacache/datacache-operator:latest resources: limits: memory: "512Mi" cpu: "250m" requests: memory: "64Mi" cpu: "50m" env: - name: REGION_ID value: *** # Specify the actual region ID. - name: ACCESS_KEY valueFrom: secretKeyRef: name: accesskey.eci.aliyun.com key: accessKey - name: SECRET_KEY valueFrom: secretKeyRef: name: accesskey.eci.aliyun.com key: secretKey -
Despliegue el CRD de DataCache.
kubectl apply -f aliyun-datacache-controller.yaml -
Compruebe el despliegue.
kubectl get pods -n datacache-controllerEl pod del controlador debe mostrar el estado
Running:NAME READY STATUS RESTARTS AGE aliyun-datacache-controller-xxxxxxxxx-xxxxx 1/1 Running 0 30s