On ACK Serverless, deploy Fluid to cache OSS data locally so repeated Job reads finish in under one second. The Fluid controller, cache system, and application pods can all run in the Serverless environment.
Deploy Fluid, configure a Dataset and JindoRuntime backed by an OSS bucket, and run a Job that reads cached data.
Prerequisites
Ensure that you have:
-
An ACK Serverless cluster running Kubernetes 1.18 or later with CoreDNS.
-
kubectl configured to connect to the cluster.
-
An activated OSS instance with a bucket ready.
Limitations
Fluid conflicts with the virtual node scheduling feature of ACK Serverless clusters — you cannot use both. See Enable the virtual node scheduling policy for a cluster.
To avoid this, all JindoRuntime cache worker and application pods must include the alibabacloud.com/burst-resource: eci_only annotation. This annotation appears in the YAML examples below.
Deploy the Fluid control plane
If open-source Fluid is installed, uninstall it before deploying ack-fluid.
-
In the ACK console, click Clusters in the navigation pane.
-
Click the cluster name. In the navigation pane, click Applications > Helm.
-
On the Helm page, click Deploy.
-
In Basic Information, set these parameters, then click Next.
The default release name is
ack-fluidand namespace isfluid-system. If you change them, a Confirm dialog appears — click Yes to revert.Parameter Value Source Marketplace Chart Search for and select ack-fluid -
In Parameters, click OK.
-
Verify that the Fluid control plane is running:
-
Dataset Controller — manages Dataset CR lifecycles.
-
Fluid Webhook — injects a caching sidecar into application pods for transparent data access in Serverless scenarios. — injects a caching sidecar into application pods for transparent data access.
The Fluid control plane also includes controllers for JindoFS, JuiceFS, and Alluxio. These scale on demand when you configure each caching system.
kubectl get pod -n fluid-systemExpected output:
NAME READY STATUS RESTARTS AGE dataset-controller-d99998f79-dgkmh 1/1 Running 0 2m48s fluid-webhook-55c6d9d497-dmrzb 1/1 Running 0 2m49sThe two components serve distinct roles:
-
Accelerate data access
Upload test data to OSS
-
Create a 2 GB test file such as this sample dataset.
-
Upload the file to your OSS bucket with ossutil.
Create the Dataset and JindoRuntime resources
This example uses JindoFS as the cache backend (JindoRuntime). Fluid represents data sources as two Custom Resources (CRs):
-
Dataset — points to data in the external storage system.
-
JindoRuntime — defines caching system configuration.
Fluid uses lazy loading: first access fetches from OSS to local cache; subsequent reads come from cache. To eliminate first-run latency, pre-warm the cache before submitting your Job.
-
Create a Secret to store the OSS credentials:
kubectl create secret generic oss-access-key \ --from-literal=fs.oss.accessKeyId=<access_key_id> \ --from-literal=fs.oss.accessKeySecret=<access_key_secret> -
Create a file named
dataset.yaml:Parameter Description mountPointOSS mount path in oss://<bucket_name>/<bucket_path>format. Setpathto/for a single mount point.fs.oss.endpointOSS bucket endpoint. Use an internal endpoint (e.g., oss-cn-hangzhou-internal.aliyuncs.com) for same-region access; use a public endpoint (e.g.,oss-cn-hangzhou.aliyuncs.com) otherwise.replicasNumber of cache worker pods. Determines total cache capacity. alibabacloud.com/burst-resource: eci_onlyDisables virtual node scheduling on cache worker pods. Required — Fluid conflicts with virtual node scheduling (see Limitations). k8s.aliyun.com/eci-use-specsECI instance spec for each cache worker pod. k8s.aliyun.com/eci-image-cacheEnables instance image cache to speed up pod startup. tieredstore.levels.mediumtypeCache medium. Valid values: MEM(memory),SSD,HDD. See Select a cache medium.tieredstore.levels.volumeTypeVolume type. Use emptyDirfor memory or system disk (prevents residual cache from affecting node availability). UsehostPathfor data disks and setpathto the mount point. Default:hostPath.tieredstore.levels.pathCache path. Only one path supported. tieredstore.levels.quotaMaximum cache capacity per worker, for example 10Gi.tieredstore.levels.high/lowHigh and low watermarks for cache eviction. apiVersion: data.fluid.io/v1alpha1 kind: Dataset metadata: name: demo-dataset spec: mounts: - mountPoint: oss://<bucket_name>/<bucket_path> name: demo path: / options: fs.oss.endpoint: oss-<region>.aliyuncs.com encryptOptions: - name: fs.oss.accessKeyId valueFrom: secretKeyRef: name: oss-access-key key: fs.oss.accessKeyId - name: fs.oss.accessKeySecret valueFrom: secretKeyRef: name: oss-access-key key: fs.oss.accessKeySecret --- apiVersion: data.fluid.io/v1alpha1 kind: JindoRuntime metadata: name: demo-dataset spec: # Number of cache worker nodes replicas: 2 worker: podMetadata: annotations: # Required: disable virtual node scheduling (conflicts with Fluid — see Limitations) alibabacloud.com/burst-resource: eci_only # ECI instance spec for the JindoFS cache worker pod k8s.aliyun.com/eci-use-specs: <eci_instance_spec> # Enable instance image cache to speed up pod startup k8s.aliyun.com/eci-image-cache: "true" tieredstore: levels: # 10 GiB of memory cache per worker node - mediumtype: MEM volumeType: emptyDir path: /dev/shm quota: 10Gi high: "0.99" low: "0.99"Key parameters:
-
Apply the manifest:
kubectl create -f dataset.yaml -
Wait one to two minutes for the caching system to deploy, then verify the Dataset status:
If
PHASEshowsNotBound, the caching system is still initializing. Wait one to two minutes and recheck.kubectl get dataset demo-datasetExpected output:
NAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGE demo-dataset 1.16GiB 0.00B 20.00GiB 0.0% Bound 2m58sPHASE: Boundconfirms successful deployment. Other columns show OSS data size, cached amount, and total cache capacity.
Pre-warm the cache (optional)
Fluid uses lazy loading, so the first Job run fetches from OSS and can take tens of seconds for large datasets. Pre-warm the cache to eliminate first-run latency.
-
Create a file named
dataload.yaml:apiVersion: data.fluid.io/v1alpha1 kind: DataLoad metadata: name: data-warmup spec: dataset: name: demo-dataset namespace: default loadMetadata: true -
Start the pre-warm job:
kubectl create -f dataload.yamlWait until status shows
Complete:NAME DATASET PHASE AGE DURATION data-warmup demo-dataset Complete 99s 58sCache warm-up completed in about
58s.
Create a Job application
Use application containers or machine learning jobs to access accelerated data through JindoFS. This example creates a Job that reads OSS data.demo-dataset PVC read from JindoFS cache automatically — no code changes needed. The alibabacloud.com/fluid-sidecar-target: eci label triggers Fluid Webhook to inject the caching sidecar.
-
Create a file named
job.yaml:apiVersion: batch/v1 kind: Job metadata: name: demo-app spec: template: metadata: labels: alibabacloud.com/fluid-sidecar-target: eci annotations: # Required: disable virtual node scheduling (conflicts with Fluid — see Limitations) alibabacloud.com/burst-resource: eci_only # ECI instance spec for the application pod k8s.aliyun.com/eci-use-specs: ecs.g7.4xlarge spec: containers: - name: demo image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6 command: - /bin/bash args: - -c - du -sh /data && time cp -r /data/ /tmp volumeMounts: - mountPath: /data name: demo restartPolicy: Never volumes: - name: demo persistentVolumeClaim: claimName: demo-dataset backoffLimit: 4 -
Submit the Job:
kubectl create -f job.yaml -
Check the Job logs after it completes:
kubectl logs demo-app-jwktf -c demoExpected output:
1.2G /data real 0m0.992s user 0m0.004s sys 0m0.674sThe
realtime for the file copy is0m0.992s.
Clean up
Clean up resources to avoid unnecessary charges.
-
Delete the Job:
kubectl delete job demo-app -
Delete the Dataset. This also removes the associated caching system components:
ImportantCleanup takes about one minute. Wait until all caching pods are deleted before proceeding.
kubectl delete dataset demo-dataset -
Scale down the Fluid control plane:
kubectl get deployments.apps -n fluid-system | awk 'NR>1 {print $1}' | xargs kubectl scale deployments -n fluid-system --replicas=0To re-enable data access, scale the control plane back up before creating new Dataset and JindoRuntime resources:
kubectl scale -n fluid-system deployment dataset-controller --replicas=1 kubectl scale -n fluid-system deployment fluid-webhook --replicas=1