安装
安装地址:Installation - gVisor
1 2 3 4 5 6 7 8 9 10
| ARCH=$(uname -m) URL=https://storage.googleapis.com/gvisor/releases/release/latest/${ARCH} wget ${URL}/runsc ${URL}/runsc.sha512 \ ${URL}/containerd-shim-runsc-v1 ${URL}/containerd-shim-runsc-v1.sha512 sha512sum -c runsc.sha512 \ -c containerd-shim-runsc-v1.sha512 rm -f *.sha512 chmod a+rx runsc containerd-shim-runsc-v1 sudo mv runsc containerd-shim-runsc-v1 /usr/local/bin
|
与containerd集成
下发runtimeclass资源
1 2 3 4 5 6 7 8 9 10 11
| root@node01:~ apiVersion: node.k8s.io/v1 kind: RuntimeClass metadata: name: untrusted handler: runsc root@node01:~ root@node01:~ NAME HANDLER AGE untrusted runsc 7m34s
|
修改containerd配置文件
1
| vim /etc/containerd/config.toml
|
增加
1 2 3
| [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runsc] runtime_type = "io.containerd.runsc.v1"
|
准备pod的yaml文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| root@node01:~ apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: nginx-gvisor name: nginx-gvisor spec: containers: - image: nginx name: nginx-gvisor resources: {} dnsPolicy: ClusterFirst restartPolicy: Always status: {}
root@node01:~
root@node01:~ apiVersion: v1 kind: Pod metadata: name: nginx-gvisor spec: runtimeClassName: untrusted containers: - image: nginx name: nginx-gvisor
root@node01:~
root@node01:~ NAME READY STATUS RESTARTS AGE nginx-gvisor 1/1 Running 0 8m3s
|
成了~
参考资料
### Kubernetes 最小化微服务漏洞 gVisor与Containerd集成