无法创建pod沙箱:rpc错误:代码=未知desc =您的内核未启用seccomp,无法与配置文件一起运行

时间:2020-04-06 11:21:34

标签: kubernetes seccomp cri-o

我对kube和Cri-o有问题。 实际上,我正在部署kube集群,而只是不想部署仪表板。 我已经安装了CRIO而不是Docker(在生产环境中为RHEL8)。 “ describe pod”命令的输出日志为:

Events:
  Type     Reason                  Age                 From                   Message
  ----     ------                  ----                ----                   -------
  Normal   Scheduled               11m                 default-scheduler      Successfully assigned kubernetes-dashboard/dashboard-metrics-scraper-6b4884c9d5-fwdv9 to worker-node1
  Warning  FailedCreatePodSandBox  95s (x48 over 11m)  kubelet, worker-node1  Failed to create pod sandbox: rpc error: code = Unknown desc = seccomp is not enabled in your kernel, cannot run with a profile

我已经尝试过:grep SECCOMP /boot/config-$(uname -r)

CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
CONFIG_SECCOMP_FILTER=y
CONFIG_SECCOMP=y

有了这些回报,我认为这已启用...

在安装kube的过程中,我在系统中找到了一个seccomp.json文件,我试图在CRI-O的配置的seccomp_profile部分中设置绝对路径,但是没有...不是解决方案...

有人有想法...吗?

关于

1 个答案:

答案 0 :(得分:1)

Kubernetes仪表板部署yaml,默认将seccomp设置为seccomp.security.alpha.kubernetes.io/pod: 'runtime/default'

这意味着它正在使用默认的容器运行时配置文件,我们可以阅读here

可以通过PodSecurityPolicy上的注释来控制seccomp配置文件在pod中的使用。 Seccomp是Kubernetes中的Alpha功能。

seccomp.security.alpha.kubernetes.io/defaultProfileName -注释,用于指定要应用于容器的默认seccomp配置文件。可能的值为:

  • unconfined-如果没有其他选择,则Seccomp不会应用于容器进程(这是Kubernetes中的默认设置)。
  • runtime/default-使用默认的容器运行时配置文件。
  • docker/default-使用Docker默认的seccomp配置文件。从Kubernetes 1.11开始不推荐使用。请改用runtime/default
  • localhost/<path>-在<seccomp_root>/<path>上的节点上将配置文件指定为文件,其中<seccomp_root>是通过Kubelet上的--seccomp-profile-root标志定义的。

Unexpected behavior with empty seccomp profile有一个github问题。 在讨论中,@saschagrunert提到:

... 通常,我无法找到以下内容的概括描述:

  • 如果将配置文件指定给广告连播,则该配置文件也将应用于所有容器
    (目前仅受seccomp支持)
  • 如果将配置文件指定给容器,则会覆盖pods配置文件
  • 我们始终默认为runtime/default

我真的很想从安全角度实施此操作,并在此存储库内的专用安全部分中对其进行适当记录。 WDYT?

顺便说一句,我们可能应该推动seccomp和AppArmor的GA移植,以便在securityContext中获得一流的API,就像SELinux一样。参见:https://kubernetes.io/docs/tutorials/clusters/apparmor/#upgrade-path-to-general-availability

@CptBuko已经提到过,他通过设置seccomp.security.alpha.kubernetes.io/pod: unconfined来为自己解决问题,该方法未将seccomp应用于容器进程。