Carregar grandes conjuntos de dados em containers ECI frequentemente causa lentidão na inicialização dos pods. O CRD DataCache permite pré-carregar dados em um cache para que os containers do Kubernetes iniciem com as informações já disponíveis. Este tópico descreve como implantar o controlador do CRD DataCache em um cluster Kubernetes usando Helm (recomendado) ou um arquivo YAML.
Faturamento
|
Tipo de cluster |
Faturamento |
|
Cluster Container Service for Kubernetes (ACK) |
O CRD DataCache é implantado em um nó Elastic Compute Service (ECS) existente. Não há cobranças adicionais. |
|
Cluster ACK Serverless |
A implantação do CRD DataCache cria um pod com 0,25 vCPU e 0,5 GiB de memória. Esse pod gera custos: |
Pré-requisitos
Antes de começar, verifique se você tem:
-
Um AccessKey ID e um AccessKey secret com permissões para chamar operações da API do DataCache. Para mais detalhes, consulte Criar um par de AccessKey
ImportanteA conta Alibaba Cloud ou o usuário RAM associado ao par de AccessKey deve ter permissões para chamar operações de API relacionadas ao DataCache.
O ID da região do cluster
Implantação via Helm (recomendado)
Recomendamos o uso do Helm para implantação, pois ele gerencia dependências e simplifica atualizações.
Helm 3.7.0 ou posterior
Conecte-se ao cluster Kubernetes.
-
Verifique a versão do Helm.
helm version -
Se utilizar a versão 3.7.x do Helm, ative o suporte a registro OCI.
export HELM_EXPERIMENTAL_OCI=1ImportanteO Helm 3.7.x exige esse sinalizador para baixar charts de registros compatíveis com OCI. As versões 3.8.0 e posteriores já habilitam o suporte a OCI por padrão. Ignore esta etapa se estiver usando a versão 3.8.0 ou superior.
-
Defina as variáveis de ambiente.
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>'ImportanteO valor de
REPOaponta para o Alibaba Cloud Container Registry que hospeda o chart do operador DataCache. Não altere o ID da região incorporado na URL. -
Implante o CRD DataCache.
helm install datacache-operator $REPO --set accessKey=$AK --set secretKey=$SK --set regionId=$REGION -
Verifique a implantação.
kubectl get pods -n datacache-controllerO pod do controlador deve estar no estado
Running:NAME READY STATUS RESTARTS AGE aliyun-datacache-controller-xxxxxxxxx-xxxxx 1/1 Running 0 30s
Helm anterior à versão 3.7.0
Conecte-se ao cluster Kubernetes.
-
Verifique a versão do Helm.
helm version -
Instale o plugin do Container Registry para o Helm. Se tiver acesso ao GitHub, execute:
helm plugin install https://github.com/AliyunContainerService/helm-acrSe a conexão com o GitHub estiver instável, utilize o espelho da 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-acrImportanteO comando
sedsubstitui a URL de download do GitHub no script de instalação por uma URL de espelho da Alibaba Cloud (helm-acr-releases.oss-cn-hangzhou.aliyuncs.com). Isso oferece maior confiabilidade em redes com acesso restrito ao GitHub. -
Adicione o repositório Helm do DataCache.
helm repo add datacache acr://eci-release-chart.cn-hangzhou.cr.aliyuncs.com/datacache/datacache-operator helm repo update -
Defina as variáveis de ambiente.
export REPO="datacache/datacache-operator" export AK='<AccessKey ID>' export SK='<AccessKey secret>' export REGION='<Region ID>' -
Implante o CRD DataCache.
helm install datacache-operator $REPO --set accessKey=$AK --set secretKey=$SK --set regionId=$REGION -
Verifique a implantação.
kubectl get pods -n datacache-controllerO pod do controlador deve estar no estado
Running:NAME READY STATUS RESTARTS AGE aliyun-datacache-controller-xxxxxxxxx-xxxxx 1/1 Running 0 30s
Implantação via arquivo YAML
Conecte-se ao cluster Kubernetes.
-
Crie um arquivo chamado
aliyun-datacache-controller.yamlcom o conteúdo abaixo. Substitua os três valores de espaço reservado marcados com***no modelo: o AccessKey ID (linha 13), o AccessKey secret (linha 14) e o ID da região (linha 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 -
Implante o CRD DataCache.
kubectl apply -f aliyun-datacache-controller.yaml -
Verifique a implantação.
kubectl get pods -n datacache-controllerO pod do controlador deve estar no estado
Running:NAME READY STATUS RESTARTS AGE aliyun-datacache-controller-xxxxxxxxx-xxxxx 1/1 Running 0 30s