Skip to content

Commit 2053889

Browse files
author
faweizhao26
committed
zh blog for release v1.0.0
Signed-off-by: faweizhao26 <faweizhao@kubesphere.io>
1 parent b739d6e commit 2053889

File tree

1 file changed

+149
-0
lines changed

1 file changed

+149
-0
lines changed
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
---
2+
title: "OpenFunction v1.0.0 发布:集成 WasmEdge,支持 Wasm 函数和更完整的 CI/CD"
3+
linkTitle: "Release v1.0.0"
4+
date: 2023-03-11
5+
weight: 92
6+
---
7+
8+
[OpenFunction](https://github.com/OpenFunction/OpenFunction) 是一个开源的云原生 FaaS(Function as a Service,函数即服务)平台,旨在帮助开发者专注于业务逻辑的研发。今天,我们非常高兴地宣布 OpenFunction 迎来了一次重要的更新,即 v1.0.0 版本的发布!
9+
10+
本次更新中,我们继续致力于为开发者们提供更加灵活和强大的工具,并在此基础上加入了一些新的功能点。其中,该版本集成了 WasmEdge 以支持 Wasm 函数;我们还对 OpenFunction 的 CI/CD 功能进行了增强,提供了相对完整的端到端的 CI/CD 功能;除此之外,我们还在这个版本中新增了从本地代码直接构建函数或应用的镜像的功能,让开发者可以更加便捷地进行代码发布和部署。
11+
12+
与此同时,我们也在大力优化 OpenFunction 的性能和代码质量,使其更加稳定高效。
13+
14+
以下是本次版本更新的主要内容:
15+
16+
## 集成 WasmEdge,支持 Wasm 函数
17+
18+
WasmEdge 是一个轻量级、高性能和可扩展的 WebAssembly 运行时,适用于云原生、边缘和去中心化应用程序。它为 Serverless 应用程序、嵌入式功能、微服务、智能合约和物联网设备提供支持。
19+
20+
OpenFunction 现在支持构建和运行以 WasmEdge 为运行时的 Wasm 函数或应用。WasmEdge 成为 Docker、Containerd 和 CRI-O 之外的容器运行时的新选择。
21+
22+
### Wasm 函数示例
23+
```shell
24+
cat <<EOF | kubectl apply -f -
25+
apiVersion: core.openfunction.io/v1beta1
26+
kind: Function
27+
metadata:
28+
name: wasmedge-http-server
29+
spec:
30+
workloadRuntime: wasmedge
31+
image: openfunctiondev/wasmedge_http_server:0.1.0
32+
imageCredentials:
33+
name: push-secret
34+
build:
35+
dockerfile: Dockerfile
36+
srcRepo:
37+
revision: main
38+
sourceSubPath: functions/knative/wasmedge/http-server
39+
url: https://github.com/OpenFunction/samples
40+
port: 8080
41+
route:
42+
rules:
43+
- matches:
44+
- path:
45+
type: PathPrefix
46+
value: /echo
47+
serving:
48+
runtime: knative
49+
scaleOptions:
50+
minReplicas: 0
51+
template:
52+
containers:
53+
- command:
54+
- /wasmedge_hyper_server.wasm
55+
imagePullPolicy: IfNotPresent
56+
livenessProbe:
57+
initialDelaySeconds: 3
58+
periodSeconds: 30
59+
tcpSocket:
60+
port: 8080
61+
name: function
62+
EOF
63+
```
64+
65+
借助 WasmEdge 引擎,开发者可以使用多种支持 Wasm 的语言和开发框架来编写及运行函数。
66+
67+
> 如何构建和运行 Wasm functions,请参考官方文档 [Wasm Functions](https://openfunction.dev/docs/concepts/wasm_functions/)
68+
69+
## 更完整的 CI/CD
70+
71+
之前,用户可以使用 OpenFunction 将函数或应用程序源代码构建为容器镜像,然后直接将构建的镜像部署到底层的同步或异步 Serverless 运行时,而无需用户干预。
72+
73+
但是,OpenFunction 不能在函数或应用程序源代码发生更改时重新构建镜像并重新部署它,也不能在镜像更改时重新部署它(例如手动构建和推送镜像或在其他函数中构建镜像)。
74+
75+
从 v1.0.0 开始,OpenFunction 在新的组件 `Revision Controller` 中增加了检测源代码或镜像变更的能力,并且可以在检测到变更后触发镜像重新构建或重新部署新的镜像。`Revision Controller` 的能力包括:
76+
77+
- 检测 GitHub、GitLab 或 Gitee 中的源代码变更,然后在源代码变更时重新构建并重新部署新的镜像。
78+
- 检测包含源代码的镜像(Bundle Container Image)的变更,然后在该镜像变更时重新构建和重新部署新的镜像。
79+
- 检测函数或应用程序镜像变更,然后在函数或应用程序镜像变更时重新部署新的镜像。
80+
81+
更好的 CI/CD 功能确保了代码能在不同的环境中高效运行,使用者可以在开发和部署过程中更好的控制版本和代码质量,同时也为使用者提供了更好的使用体验。
82+
83+
> 此处请参考官方文档 [CI/CD](https://openfunction.dev/docs/concepts/cicd/)
84+
85+
## 从本地源代码构建函数
86+
87+
目前,OpenFunction v1.0.0 支持根据本地的源代码构建函数或应用。只需要将本地源代码打包到容器镜像中,并将此镜像推送到容器注册表即可完成构建。以下为操作方法。
88+
89+
假设你的源代码在 `samples` 目录中,你可以根据以下 `Dockerfile` 来构建包含源代码的镜像。
90+
91+
```shell
92+
FROM scratch
93+
WORKDIR /
94+
COPY samples samples/
95+
```
96+
97+
然后如下操作:
98+
99+
```shell
100+
docker build -t <your registry name>/sample-source-code:latest -f </path/to/the/dockerfile> .
101+
docker push <your registry name>/sample-source-code:latest
102+
```
103+
104+
> 推荐使用空镜像 `scratch` 作为基础镜像构建包含源代码的镜像,非空基础镜像可能会导致源代码拷贝失败。
105+
106+
另外还需要定义字段 `spec.build.srcRepo.bundleContainer.image`
107+
108+
```yaml
109+
apiVersion: core.openfunction.io/v1beta1
110+
kind: Function
111+
metadata:
112+
name: logs-async-handler
113+
spec:
114+
build:
115+
srcRepo:
116+
bundleContainer:
117+
image: openfunctiondev/sample-source-code:latest
118+
sourceSubPath: "/samples/functions/async/logs-handler-function/"
119+
```
120+
121+
> `sourceSubPath` 是包含源代码的镜像中源代码的绝对路径。
122+
123+
## 其他的改进和优化
124+
125+
除了上述的主要变化,该版本还有以下更改和增强:
126+
127+
- OpenFunction
128+
- 核心 API `v1alpha2` 已弃用并删除
129+
- 将 sha256 添加到服务镜像
130+
- 将构建源信息添加到函数状态
131+
- 将 Shipwright 升级到 v0.11.0
132+
- 将 Knative 升级到 v0.32.0
133+
- 将 Dapr 升级到 v1.8.3
134+
- 将 Go 升级到 v1.18
135+
- functions-framework-java 发布 V1.0.0
136+
- 在一个 pod 中支持多个函数
137+
- 支持自动发布
138+
- Builder
139+
- 在一个 pod 中支持多个函数
140+
- 将默认的 Java 框架版本更新为 1.0.0
141+
- revision-controller 发布 v1.0.0(功能见上文)
142+
143+
144+
以上就是 OpenFunction v1.0.0 的主要功能变化,在此十分感谢各位贡献者的参与和贡献。如果您正在寻找一款高效、灵活的云原生函数开发平台,那么 OpenFunction v1.0.0 将是您的绝佳选择。
145+
146+
了解更多关于 OpenFunction 和本次版本更新的信息,欢迎访问我们的官方网站和 Github 页面。
147+
148+
- [官网](https://openfunction.dev/):https://openfunction.dev/
149+
- [Github](https://github.com/OpenFunction/OpenFunction/releases/tag/v1.0.0):https://github.com/OpenFunction/OpenFunction/releases/tag/v1.0.0

0 commit comments

Comments
 (0)