2024.11.28 - [CS/wasm] - 쿠버네티스 런타임 wasm으로 변경해서 실행해보기
컨테이너를 wasm으로 실행한거에 이어서 이번에는 wasm런타임으로 쿠버네티스 클러스터를 변경해보려고 합니다.
wasm런타임에는 여러가지가 있지만 runwasi를 사용해보겠습니다.
아래의 그림처럼 컨테이너 런타임이 runc에서 wasmedge로 변경되게됩니다.
runwasi 설치하기
containerd의 런타임에 runwasi를 추가하여 wasm 컨테이너도 실행해보려고 합니다.
https://github.com/containerd/runwasi
GitHub - containerd/runwasi: Facilitates running Wasm / WASI workloads managed by containerd
Facilitates running Wasm / WASI workloads managed by containerd - containerd/runwasi
github.com
먼저 서버에 들어가서 runwasi를 설치합니다.
git clone https://github.com/containerd/runwasi.git
make build
make install
wasmedge 설치하기
<생략>
Containerd와 연결하기
containerd의 설정을 아래와 같이 바꿔야합니다. wasmedge 런타임을 추가합니다.
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes]
... (생략)
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.wasmedge]
runtime_type = "io.containerd.wasmedge.v1"
설정을 적용합니다.
systemctl daemon-reload
systemctl restart containerd
Runtime 배포하기
apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
name: wasm
scheduling:
nodeSelector:
runtime: wasm
handler: wasmedge
노드에 라벨 추가하기
kubectl label nodes wasm-worker runtime=wasm
직접 배포해보기
apiVersion: apps/v1
kind: Deployment
metadata:
name: http-server-deployment
spec:
replicas: 1
selector:
matchLabels:
app: http-server
template:
metadata:
labels:
app: http-server
spec:
containers:
- image: wasmedge/example-wasi-http:latest
name: http-server
ports:
- containerPort: 1234
protocol: TCP
runtimeClassName: wasm
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/control-plane
operator: Exists
'CS > wasm' 카테고리의 다른 글
wasm 컨테이너 실행하기 (0) | 2024.11.28 |
---|---|
WebAssembly 알아보기 (0) | 2024.10.03 |