apiVersion: vl kind: Pod metadata: name: pod-with-host-network spec: hostNetwork: true #使用宿主节点的网络命名空间 containers - name. dfse image: asdf command : ["/bin/sleep”,1000000”]
通过将pod spec中的hostNetwork设置为true实现。
apiVersion: v1 kind: Pod metadata: name: nginx spec: containers: - image: docker.io/nginx name: asdf ports: - containersPorts: 8080 #可以通过pod 的Ip:8080 访问该pod hostPort: 9000 #也可以通过Pod 所在节点的9000访问该pod protocol: TCP
apiVersion: v1 kind: Pod metadata: name: pod-with-host-pid-and-ipc spec: hostPID: true hostIPC: true containers: ... ...
指定容器中运行进程的用户(用户ID)
阻止容器使用 root 户运行(容器的默认运行用户通常在其镜像中指定,所以可能需要阻止容器 root 用户运行)
使用特权模式运行容器,使其对宿主节点的内核具有完全的访问权限
与以上相反,通过添加或禁用内核功能,配置细粒度的内核访问权限
设置 SELinux (Security Enhaced Linux 安全增强型 Linux )选项,加强对容器的限制。
阻止进程写入容器的根文件系统
原文:https://www.cnblogs.com/fanggege/p/12204952.html