真题解析
题目

Context
该 cluster 使用 containerd 作为 CRI 运行时。containerd 的默认运行时处理程序是 runc 。containerd 已准备好支持额外的运行时处理程序 runsc (gVisor) 。
Task
使用名为 runsc 的现有运行时处理程序,创建一个名为 untrusted 的 RuntimeClass。
更新 namespace client 中的所有 Pod 以在 gVisor 上运行。
解析
RuntimeClass 官方文档:
https://kubernetes.io/zh-cn/docs/concepts/containers/runtime-class/
配置 RuntimeClass
# vim gVisorRuntimeClass.yaml
apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
# 用来引用 RuntimeClass 的名字
# RuntimeClass 是一个集群层面的资源
name: untrusted
# 对应的 CRI 配置的名称
handler: runsc
kubectl create -f gVisorRuntimeClass.yaml配置 Pod 的 RuntimeClass
kubectl get pod nginx -n client -o yaml > nginx.yaml
vim nginx.yaml
apiVersion: v1
kind: Pod
metadata:
labels:
run: nginx
name: nginx
namespace: client
spec:
runtimeClassName: untrusted # 添加此项配置
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
resources: {}
kubectl delete -f nginx.yaml
kubectl create -f nginx.yamlLast updated