In serverless scenarios, Fluid uses JindoRuntime to optimize access to Object Storage Service (OSS). Fluid supports both cache mode and no cache mode. This topic describes how to use no cache mode to accelerate data access for online applications.
Prerequisites
-
You have created an ACK Pro cluster of v1.18 or later that runs on an operating system other than ContainerOS. For more information, see Create an ACK Pro cluster.
ImportantThe ack-fluid component does not support ContainerOS.
-
You have installed the cloud-native AI suite and the ack-fluid component.
ImportantIf you have open-source Fluid installed, uninstall it before you deploy the ack-fluid component.
-
If you have not installed the cloud-native AI suite: deploy the Fluid component. For more information, see Install the cloud-native AI suite.
-
If you have installed the cloud-native AI suite: in the ACK console, go to the Cloud-native AI Suite page and deploy ack-fluid.
-
-
You have deployed a virtual node. For more information, see Create an ECI pod by deploying the ACK Virtual Node component.
-
You have connected to your Kubernetes cluster using kubectl. For more information, see Connect to a Kubernetes cluster by using kubectl.
-
You have activated Object Storage Service (OSS) and created a bucket. For more information, see Activate OSS and Create a bucket.
Limitations
This feature is incompatible with the elastic scheduling feature of ACK. For more information about the elastic scheduling feature, see Custom scheduling of elastic resources based on priorities.
Step 1: Upload test data to OSS
-
Create a 2 GB test file. This topic uses test as an example.
-
Upload the test file to your OSS bucket.
You can use ossutil, a client tool provided by OSS, to upload data. For more information, see Install ossutil.
Step 2: Create a dataset and a JindoRuntime
After configuring the Kubernetes and OSS environments, you can deploy the dataset and JindoRuntime in minutes.
-
Use the following content to create the secret.yaml file.
Before you create a dataset, you can create the following YAML file to save the OSS
fs.oss.accessKeyIdandfs.oss.accessKeySecret.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.yaml -
Use the following content to create a resource.yaml file.
The YAML file contains two resource definitions:
-
Dataset: Defines information about a remote storage dataset and UFS. -
JindoRuntime: Starts a JindoFS cluster and provides a caching service.
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.
Parameter
Description
mountPointSpecifies the path to mount the UFS. The path format is
oss://<oss_bucket>/<bucket_dir>.The path does not need to include Endpoint information. If you directly access the Bucket, you can omit
<bucket_dir>.fs.oss.endpointThe endpoint of the OSS bucket. You can specify a public or private endpoint.
Configuring a private endpoint can improve data access performance, but this requires that your K8s cluster and OSS are in the same region. For example, if your bucket is in the China (Hangzhou) region, the public endpoint is
oss-cn-hangzhou.aliyuncs.com, and the private endpoint isoss-cn-hangzhou-internal.aliyuncs.com.fs.oss.accessKeyIdThe AccessKey ID with permission to access the OSS bucket.
fs.oss.accessKeySecretThe AccessKey secret that corresponds to the AccessKey ID.
accessModesThe supported access modes include
ReadWriteOnce,ReadOnlyMany,ReadWriteMany, andReadWriteOncePod. The default value isReadOnlyMany.disabledThe Master and Worker are both set to
true, which enables no cache mode. -
-
Run the following command to deploy the JindoRuntime and dataset.
kubectl create -f resource.yaml -
Run the following command to check the status of the dataset.
kubectl get dataset serverless-dataExpected output:
NAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGE serverless-data Bound 1dA
PHASEofBoundindicates that the dataset is successfully deployed. -
Run the following command to check the status of the JindoRuntime.
kubectl get jindoruntime serverless-dataExpected output:
NAME MASTER PHASE WORKER PHASE FUSE PHASE AGE serverless-data Ready 3m41sThe expected output shows that
FUSEisReady, which indicates that the JindoRuntime is deployed successfully.
Step 3: Create a serverless application
You can create an application container or submit a machine learning job to use the JindoFS acceleration service. This topic uses a Deployment to create a serverless application that accesses data in OSS.
-
Create a serving.yaml file with 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-data -
Run the following command to create the application container.
kubectl create -f serving.yaml -
Check the test file size.
-
Run the following command to open a shell in the application container.
kubectl exec -it model-serving-85b645b5d5-2trnf -c serving -- bash -
In the pod, run the following command to check the test file size.
bash-4.4# du -sh /data/testExpected output:
2.0G /data/test
-
-
Run the following command to view the startup logs.
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:26As shown in the expected output, the
realfile copy time is0m27.107s. This copy time depends on network latency and bandwidth. If you want to accelerate data access, see Use cache mode to accelerate online application data access.
Step 4: Clean up the environment
When you no longer need the data access feature, you can clean up the resources.
-
Run the following command to delete the application Deployment.
kubectl delete deployment model-serving -
Run the following command to delete the dataset.
kubectl delete dataset serverless-data
Related documents
-
For more information about how to use no cache mode to accelerate data access, see Accelerate data access for Job applications and Accelerate data access for Argo workflows.
-
To accelerate data access in ACK by using cache mode, see Accelerate data access by using cache mode in ACK.
-
To accelerate data access in ACK serverless by using cache mode, see Use cache mode in ACK Serverless.