Unverified Commit 2f7cb947 authored by cheyang's avatar cheyang Committed by GitHub
Browse files

Docs for serverless (#1443)


* Add doc, To #37688693
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Build docker image, To #39482462
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Build docker image, To #39482462
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Build docker image, To #39482462
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Fluid for serverless, To #37688693
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Fluid for serverless, To #37688693
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Fluid for serverless, To #37688693
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Fluid for serverless, To #37688693
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Fluid for serverless, To #37688693
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Fix update dataload status error, To #37688693
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Build docker image, To #39482462
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Build docker image, To #39482462
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Build docker image, To #39482462
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Fluid for serverless, To #37688693
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Fluid for serverless, To #37688693
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Fluid for serverless, To #37688693
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Fluid for serverless, To #37688693
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Add volume, To #38946668
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Add volume, To #38946668
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Add doc, To #38946668
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Add doc, To #38946668
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Fluid for serverless, To #37688693
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Add doc, To #38946668
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Fix ut, To #38946668
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Fix ut, To #38946668
Signed-off-by: default avatarcheyang <cheyang@163.com>

* Update docs, To #39482462
Signed-off-by: default avatarcheyang <cheyang@163.com>
parent 07ac3c22
Showing with 10222 additions and 1 deletion
+10222 -1
......@@ -30,6 +30,7 @@
+ 进阶使用
- [AlluxioRuntime分层存储配置](samples/tieredstore_config.md)
- [通过Webhook机制优化Pod调度](operation/pod_schedule.md)
- [如何在Knative环境运行](samples/knative.md)
- [如何开启 FUSE 自动恢复能力](samples/fuse_recover.md)
+ 工作负载
- [机器学习](samples/machinelearning.md)
......
......@@ -8,7 +8,7 @@ Fluid结合根据数据集排布的Pod调度策略,通过webhook机制将调
## 前提条件
您使用的k8s版本需要支持 admissionregistration.k8s.io/v1beta1( Kubernetes version > 1.14 )
您使用的k8s版本需要支持 admissionregistration.k8s.io/v1( Kubernetes version > 1.16 )
启用允许控制器集需要通过向 Kubernetes API 服务器传递一个标志来配置,确保你的集群进行了正常的配置
```yaml
--enable-admission-plugins=MutatingAdmissionWebhook
......
# 示例 - 如何运行在以Knative为例的Serverless环境中
本示例以开源框架Knative为例子,演示如何在Serverless环境中通过Fluid进行统一的数据加速,本例子以AlluxioRuntime为例,实际上Fluid支持所有的Runtime运行在Serverless环境。
## 安装
1.根据[Knative文档](https://knative.dev/docs/install/serving/install-serving-with-yaml/)安装Knative Serving v1.2,需要开启[kubernetes.Deploymentspec-persistent-volume-claim](https://github.com/knative/serving/blob/main/config/core/configmaps/features.yaml#L156)
检查 Knative的组件是否正常运行
```
kubectl get Deployments -n knative-serving
```
> 注:本文只是作为演示目的,关于Knative的生产系统安装请参考Knative文档最佳实践进行部署。另外由于Knative的容器镜像都在gcr.io镜像仓库,请确保镜像可达。
如果您使用的是阿里云,您也可以直接使用[阿里云ACK的托管服务](https://help.aliyun.com/document_detail/121508.html)降低配置Knative的复杂度。
2. 请参考[安装文档](../userguide/install.md)安装Fluid最新版, 安装后检查 Fluid 各组件正常运行(这里以 AlluxioRuntime 为例):
```shell
$ kubectl get deploy -n fluid-system
NAME READY UP-TO-DATE AVAILABLE AGE
alluxioruntime-controller 1/1 1 1 18m
dataset-controller 1/1 1 1 18m
fluid-webhook 1/1 1 1 18m
```
通常来说,你会看到一个名为 `dataset-controller` 的 Deployment、一个名为 `alluxioruntime-controller` 的 Deployment、一个名为 `fluid-webhook` 的 Deployment。
## 配置
**为namespace添加标签**
为namespace添加标签fluid.io/enable-injection后,可以开启此namespace下Pod的调度优化功能
```bash
$ kubectl label namespace default fluid.io/enable-injection=true
```
## 运行示例
**创建 dataset 和 runtime**
针对不同类型的 runtime 创建相应的 Runtime 资源,以及同名的 Dataset。这里以 AlluxioRuntime 为例, 以下为Dataset内容
```yaml
$ cat<<EOF >dataset.yaml
apiVersion: data.fluid.io/v1alpha1
kind: Dataset
metadata:
name: serverless-data
spec:
mounts:
- mountPoint: https://mirrors.bit.edu.cn/apache/hbase/stable/
name: hbase
path: "/"
accessModes:
- ReadOnlyMany
---
apiVersion: data.fluid.io/v1alpha1
kind: AlluxioRuntime
metadata:
name: serverless-data
spec:
replicas: 2
tieredstore:
levels:
- mediumtype: MEM
path: /dev/shm
quota: 2Gi
high: "0.95"
low: "0.7"
EOF
```
执行创建Dataset操作
```
$ kubectl create -f dataset.yaml
```
查看Dataset状态
```shell
$ kubectl get alluxio
NAME MASTER PHASE WORKER PHASE FUSE PHASE AGE
serverless-data Ready Ready Ready 4m52s
$ kubectl get dataset
NAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGE
serverless-data 566.22MiB 0.00B 4.00GiB 0.0% Bound 4m52s
```
**创建 Knative Serving 资源对象**
```yaml
$ cat<<EOF >serving.yaml
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: model-serving
spec:
template:
metadata:
labels:
app: model-serving
serverless.fluid.io/inject: "true"
annotations:
autoscaling.knative.dev/target: "10"
autoscaling.knative.dev/scaleDownDelay: "30m"
autoscaling.knative.dev/minScale: "1"
spec:
containers:
- image: fluidcloudnative/serving
ports:
- name: http1
containerPort: 8080
env:
- name: TARGET
value: "World"
volumeMounts:
- mountPath: /data
name: data
readOnly: true
volumes:
- name: data
persistentVolumeClaim:
claimName: serverless-data
readOnly: true
EOF
$ kubectl create -f serving.yaml
service.serving.knative.dev/model-serving created
```
请在podSpec或者podTemplateSpec中的label中配置`serverless.fluid.io/inject: "true"`
**查看 Knative Serving 是否创建,并检查 fuse-container 是否注入**
```shell
$ kubectl get po
NAME READY STATUS RESTARTS AGE
model-serving-00001-deployment-64d674d75f-46vvf 3/3 Running 0 76s
serverless-data-master-0 2/2 Running 0 16m
serverless-data-worker-0 2/2 Running 0 16m
serverless-data-worker-1 2/2 Running 0 16m
$ kubectl get po model-serving-00001-deployment-64d674d75f-46vvf -oyaml| grep -i fluid-fuse -B 3
- /opt/alluxio/integration/fuse/bin/alluxio-fuse
- unmount
- /runtime-mnt/alluxio/default/serverless-data/alluxio-fuse
name: fluid-fuse
```
查看 Knative Serving 启动速度,可以看到启动加载数据的时间是**43s**
```shell
$ kubectl logs model-serving-00001-deployment-64d674d75f-46vvf -c user-container
Begin loading models at 16:29:02
real 0m43.480s
user 0m0.001s
sys 0m0.956s
Finish loading models at 16:29:45
2022-02-15 16:29:45 INFO Hello world sample started.
```
清理knative serving实例
```
$ kubectl delete -f serving.yaml
```
**执行数据预热**
创建dataload对象,并查看状态:
```yaml
$ cat<<EOF >dataload.yaml
apiVersion: data.fluid.io/v1alpha1
kind: DataLoad
metadata:
name: serverless-dataload
spec:
dataset:
name: serverless-data
namespace: default
EOF
$ kubectl create -f dataload.yaml
dataload.data.fluid.io/serverless-dataload created
$ kubectl get dataload
NAME DATASET PHASE AGE DURATION
serverless-dataload serverless-data Complete 2m43s 34s
```
检查此时的缓存状态, 目前已经将数据完全缓存到集群中
```
$ kubectl get dataset
NAME UFS TOTAL SIZE CACHED CACHE CAPACITY CACHED PERCENTAGE PHASE AGE
serverless-data 566.22MiB 566.22MiB 4.00GiB 100.0% Bound 33m
```
再次创建Knative服务:
```shell
$ kubectl create -f serving.yaml
service.serving.knative.dev/model-serving created
```
此时查看启动时间发现当前启动加载数据的时间是**2.19s**, 变成没有预热的情况下性能的**1/20**
```
kubectl logs model-serving-00001-deployment-6cb54f94d7-dbgxf -c user-container
Begin loading models at 18:38:23
real 0m2.190s
user 0m0.000s
sys 0m0.899s
Finish loading models at 18:38:25
2022-02-15 18:38:25 INFO Hello world sample started.
```
> 注: 本例子使用的是Knative serving,如果您没有Knative环境,也可以使用Deployment进行实验。
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: model-serving
spec:
selector:
matchLabels:
app: model-serving
template:
metadata:
labels:
app: model-serving
serverless.fluid.io/inject: "true"
annotations:
autoscaling.knative.dev/target: "10"
autoscaling.knative.dev/scaleDownDelay: "30m"
autoscaling.knative.dev/minScale: "1"
spec:
containers:
- image: fluidcloudnative/serving
name: serving
ports:
- name: http1
containerPort: 8080
env:
- name: TARGET
value: "World"
volumeMounts:
- mountPath: /data
name: data
volumes:
- name: data
persistentVolumeClaim:
claimName: serverless-data
```
This source diff could not be displayed because it is too large. You can view the blob instead.
# Copyright 2020 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: v1
kind: Namespace
metadata:
name: kourier-system
labels:
networking.knative.dev/ingress-provider: kourier
app.kubernetes.io/name: knative-serving
app.kubernetes.io/component: net-kourier
app.kubernetes.io/version: "1.2.0"
serving.knative.dev/release: "v1.2.0"
---
# Copyright 2020 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: v1
kind: ConfigMap
metadata:
name: kourier-bootstrap
namespace: kourier-system
labels:
networking.knative.dev/ingress-provider: kourier
app.kubernetes.io/component: net-kourier
app.kubernetes.io/version: "1.2.0"
app.kubernetes.io/name: knative-serving
serving.knative.dev/release: "v1.2.0"
data:
envoy-bootstrap.yaml: |
dynamic_resources:
ads_config:
transport_api_version: V3
api_type: GRPC
rate_limit_settings: {}
grpc_services:
- envoy_grpc: {cluster_name: xds_cluster}
cds_config:
resource_api_version: V3
ads: {}
lds_config:
resource_api_version: V3
ads: {}
node:
cluster: kourier-knative
id: 3scale-kourier-gateway
static_resources:
listeners:
- name: stats_listener
address:
socket_address:
address: 0.0.0.0
port_value: 9000
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: stats_server
http_filters:
- name: envoy.filters.http.router
route_config:
virtual_hosts:
- name: admin_interface
domains:
- "*"
routes:
- match:
safe_regex:
google_re2: {}
regex: '/(certs|stats(/prometheus)?|server_info|clusters|listeners|ready)?'
headers:
- name: ':method'
exact_match: GET
route:
cluster: service_stats
clusters:
- name: service_stats
connect_timeout: 0.250s
type: static
load_assignment:
cluster_name: service_stats
endpoints:
lb_endpoints:
endpoint:
address:
pipe:
path: /tmp/envoy.admin
- name: xds_cluster
connect_timeout: 1s
type: strict_dns
load_assignment:
cluster_name: xds_cluster
endpoints:
lb_endpoints:
endpoint:
address:
socket_address:
address: "net-kourier-controller.knative-serving"
port_value: 18000
http2_protocol_options: {}
type: STRICT_DNS
admin:
access_log_path: "/dev/stdout"
address:
pipe:
path: /tmp/envoy.admin
---
# Copyright 2021 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: v1
kind: ConfigMap
metadata:
name: config-kourier
namespace: knative-serving
labels:
networking.knative.dev/ingress-provider: kourier
app.kubernetes.io/component: net-kourier
app.kubernetes.io/version: "1.2.0"
app.kubernetes.io/name: knative-serving
serving.knative.dev/release: "v1.2.0"
data:
_example: |
################################
# #
# EXAMPLE CONFIGURATION #
# #
################################
# This block is not actually functional configuration,
# but serves to illustrate the available configuration
# options and document them in a way that is accessible
# to users that `kubectl edit` this config map.
#
# These sample configuration options may be copied out of
# this example block and unindented to be in the data block
# to actually change the configuration.
# Specifies whether requests reaching the Kourier gateway
# in the context of services should be logged. Readiness
# probes etc. must be configured via the bootstrap config.
enable-service-access-logging: "true"
---
# Copyright 2020 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: v1
kind: ServiceAccount
metadata:
name: net-kourier
namespace: knative-serving
labels:
networking.knative.dev/ingress-provider: kourier
app.kubernetes.io/component: net-kourier
app.kubernetes.io/version: "1.2.0"
app.kubernetes.io/name: knative-serving
serving.knative.dev/release: "v1.2.0"
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: net-kourier
namespace: knative-serving
labels:
networking.knative.dev/ingress-provider: kourier
app.kubernetes.io/component: net-kourier
app.kubernetes.io/version: "1.2.0"
app.kubernetes.io/name: knative-serving
serving.knative.dev/release: "v1.2.0"
rules:
- apiGroups: [""]
resources: ["events"]
verbs: ["create", "update", "patch"]
- apiGroups: [""]
resources: ["pods", "endpoints", "services", "secrets"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "list", "watch"]
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"]
- apiGroups: ["networking.internal.knative.dev"]
resources: ["ingresses"]
verbs: ["get", "list", "watch", "patch"]
- apiGroups: ["networking.internal.knative.dev"]
resources: ["ingresses/status"]
verbs: ["update"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: net-kourier
labels:
networking.knative.dev/ingress-provider: kourier
app.kubernetes.io/component: net-kourier
app.kubernetes.io/version: "1.2.0"
app.kubernetes.io/name: knative-serving
serving.knative.dev/release: "v1.2.0"
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: net-kourier
subjects:
- kind: ServiceAccount
name: net-kourier
namespace: knative-serving
---
# Copyright 2020 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: apps/v1
kind: Deployment
metadata:
name: net-kourier-controller
namespace: knative-serving
labels:
networking.knative.dev/ingress-provider: kourier
app.kubernetes.io/component: net-kourier
app.kubernetes.io/version: "1.2.0"
app.kubernetes.io/name: knative-serving
serving.knative.dev/release: "v1.2.0"
spec:
replicas: 1
selector:
matchLabels:
app: net-kourier-controller
template:
metadata:
labels:
app: net-kourier-controller
spec:
containers:
- image: gcr.io/knative-releases/knative.dev/net-kourier/cmd/kourier@sha256:15b60b48a85d15490f1836585c01eb939dc468727e375585e66ff4646a2c6cfc
name: controller
env:
- name: CERTS_SECRET_NAMESPACE
value: ""
- name: CERTS_SECRET_NAME
value: ""
- name: SYSTEM_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: METRICS_DOMAIN
value: "knative.dev/samples"
- name: KOURIER_GATEWAY_NAMESPACE
value: "kourier-system"
ports:
- name: http2-xds
containerPort: 18000
protocol: TCP
readinessProbe:
exec:
command: ["/ko-app/kourier", "-probe-addr=:18000"]
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- all
restartPolicy: Always
serviceAccountName: net-kourier
---
apiVersion: v1
kind: Service
metadata:
name: net-kourier-controller
namespace: knative-serving
labels:
networking.knative.dev/ingress-provider: kourier
app.kubernetes.io/component: net-kourier
app.kubernetes.io/version: "1.2.0"
app.kubernetes.io/name: knative-serving
serving.knative.dev/release: "v1.2.0"
spec:
ports:
- name: grpc-xds
port: 18000
protocol: TCP
targetPort: 18000
selector:
app: net-kourier-controller
type: ClusterIP
---
# Copyright 2020 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: apps/v1
kind: Deployment
metadata:
name: 3scale-kourier-gateway
namespace: kourier-system
labels:
networking.knative.dev/ingress-provider: kourier
app.kubernetes.io/component: net-kourier
app.kubernetes.io/version: "1.2.0"
app.kubernetes.io/name: knative-serving
serving.knative.dev/release: "v1.2.0"
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
selector:
matchLabels:
app: 3scale-kourier-gateway
template:
metadata:
labels:
app: 3scale-kourier-gateway
annotations:
# v0.26 supports envoy v3 API, so
# adding this label to restart pod.
networking.knative.dev/poke: "v0.26"
spec:
containers:
- args:
- --base-id 1
- -c /tmp/config/envoy-bootstrap.yaml
- --log-level info
command:
- /usr/local/bin/envoy
image: docker.io/envoyproxy/envoy:v1.18-latest
name: kourier-gateway
ports:
- name: http2-external
containerPort: 8080
protocol: TCP
- name: http2-internal
containerPort: 8081
protocol: TCP
- name: https-external
containerPort: 8443
protocol: TCP
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: false
runAsNonRoot: false
capabilities:
drop:
- all
volumeMounts:
- name: config-volume
mountPath: /tmp/config
lifecycle:
preStop:
exec:
command: ["/bin/sh", "-c", "curl -X POST --unix /tmp/envoy.admin http://localhost/healthcheck/fail; sleep 15"]
readinessProbe:
httpGet:
httpHeaders:
- name: Host
value: internalkourier
path: /ready
port: 8081
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 5
volumes:
- name: config-volume
configMap:
name: kourier-bootstrap
restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
name: kourier
namespace: kourier-system
labels:
networking.knative.dev/ingress-provider: kourier
app.kubernetes.io/component: net-kourier
app.kubernetes.io/version: "1.2.0"
app.kubernetes.io/name: knative-serving
serving.knative.dev/release: "v1.2.0"
spec:
ports:
- name: http2
port: 80
protocol: TCP
targetPort: 8080
- name: https
port: 443
protocol: TCP
targetPort: 8443
selector:
app: 3scale-kourier-gateway
type: LoadBalancer
---
apiVersion: v1
kind: Service
metadata:
name: kourier-internal
namespace: kourier-system
labels:
networking.knative.dev/ingress-provider: kourier
app.kubernetes.io/component: net-kourier
app.kubernetes.io/version: "1.2.0"
app.kubernetes.io/name: knative-serving
serving.knative.dev/release: "v1.2.0"
spec:
ports:
- name: http2
port: 80
protocol: TCP
targetPort: 8081
selector:
app: 3scale-kourier-gateway
type: ClusterIP
---
This diff is collapsed.
# Copyright 2019 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: apps/v1
kind: Deployment
metadata:
name: autoscaler-hpa
namespace: knative-serving
labels:
autoscaling.knative.dev/autoscaler-provider: hpa
app.kubernetes.io/component: autoscaler-hpa
app.kubernetes.io/name: knative-serving
app.kubernetes.io/version: "1.2.0"
serving.knative.dev/release: "v1.2.0"
spec:
selector:
matchLabels:
app: autoscaler-hpa
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
labels:
app: autoscaler-hpa
app.kubernetes.io/component: autoscaler-hpa
app.kubernetes.io/name: knative-serving
app.kubernetes.io/version: "1.2.0"
serving.knative.dev/release: "v1.2.0"
spec:
# To avoid node becoming SPOF, spread our replicas to different nodes.
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchLabels:
app: autoscaler-hpa
topologyKey: kubernetes.io/hostname
weight: 100
serviceAccountName: controller
containers:
- name: autoscaler-hpa
# This is the Go import path for the binary that is containerized
# and substituted here.
image: gcr.io/knative-releases/knative.dev/serving/cmd/autoscaler-hpa@sha256:e3db964edf76abb4a53927039a8d3ddafb983e894c51e98b51dd0c3ebb260ccd
resources:
requests:
cpu: 30m
memory: 40Mi
limits:
cpu: 300m
memory: 400Mi
env:
- name: SYSTEM_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: CONFIG_LOGGING_NAME
value: config-logging
- name: CONFIG_OBSERVABILITY_NAME
value: config-observability
# TODO(https://github.com/knative/pkg/pull/953): Remove stackdriver specific config
- name: METRICS_DOMAIN
value: knative.dev/serving
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- all
ports:
- name: metrics
containerPort: 9090
- name: profiling
containerPort: 8008
---
apiVersion: v1
kind: Service
metadata:
labels:
app: autoscaler-hpa
autoscaling.knative.dev/autoscaler-provider: hpa
app.kubernetes.io/component: autoscaler-hpa
app.kubernetes.io/name: knative-serving
app.kubernetes.io/version: "1.2.0"
serving.knative.dev/release: "v1.2.0"
name: autoscaler-hpa
namespace: knative-serving
spec:
ports:
# Define metrics and profiling for them to be accessible within service meshes.
- name: http-metrics
port: 9090
targetPort: 9090
- name: http-profiling
port: 8008
targetPort: 8008
selector:
app: autoscaler-hpa
---
apiVersion: data.fluid.io/v1alpha1
kind: DataLoad
metadata:
name: serverless-dataload
spec:
dataset:
name: serverless-data
namespace: default
apiVersion: data.fluid.io/v1alpha1
kind: Dataset
metadata:
name: serverless-data
spec:
mounts:
- mountPoint: https://mirrors.bit.edu.cn/apache/hbase/stable/
name: hbase
path: "/"
accessModes:
- ReadOnlyMany
---
apiVersion: data.fluid.io/v1alpha1
kind: AlluxioRuntime
metadata:
name: serverless-data
spec:
replicas: 2
tieredstore:
levels:
- mediumtype: MEM
path: /dev/shm
quota: 2Gi
high: "0.95"
low: "0.7"
FROM registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:160e4dc8
RUN apk add bash
ADD entrypoint.sh /
RUN chmod u+x /entrypoint.sh
CMD ["/entrypoint.sh"]
#!/usr/bin/env bash
# Define a timestamp function
timestamp() {
date +"%T" # current time
}
echo Begin loading models at $(timestamp)
time cp /data/hbase-2.4.9-client-bin.tar.gz /tmp
echo Finish loading models at $(timestamp)
/helloworld
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go
#namespace: test
spec:
template:
metadata:
labels:
app: helloworld-go
serverless.fluid.io/inject: "true"
annotations:
autoscaling.knative.dev/target: "10"
autoscaling.knative.dev/scaleDownDelay: "30m"
autoscaling.knative.dev/minScale: "1"
spec:
containers:
- image: fluidcloudnative/serving
ports:
- name: http1
containerPort: 8080
env:
- name: TARGET
value: "World"
volumeMounts:
- mountPath: /data
name: data
readOnly: true
volumes:
- name: data
persistentVolumeClaim:
claimName: serverless-data
readOnly: true
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment