k8s学习-CKS真题-Context安全上下文
在spec下面添加(考试时可能已有securityContext)修改deployment。
·
题目
Context
Container Security Context 应在特定 namespace 中修改 Deployment。
Task
按照如下要求修改 sec-ns 命名空间里的 Deployment secdep
一、用 ID 为 30000 的用户启动容器(设置用户 ID 为: 30000)
二、不允许进程获得超出其父进程的特权(禁止 allowPrivilegeEscalation)
三、以只读方式加载容器的根文件系统(对根文件的只读权限)
环境搭建
命令
kubectl create ns sec-ns
kubectl create deploy secdep --image=nginx -n sec-ns
截图
解题
修改deployment
命令
kubectl -n sec-ns edit deployment secdep
任务一
在template的spec下面添加(考试时可能已有securityContext)
securityContext:
runAsUser: 30000
任务二、三
在每个容器中添加
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
截图
参考
更多k8s相关内容,请看文章:k8s学习-思维导图与学习笔记
更多推荐
已为社区贡献44条内容
所有评论(0)