Accelerate hostPath volume access with JindoRuntime

更新时间:
复制 MD 格式

JindoRuntime is a Fluid runtime engine from Alibaba Cloud EMR, built on JindoFS. It caches hostPath volume data locally to accelerate access and can mount host directories to self-managed storage in hybrid cloud scenarios. This topic explains how to use JindoRuntime to accelerate hostPath volume access in ACK clusters.

JindoRuntime is a Fluid runtime engine from Alibaba Cloud EMR, built on JindoFS. It caches hostPath volume data in local memory or disk so reads are served from cache instead of the remote file system.

Use JindoRuntime to accelerate hostPath volume access in an ACK cluster.

Prerequisites

You need:

  • ACK Pro cluster on non-containerOS nodes (Kubernetes 1.18+)

    Important

    ack-fluid doesn't support ContainerOS.

  • ack-fluid component (version > 1.0.6) deployed in the cluster

    • If the cloud-native AI suite isn't installed, install it and enable Fluid acceleration.

    • If the suite is installed, log on to the ACK console and deploy ack-fluid from Cloud-native AI Suite.

    Important

    Uninstall open-source Fluid before installing ack-fluid.

How it works

The setup uses these Fluid components:

Component Role
Dataset Defines the hostPath data source and pod mount configuration.
JindoRuntime master Coordinates cache metadata.
JindoRuntime worker Stores cached data on each node (memory or disk per tieredstore config). Scale horizontally to add capacity.
JindoRuntime FUSE Exposes cached data as a POSIX file system to application pods.
DataLoad (optional) Prefetches data into cache before pods start to eliminate cold-read latency.

Pods access the dataset through a PVC that matches the Dataset name.

Step 1: Prepare the hostPath directories

JindoRuntime master and worker pods require nodes with the hostPath directory pre-created. Create the directory on each target node, then label those nodes to restrict scheduling.

  1. On each node where JindoRuntime runs, create the hostPath directory:

    mkdir /mnt/demo-remote-fs
  2. To create the directory remotely over SSH, replace the node names with yours:

    ssh cn-beijing.192.168.1.45 "mkdir -p /mnt/demo-remote-fs"
    ssh cn-beijing.192.168.2.234 "mkdir -p /mnt/demo-remote-fs"
  3. Label the nodes to restrict JindoRuntime scheduling:

    kubectl label node cn-beijing.192.168.1.45 demo-remote-fs=true
    kubectl label node cn-beijing.192.168.2.234 demo-remote-fs=true

Step 2: Create a Dataset and JindoRuntime

Create dataset.yaml with the following content:

apiVersion: data.fluid.io/v1alpha1
kind: Dataset
metadata:
  name: hostpath-demo-dataset
spec:
  mounts:
    - mountPoint: local:///mnt/demo-remote-fs
      name: data
      path: /
  accessModes:
    - ReadOnlyMany
---
apiVersion: data.fluid.io/v1alpha1
kind: JindoRuntime
metadata:
  name: hostpath-demo-dataset
spec:
  master:
    nodeSelector:
      demo-remote-fs: "true"
  worker:
    nodeSelector:
      demo-remote-fs: "true"
  fuse:
    nodeSelector:
      demo-remote-fs: "true"
  replicas: 2
  tieredstore:
    levels:
      - mediumtype: MEM
        volumeType: emptyDir
        path: /dev/shm
        quota: 10Gi
        high: "0.99"
        low: "0.99"

Key parameters:

Parameter Description
mountPoint Data source in local://<path> format. <path> is an absolute host path.
nodeSelector Restricts master, worker, and FUSE pods to nodes with the hostPath directory. Use the same selector for all three.
replicas Worker pod count. Increase to add cache capacity.
mediumtype Cache storage type. Valid values: HDD, SSD, MEM.
volumeType Cache medium mount type. Use emptyDir for memory (/dev/shm) or system disks to avoid residual data. Use hostPath for dedicated data disks and set path to the disk mount path. Default: hostPath.
path Directory for worker pod cache storage. /dev/shm (tmpfs) provides the highest throughput for memory caching.
quota Maximum cache size per worker pod.

Cache medium options:

Storage available mediumtype volumeType path
Memory or system disk MEM or SSD emptyDir /dev/shm or a tmpfs path
Dedicated local data disk SSD or HDD hostPath Host mount path of the data disk

Follow Policy 2: Select proper cache media for detailed recommendations.

Apply the configuration:

kubectl create -f dataset.yaml

Verify the Dataset is bound:

kubectl get dataset hostpath-demo-dataset

Expected output:

NAME                    UFS TOTAL SIZE   CACHED   CACHE CAPACITY   CACHED PERCENTAGE   PHASE   AGE
hostpath-demo-dataset   1.98GiB          0.00B    20.00GiB         0.0%                Bound   3m54s

When PHASE is Bound, JindoFS is running and pods can access the data.

Note

JindoFS pulls a container image on first launch, which may take 2–3 minutes depending on network speed.

(Optional) Step 3: Prefetch data with DataLoad

By default, the cache fills passively as pods read data—the first read for each file hits the remote file system. For latency-sensitive workloads, create a DataLoad object to prefetch the dataset before your application starts.

  1. Create dataload.yaml:

    Parameter Description
    dataset.name Dataset to prefetch.
    dataset.namespace Dataset namespace. Must match the DataLoad namespace.
    loadMetadata Set to true to sync metadata before prefetching.
    target[*].path Relative path within the Dataset mount point to prefetch.
    target[*].replicas Worker pods used to cache prefetched data.
    apiVersion: data.fluid.io/v1alpha1
    kind: DataLoad
    metadata:
      name: dataset-warmup
    spec:
      dataset:
        name: hostpath-demo-dataset
        namespace: default
      loadMetadata: true
      target:
        - path: /
          replicas: 1
  2. Create the DataLoad:

    kubectl create -f dataload.yaml
  3. Monitor prefetch progress:

    kubectl get dataload dataset-warmup

    Expected output after completion:

    NAME             DATASET           PHASE      AGE   DURATION
    dataset-warmup   pv-demo-dataset   Complete   62s   9s
  4. Verify full caching:

    kubectl get dataset

    Expected output:

    NAME                    UFS TOTAL SIZE   CACHED    CACHE CAPACITY   CACHED PERCENTAGE   PHASE   AGE
    hostpath-demo-dataset   1.98GiB          1.98GiB   20.00GiB         100.0%              Bound   7m24s

    When CACHED equals UFS TOTAL SIZE and CACHED PERCENTAGE is 100.0%, the dataset is fully cached.

Step 4: Access the cached data from a pod

Mount the Dataset as a PVC in your application pod. Set claimName to the Dataset name from Step 2.

  1. Create pod.yaml:

    apiVersion: v1
    kind: Pod
    metadata:
      name: nginx
    spec:
      containers:
        - name: nginx
          image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6
          command:
          - "bash"
          - "-c"
          - "sleep inf"
          volumeMounts:
            - mountPath: /data
              name: data-vol
      volumes:
        - name: data-vol
          persistentVolumeClaim:
            claimName: hostpath-demo-dataset  # Must match the Dataset name
  2. Create the pod:

    kubectl create -f pod.yaml
  3. Log on to the pod and read data:

    kubectl exec -it nginx bash

    In the pod, verify data access and measure read throughput:

    # List files in the mounted directory
    ls -lh /data

    Expected output:

    total 2.0G
    -rwxrwxr-x 1 root root 2.0G Jun  9 04:02 demo-file
    # Measure read throughput
    time cat /data/demofile > /dev/null

    Expected output:

    real    0m2.061s
    user    0m0.015s
    sys     0m0.581s

    Reads are served from the local JindoFS cache instead of the remote file system, reducing latency.

Next steps