Share Data across Namespace (Sidecar mode)
This tutorial is used to show how to use a Dataset cache across Namespace.
- In Namespace
ns-a
, create Datasetdemo
and AlluxioRuntimedemo
- In Namespace
ns-b
create Datasetdemo-ref
. The mountPoint ofdemo-ref
isdataset://ns-a/demo
Prerequests
Before running this tutorial, please refer to the installation documentation to complete the installation and check that the components of Fluid are working properly:
$ kubectl get pod -n fluid-system
alluxioruntime-controller-5b64fdbbb-84pc6 1/1 Running 0 8h
csi-nodeplugin-fluid-fwgjh 2/2 Running 0 8h
csi-nodeplugin-fluid-ll8bq 2/2 Running 0 8h
dataset-controller-5b7848dbbb-n44dj 1/1 Running 0 8h
thinruntime-controller-7dcbf5f45-xsf4p 1/1 Running 0 8h
Where thinruntime-controller
is used to support Dataset sharing across Namespace and alluxioruntime-controller
is the actual cache.
Share Dataset cache across Namespace through CSI mechanism
1. Create Dataset and Cache Runtime
In default Namespace,create phy
Dataset and AlluxioRuntime.
$ cat<<EOF >ds.yaml
apiVersion: data.fluid.io/v1alpha1
kind: Dataset
metadata:
name: phy
spec:
mounts:
- mountPoint: https://mirrors.bit.edu.cn/apache/spark/
name: spark
---
apiVersion: data.fluid.io/v1alpha1
kind: AlluxioRuntime
metadata:
name: phy
spec:
replicas: 1
tieredstore:
levels:
- mediumtype: MEM
path: /dev/shm
quota: 1Gi
high: "0.95"
low: "0.7"
EOF
$ kubectl create -f ds.yaml
2. Create referenced Dataset and Runtime
In Namespace ref
, create:
- the referenced dataset
refdemo
, whose mountPoint format isdataset://${origin-dataset-namespace}/${origin-dataset-name}
. - ThinRuntime
refdemo
, and its Spec fields don't need to be filled.
Note:
- Currently, the referenced Dataset only supports single mount and its form must be
dataset://
(i.e. the creation of a dataset fails whendataset://
and other forms both appear), and other fields in the Spec are invalid. - The fields in Spec of the referenced Runtime corresponding to the Dataset are invalid.
$ kubectl create ns ref
$ cat<<EOF >ds-ref.yaml
apiVersion: data.fluid.io/v1alpha1
kind: Dataset
metadata:
name: refdemo
spec:
mounts:
- mountPoint: dataset://default/phy
name: fusedemo
path: "/"
EOF
$ kubectl create -f ds-ref.yaml -n ref
Create Pod and Check the data
In Namespace ref
, create a Pod:
Need to enable serverless injection, set pod tag serverless.fluid.io/inject=true
$ cat<<EOF >app-ref.yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
serverless.fluid.io/inject: "true"
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- mountPath: /data_spark
name: spark-vol
volumes:
- name: spark-vol
persistentVolumeClaim:
claimName: refdemo
EOF
$ kubectl create -f app-ref.yaml -n ref