Context

该 cluster 使用 containerd 作为 CRI 运行时。containerd 的默认运行时处理程序是 runc 。 containerd 已准备好支持额外的运行时处理程序 runsc (gVisor)。

Task

使用名为 runsc 的现有运行时处理程序,创建一个名为 untrusted 的 RuntimeClass。 更新 namespace server 中的所有 Pod 以在 gVisor 上运行。 您可以在 /cks/gVisor/rc.yaml 中找到一个模版清单。

解:

apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
  • 1.
  • 2.
  • 3.

kubernetes.io 搜索 runtimeclass
CKS备考8-沙箱运行容器 gVisor_cks
CKS备考8-沙箱运行容器 gVisor_cks_02

# 修改runtimeclass配置
vim /cks/gVisor/rc.yaml
# 应用配置
kubectl apply -f /cks/gVisor/rc.yaml
# 验证
kubectl get runtimeclass
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.

CKS备考8-沙箱运行容器 gVisor_cks_03
CKS备考8-沙箱运行容器 gVisor_runtimeclass_04
CKS备考8-沙箱运行容器 gVisor_runtimeclass_05

# 查看server资源
kubectl get all -n server
# 查看runtimeclass这个参数在deployment参数的位置
kubectl explain deployment.spec.template.spec | grep runtime
# 修改deployment
kubectl edit deploy busybox-run -n server 
kubectl edit deploy nginx-host -n server 
kubectl edit deploy run-test  -n server 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.

CKS备考8-沙箱运行容器 gVisor_runtimeclass_06
CKS备考8-沙箱运行容器 gVisor_k8s_07
CKS备考8-沙箱运行容器 gVisor_kubernetes_08
CKS备考8-沙箱运行容器 gVisor_runtimeclass_09