In edge scenarios, Fluid's dataset acceleration engine can significantly improve OSS file access from edge nodes. This topic explains how to use Fluid data acceleration in an ACK Edge cluster.
Prerequisites
An ACK Edge cluster of version 1.18 or later is created.
The cloud-native AI suite is installed with the ack-fluid add-on deployed.
ImportantIf open-source Fluid is installed, uninstall it before deploying ack-fluid.
If the cloud-native AI suite is not installed: enable Fluid data acceleration when you install the suite.
If the cloud-native AI suite is already installed: deploy ack-fluid on the Cloud-native AI Suite page of the ACK Console.
The cluster is connected with kubectl.
OSS is activated.
Step 1: Prepare OSS data
Download the test data to an ECS instance.
wget https://archive.apache.org/dist/spark/spark-3.0.1/spark-3.0.1-bin-hadoop2.7.tgzUpload the downloaded test data to an OSS bucket.
ImportantThese steps use Alibaba Cloud Linux 3.2104 LTS 64-bit. For other systems, see ossutil quick start and ossutil command reference 1.0.
Create a bucket named
examplebucket.Create
examplebucket.ossutil mb oss://examplebucketexamplebucketcreated successfully:0.668238(s) elapsed
Upload the test data to
examplebucket.ossutil cp spark-3.0.1-bin-hadoop2.7.tgz oss://examplebucket
Step 2: Create a Dataset and a JindoRuntime
Create a file named
mySecret.yamlwith the following content. Replacexxxwith the AccessKey ID and AccessKey secret that have read access to the OSS bucket you created in Step 1.apiVersion: v1 kind: Secret metadata: name: mysecret stringData: fs.oss.accessKeyId: xxx fs.oss.accessKeySecret: xxxApply the Secret. Kubernetes encrypts the stored values so they are not exposed as plaintext.
kubectl create -f mySecret.yamlCreate a
resource.yamlfile with the following content:Define a Dataset that describes the remote storage and underlying file system (UFS).
Create a JindoRuntime to launch a JindoFS cluster for data caching.
apiVersion: data.fluid.io/v1alpha1 kind: Dataset metadata: name: hadoop spec: nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: alibabacloud.com/nodepool-id operator: In values: - npxxxxxxxxxxxxxx mounts: - mountPoint: oss://<oss_bucket>/<bucket_dir> options: fs.oss.endpoint: <oss_endpoint> name: hadoop path: "/" encryptOptions: - name: fs.oss.accessKeyId valueFrom: secretKeyRef: name: mysecret key: fs.oss.accessKeyId - name: fs.oss.accessKeySecret valueFrom: secretKeyRef: name: mysecret key: fs.oss.accessKeySecret --- apiVersion: data.fluid.io/v1alpha1 kind: JindoRuntime metadata: name: hadoop spec: nodeSelector: alibabacloud.com/nodepool-id: npxxxxxxxxxxxxxx replicas: 2 tieredstore: levels: - mediumtype: MEM path: /dev/shm volumeType: emptyDir quota: 2Gi high: "0.99" low: "0.95"NoteIn an ACK Edge cluster, use
nodeAffinityandnodeSelectorto deploy the Dataset and JindoRuntime to the same node pool so nodes within the pool can communicate.Edge node management and OSS access both require cloud-to-edge communication. Maintain sufficient network bandwidth to avoid destabilizing the control channel.
Parameters:
Parameter
Description
mountPoint
oss://<oss_bucket>/<bucket_dir>. UFS mount path. Must point to a directory. A single file cannot be mounted. Do not include the endpoint.fs.oss.endpoint
Public or internal endpoint of the OSS bucket. See Regions and endpoints.
replicas
Number of workers in the JindoFS caching cluster.
mediumtype
Cache storage medium. Valid values:
HDD,SSD,MEM.path
Local storage path on the worker node. Only one path is allowed. Required when
mediumtypeisMEMto store data such as logs.quota
Maximum cache size per worker.
high
Cache eviction threshold (high watermark). When usage exceeds this ratio, eviction begins.
low
Cache retention threshold (low watermark). Eviction stops when usage drops to this ratio.
Create the Dataset and JindoRuntime.
kubectl create -f resource.yamlVerify that the Dataset is bound.
kubectl get dataset hadoopExpected output:
NAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGE hadoop 210MiB 0.00B 4.00GiB 0.0% Bound 1hVerify that the JindoRuntime is ready.
kubectl get jindoruntime hadoopExpected output:
NAME MASTER PHASE WORKER PHASE FUSE PHASE AGE hadoop Ready Ready Ready 4m45sVerify that the persistent volume (PV) and persistent volume claim (PVC) are created.
kubectl get pv,pvcExpected output:
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE persistentvolume/hadoop 100Gi RWX Retain Bound default/hadoop 52m NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE persistentvolumeclaim/hadoop Bound hadoop 100Gi RWX 52m
The Dataset and JindoRuntime are ready when all phases show Ready and the PVC status is Bound.
Step 3: Test data access acceleration
Deploy a pod that mounts the Dataset PVC and compare file read times before and after data is cached.
Create an app.yaml file:
apiVersion: v1 kind: Pod metadata: name: demo-app spec: nodeSelector: alibabacloud.com/nodepool-id: npxxxxxxxxxxxxx containers: - name: demo image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6 volumeMounts: - mountPath: /data name: hadoop volumes: - name: hadoop persistentVolumeClaim: claimName: hadoopNoteIn an ACK Edge cluster, use
nodeSelectorto deploy the test pod to the node pool in Step 2.Deploy the pod.
kubectl create -f app.yamlOpen a shell in the pod and check the file size.
kubectl exec -it demo-app -- bash du -sh /data/spark-3.0.1-bin-hadoop2.7.tgzExpected output:
210M /data/spark-3.0.1-bin-hadoop2.7.tgzMeasure the initial read time. This access comes directly from OSS, with no cache.
time cp /data/spark-3.0.1-bin-hadoop2.7.tgz /dev/nullExpected output:
real 0m18.386s user 0m0.002s sys 0m0.105sReading the file takes about 18 seconds.
Check the cached data after the read.
kubectl get dataset hadoopExpected output:
NAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGE hadoop 210.00MiB 210.00MiB 4.00GiB 100.0% Bound 1hThe full 210 MiB is now cached in local storage.
Delete and recreate the pod to clear the OS page cache, so the next read comes from JindoFS cache rather than memory.
kubectl delete -f app.yaml && kubectl create -f app.yamlMeasure the read time again with data served from cache.
kubectl exec -it demo-app -- bash time cp /data/spark-3.0.1-bin-hadoop2.7.tgz /dev/nullExpected output:
real 0m0.048s user 0m0.001s sys 0m0.046sWith JindoFS cache, the same file read completes in 48 milliseconds — more than 300 times faster than the direct OSS access.
(Optional) Clean up
When data acceleration is no longer needed, delete the pod, the Dataset, and the JindoRuntime.
Delete the pod:
kubectl delete pod demo-appDelete the Dataset and JindoRuntime:
kubectl delete dataset hadoop