k8s 使用crio,pod ip无法ssh登录,无法使用ping命令

发布时间 2023-06-02 16:27:34作者: fengjian1585

使用crio容器运行时,部署ssh pod后,ssh root@127.0.0.1 后,出现 connection reset by 127.0.0.1 port 22. 但是telnet 显示能通,

在pod中 ping 其他pod 出现 socket: Operation  not  permitted, 权限问题。

通过测试 在contianerd 与 docker 没出现这个问题, 基本上与crio 有关了。通过crio配置文件,没有相关配置, 

通过官网查看,在API Chanage中有提到:

 

CRI-O 现在运行没有NET_RAW和SYS_CHROOT功能的容器。当容器尝试执行需要这些功能之一的操作时,这可能会导致权限被拒绝错误。

解决方式

在deployment.spec.containers.securityContext.capabilities 添加

apiVersion: v1
kind: Pod
metadata:
  name: security-context-demo-4
spec:
  containers:
  - name: sec-ctx-4
    image: gcr.io/google-samples/node-hello:1.0
    securityContext:
      capabilities:
        add: ["NET_ADMIN", "SYS_TIME""NET_RAW","SYS_CHROOT"]

 

 

 

 

参考:

https://cri-o.github.io/cri-o/v1.18.0.html#SnippetTab

https://man7.org/linux/man-pages/man7/capabilities.7.html

 https://kubernetes.io/zh-cn/docs/tasks/configure-pod-container/security-context/