You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Typically, you will see a Pod named `dataset-controller`, a Pod named `juicefsruntime-controller`, a Pod
34
+
named `fluid-webhook` and a Pod named `fluidapp-controller`.
35
+
36
+
## Demo
37
+
38
+
**Create dataset and runtime**
39
+
40
+
Create corresponding Runtime resources and Datasets with the same name for different types of runtimes. Take JuiceFSRuntime as an example here. For details, please refer to [Documentation](https://github.com/fluid-cloudnative/fluid/blob/master/docs/en/samples/juicefs_runtime.md), as follows:
41
+
42
+
```shell
43
+
$ kubectl get juicefsruntime
44
+
NAME WORKER PHASE FUSE PHASE AGE
45
+
jfsdemo Ready Ready 2m58s
46
+
$ kubectl get dataset
47
+
NAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGE
48
+
jfsdemo [Calculating] N/A N/A Bound 2m55s
49
+
```
50
+
51
+
**Create Job**
52
+
53
+
To use Fluid in a serverless scenario, you need to add the `serverless.fluid.io/inject: "true"` label to the application pod. as follows:
54
+
55
+
```yaml
56
+
$ cat<<EOF >sample.yaml
57
+
apiVersion: batch/v1
58
+
kind: Job
59
+
metadata:
60
+
name: demo-app
61
+
spec:
62
+
template:
63
+
metadata:
64
+
labels:
65
+
serverless.fluid.io/inject: "true"
66
+
spec:
67
+
containers:
68
+
- name: demo
69
+
image: busybox
70
+
args:
71
+
- -c
72
+
- echo $(date -u) >> /data/out.txt
73
+
command:
74
+
- /bin/sh
75
+
volumeMounts:
76
+
- mountPath: /data
77
+
name: demo
78
+
restartPolicy: Never
79
+
volumes:
80
+
- name: demo
81
+
persistentVolumeClaim:
82
+
claimName: jfsdemo
83
+
backoffLimit: 4
84
+
EOF
85
+
$ kubectl create -f sample.yaml
86
+
job.batch/demo-app created
87
+
```
88
+
89
+
**Check if the Pod is completed**
90
+
91
+
```shell
92
+
$ kubectl get job
93
+
NAME COMPLETIONS DURATION AGE
94
+
demo-app 1/1 14s 46s
95
+
$ kubectl get po
96
+
NAME READY STATUS RESTARTS AGE
97
+
demo-app-wdfr8 0/2 Completed 0 25s
98
+
jfsdemo-worker-0 1/1 Running 0 14m
99
+
```
100
+
101
+
It can be seen that the job has been completed, and its pod has two containers, both of which have been completed.
Copy file name to clipboardExpand all lines: docs/Tutorials/Advanced/Serverless/how-to-run-in-knative-environment.md
+284-1
Original file line number
Diff line number
Diff line change
@@ -3,4 +3,287 @@ sidebar_label: How to Run in Knative Environment
3
3
sidebar_position: 1
4
4
---
5
5
6
-
# Accelerate Data Access by MEM or SSD
6
+
# How to Run in Knative Environment
7
+
8
+
This example uses the open source framework Knative as an example to demonstrate how to perform unified data acceleration via Fluid in a Serverless environment. This example uses AlluxioRuntime as an example, and in fact Fluid supports all Runtime running in a Serverless environment.
9
+
10
+
## Installation
11
+
12
+
1.Install Knative Serving v1.2 according to the [Knative documentation](https://knative.dev/docs/install/serving/install-serving-with-yaml/), you need to enable the [kubernetes.Deploymentspec-persistent-volume-claim](https://github.com/knative/serving/blob/main/config/core/configmaps/features.yaml#L156) option.
13
+
14
+
15
+
Check if Knative's components are working properly
16
+
17
+
```
18
+
kubectl get Deployments -n knative-serving
19
+
```
20
+
21
+
> Note: This document is just for demonstration purpose, please refer to the best practices of Knative documentation for Knative deployment in production environment. Also, since the container images of Knative are in the gcr.io image repository, please make sure the images are reachable. If you are using AliCloud, you can also use [AliCloud ACK](https://help.aliyun.com/document_detail/121508.html) hosting service directly to reduce the complexity of configuring Knative.
22
+
23
+
2.Please refer to the [installation documentation](/docs/get-started/installation) to install the latest Fluid, and check that the Fluid components are working properly after installation (this document uses AlluxioRuntime as an example):
24
+
25
+
```shell
26
+
$ kubectl get deploy -n fluid-system
27
+
NAME READY UP-TO-DATE AVAILABLE AGE
28
+
alluxioruntime-controller 1/1 1 1 18m
29
+
dataset-controller 1/1 1 1 18m
30
+
fluid-webhook 1/1 1 1 18m
31
+
```
32
+
33
+
Typically, you can see a Deployment named `dataset-controller`, a Deployment named `alluxioruntime-controller`, and a Deployment named `fluid-webhook`.
34
+
35
+
## Configuration
36
+
37
+
## Running
38
+
39
+
**Create dataset and runtime**
40
+
41
+
Create Runtime resources for different types of Runtime, as well as a Dataset with the same name. Here is the example of AlluxioRuntime, the following is the Dataset content:
Checking the boot time at this point reveals that the current boot time for loading data is **3.66s**, which becomes **1/20** of the performance without warm-up.
2022-02-15 18:38:25 INFO Hello world sample started.
218
+
```
219
+
220
+
> Note: This example uses Knative serving. If you don't have a Knative environment, you can also experiment with Deployment.
221
+
222
+
```yaml
223
+
apiVersion: apps/v1
224
+
kind: Deployment
225
+
metadata:
226
+
name: model-serving
227
+
spec:
228
+
selector:
229
+
matchLabels:
230
+
app: model-serving
231
+
template:
232
+
metadata:
233
+
labels:
234
+
app: model-serving
235
+
serverless.fluid.io/inject: "true"
236
+
spec:
237
+
containers:
238
+
- image: fluidcloudnative/serving
239
+
name: serving
240
+
ports:
241
+
- name: http1
242
+
containerPort: 8080
243
+
env:
244
+
- name: TARGET
245
+
value: "World"
246
+
volumeMounts:
247
+
- mountPath: /data
248
+
name: data
249
+
volumes:
250
+
- name: data
251
+
persistentVolumeClaim:
252
+
claimName: serverless-data
253
+
```
254
+
255
+
> Note: The default sidecar injection mode does not enable cached directory short-circuit reads, if you need to enable this capability, you can configure the parameter `cachedir.sidecar.fluid.io/inject` to `true` in the labels.
0 commit comments