CKS真题 -- Container安全上下文
任务
按照如下要求修改sec-ns命名空间里的Deployment secdep
1、用ID为30000的用户启动容器(设置用户1D为:30000)
2、不允许进程获得超出其父进程的特权(禁止allowPrivilegeEscalation)
3、以只读方式加载容器的根文件系统(对根文件的只读权限)
解题
修改deployment secdep,添加配置
kubectl edit deploy secdep -n sec-ns1
2
3
4
5
6
7
8
9
10
11
12
13spec:
securityContext: #增加这两行完成任务1
runAsUser: 30000
...
containers:
securityContext: #增加这三行完成任务2,3
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
...
containers: #如果有多个容器,每个容器都要增加这三行
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true保存,检查是否添加成功,不成功说明没加对,需要重新添加
kubectl -n sec-ns get all
参考
https://kubernetes.io/zh-cn/docs/tasks/configure-pod-container/security-context/
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Eryoung2的个人博客!
评论
ValineDisqus