Fluid lets you use JindoRuntime to accelerate access to data stored in Object Storage Service (OSS) in serverless cloud computing scenarios. You can accelerate data access in cache mode and no cache mode. This topic describes how to accelerate online applications in no cache mode.
Prerequisites
A Container Service for Kubernetes (ACK) Pro cluster with non-containerOS is created, and the Kubernetes version of the cluster is 1.18 or later. For more information, see Create an ACK Pro cluster.
ImportantThe ack-fluid component is not currently supported on the ContainerOS.
The cloud-native AI suite is installed and the ack-fluid component is deployed.
ImportantIf you have installed open source Fluid, uninstall Fluid before you deploy the ack-fluid component.
If you have not installed the cloud-native AI suite: Deploy Fluid and enable data caching acceleration. For more information, see Deploy the cloud-native AI suite.
If you have already installed the cloud-native AI suite, go to the Marketplace page of the ACK console and deploy the ack-fluid component.
Virtual nodes are deployed in the ACK Pro cluster. For more information, see Schedule pods to elastic container instances.
A kubectl client is connected to the ACK Pro cluster. For more information, see Connect to a cluster using kubectl.
Object Storage Service (OSS) is activated and a bucket is created. For more information, see Activate OSS and Create buckets.
Limits
This feature is mutually exclusive with the elastic scheduling feature of ACK. For more information about the elastic scheduling feature of ACK, see Configure priority-based resource scheduling.
Step 1: Upload the test dataset to the OSS bucket
Create a test dataset of 2 GB in size. In this example, the test dataset is used.
Upload the test dataset to the OSS bucket that you created.
You can use the ossutil tool provided by OSS to upload data. For more information, see Install ossutil.
Step 2: Create a dataset and JindoRuntime
After you set up the ACK cluster and OSS bucket, you need to deploy the dataset and JindoRuntime. The deployment requires only a few minutes.
Create a file named secret.yaml based on the following content.
The file contains the
fs.oss.accessKeyIdandfs.oss.accessKeySecretthat are used to access the OSS bucket.apiVersion: v1 kind: Secret metadata: name: access-key stringData: fs.oss.accessKeyId: **** fs.oss.accessKeySecret: ****Run the following command to deploy the Secret:
kubectl create -f secret.yamlCreate a file named resource.yaml based on the following content.
The YAML file stores the following information:
Dataset: specifies the dataset that is stored in a remote datastore and the Unix file system (UFS) information.JindoRuntime: enables JindoFS for data caching in the cluster.
apiVersion: data.fluid.io/v1alpha1 kind: Dataset metadata: name: serverless-data spec: mounts: - mountPoint: oss://large-model-sh/ name: demo path: / options: fs.oss.endpoint: oss-cn-shanghai.aliyuncs.com encryptOptions: - name: fs.oss.accessKeyId valueFrom: secretKeyRef: name: access-key key: fs.oss.accessKeyId - name: fs.oss.accessKeySecret valueFrom: secretKeyRef: name: access-key key: fs.oss.accessKeySecret accessModes: - ReadWriteMany --- apiVersion: data.fluid.io/v1alpha1 kind: JindoRuntime metadata: name: serverless-data spec: master: disabled: true worker: disabled: trueThe following table describes some of the parameters that are specified in the preceding code block.
Parameter
Description
mountPointThe path to which the UFS file system is mounted. The format of the path is
oss://<oss_bucket>/<bucket_dir>.Do not include endpoint information in the path.
<bucket_dir>is optional if you can directly access the bucket.fs.oss.endpointThe public or private endpoint of the OSS bucket.
You can specify the private endpoint of the bucket to enhance data security. However, if you specify the private endpoint, make sure that your ACK cluster is deployed in the region where OSS is activated. For example, if your OSS bucket is created in the China (Hangzhou) region, the public endpoint of the bucket is
oss-cn-hangzhou.aliyuncs.comand the private endpoint isoss-cn-hangzhou-internal.aliyuncs.com.fs.oss.accessKeyIdThe AccessKey ID that is used to access the bucket.
fs.oss.accessKeySecretThe AccessKey secret that is used to access the bucket.
accessModesThe access mode. Valid values:
ReadWriteOnce,ReadOnlyMany,ReadWriteMany, andReadWriteOncePod. Default value:ReadOnlyMany.disabledIf you set this parameter to
truefor both master and worker nodes, the no cache mode is used.Run the following command to deploy the dataset and JindoRuntime:
kubectl create -f resource.yamlRun the following command to check whether the dataset is deployed:
kubectl get dataset serverless-dataExpected output:
NAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGE serverless-data Bound 1dBoundis displayed in thePHASEcolumn of the output. This indicates that the dataset is deployed.Run the following command to check whether the JindoRuntime is deployed:
kubectl get jindo serverless-dataExpected output:
NAME MASTER PHASE WORKER PHASE FUSE PHASE AGE serverless-data Ready 3m41sReadyis displayed in theFUSEcolumn of the output. This indicates that the JindoRuntime is deployed.
Step 3: Create serverless containers to access OSS
Create containers to test data access accelerated by JindoFS, or submit machine learning jobs to use relevant features. This section describes how to use a Deployment to create containers to access the data stored in OSS.
Create a file named serving.yaml based on the following content:
apiVersion: apps/v1 kind: Deployment metadata: name: model-serving spec: selector: matchLabels: app: model-serving template: metadata: labels: app: model-serving alibabacloud.com/fluid-sidecar-target: eci alibabacloud.com/eci: "true" annotations: k8s.aliyun.com/eci-use-specs: ecs.g7.4xlarge spec: containers: - image: fluidcloudnative/serving name: serving ports: - name: http1 containerPort: 8080 env: - name: TARGET value: "World" volumeMounts: - mountPath: /data name: data volumes: - name: data persistentVolumeClaim: claimName: serverless-dataDeploy the Deployment:
kubectl create -f serving.yamlCheck the size of the Serving file.
Log on to a container:
kubectl exec -it model-serving-85b645b5d5-2trnf -c serving -- bashQuery the size of the Serving file:
bash-4.4# du -sh /data/wwm_uncased_L-24_H-1024_A-16.zipExpected output:
1.2G /data/wwm_uncased_L-24_H-1024_A-16.zip
Print the container log:
kubectl logs model-serving-85b9587c5b-w5528 -c servingExpected output:
Begin loading models at 18:23:59 real 0m27.107s user 0m0.000s sys 0m0.742s Finish loading models at 18:24:26The
realfield in the output shows that it took 27.107 seconds (0m27.107s) to replicate the Serving file. The duration varies based on the network latency and bandwidth. To accelerate data access, see Accelerate online applications in cache mode.
Step 4: Clear data
If you no longer need data access acceleration, clear the environment.
Delete the containers:
kubectl delete deployment model-servingDelete the dataset:
kubectl delete dataset serverless-data
References
Accelerate online applications in no cache mode: Accelerate Jobs, Accelerate Argo workflows.
Accelerate online applications in no cache mode with ACK mode: ACK cache mode.
Accelerate online applications in no cache mode with ACK Serverless mode: ACK Serverless cache mode.