尝试在使用时设置自定义 seccomp 配置文件kubectl apply
,尽管容器中存在该文件,但 pod 不会以以下错误启动:
Error: failed to create containerd container: cannot load seccomp profile "/var/lib/kubelet/seccomp/custom_profile.json": open /var/lib/kubelet/seccomp/custom_profile.json: no such file or directory
K8 部署 YAML
...
containers:
- name: container-name
image: container-image:version
securityContext:
seccompProfile:
type: Localhost
localhostProfile: custom_profile.json
...
该文件在创建容器并进入 pod 的外壳时被复制,我可以看到它确实存在于那里(当不尝试加载它并且 pod 启动时)
Dockerfile
...
COPY custom_profile.json /var/lib/kubelet/seccomp/custom_profile.json
...
我也尝试过更改所有者(chown
)并以 root 权限运行,但只要该localhostProfile: custom_profile.json
行在 YAML 中,就会再次出现相同的错误。
我错过了什么阻止文件被找到?YAML 中缺少什么,容器/dockerfile 中缺少什么?
以下文章让我走到了这一步,但仍然无法设置配置文件:https ://docs.openshift.com/container-platform/4.8/security/seccomp-profiles.html