CKS 模拟真题 Killer.sh | Question 4 | Pod Security Standard
Task weight: 8% Use context: kubectl config use-context workload-prod There is Deployment container-host-hacker in Namespace team-red which mounts /run/containerd as a hostPath volume on the Node where it’s running. This means that the Pod can access various data about other containers running on the same Node. To prevent this configure Namespace team-red to enforce the baseline Pod Security Standard. Once completed, delete the Pod of the Deployment mentioned above. Check the Replic...
CKS 模拟真题 Killer.sh | Question 3 | Apiserver Security
Task weight: 3% Use context: kubectl config use-context workload-prod You received a list from the DevSecOps team which performed a security investigation of the k8s cluster1 ( workload-prod ). The list states the following about the apiserver setup: Accessible through a NodePort Service Change the apiserver setup so that: Only accessible through a ClusterIP Service 译文任务重量:3%。 使用环境: kubectl config use-context workload-prod 你收到一份来自DevSecOps团队的清单,该团队对k8s cluster1( workload-prod )进行了安全调查。该清...
CKS 模拟真题 Killer.sh | Question 2 | Runtime Security with Falco
Task weight: 4% Use context: kubectl config use-context workload-prod Falco is installed with default configuration on node cluster1-node1 . Connect using ssh cluster1-node1 . Use it to: Find a Pod running image nginx which creates unwanted package management processes inside its container. Find a Pod running image httpd which modifies /etc/passwd . Save the Falco logs for case 1 under /opt/course/2/falco.log in format: time-with-nanosconds,container-id,container-name,user-name No other i...
CKS 模拟真题 Killer.sh | Question 1 | Contexts
Task weight: 1% You have access to multiple clusters from your main terminal through kubectl contexts. Write all context names into /opt/course/1/contexts , one per line. From the kubeconfig extract the certificate of user restricted@infra-prod and write it decoded to /opt/course/1/cert . 译文任务权重:1 你可以通过终端使用 kubectl 访问多个集群。把所有的上下文名称每行一个写进 /opt/course/1/contexts 从 kubeconfig 中提取用户 restricted@infra-prod 的证书,并将其解码后写入 /opt/course/1/cert 。 解答把所有集群名字写入文件 k config get-contextsk config get-context...
CKS killer.sh模拟环境设置
预先设置环境变量, 提高效率 alias k=kubectl # kubectl 命令可以使用k代替export do="--dry-run=client -o yaml" # 导出yaml文件 可以用$do , 如 k create deploy nginx --image=nginx $doexport now="--force --grace-period 0" # 强制 如: k delete pod x $now vim 设置 echo "ts=2 sw=2 et ai" >> ~/.vimrcsource ~/.vimrc 设置空格, tab,为2, tab为2空格, 换行自动对齐
CKS 题库 16、ImagePolicyWebhook容器镜像扫描
Contextcluster 上设置了容器镜像扫描器,但尚未完全集成到 cluster 的配置中。 完成后,容器镜像扫描器应扫描并拒绝易受攻击的镜像的使用。 Task注意:你必须在 cluster 的 master 节点上完成整个考题,所有服务和文件都已被准备好并放置在该节点上。 给定一个目录 /etc/kubernetes/epconfig 中不完整的配置, 以及具有 HTTPS 端点 https://image-bouncer-webhook.default.svc:1323/image_policy 的功能性容器镜像扫描器: 启用必要的插件来创建镜像策略 校验控制配置并将其更改为隐式拒绝(implicit deny) 编辑配置以正确指向提供的 HTTPS 端点 最后,通过尝试部署易受攻击的资源 /cks/img/web1.yaml 来测试配置是否有效。 参考https://kubernetes.io/zh/docs/reference/access-authn-authz/admission-controllers/#如何启用一个准入控制器 https://ku...
CKS 题库 15、TLS安全配置
Task通过TLS加强kube-apiserver安全配置,要求 kube-apiserver除了 TLS 1.3 及以上的版本可以使用,其他版本都不允许使用。 密码套件(Cipher suite)为 TLS_AES_128_GCM_SHA256 通过TLS加强ETCD安全配置,要求 密码套件(Cipher suite)为 TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 参考https://kubernetes.io/zh-cn/docs/reference/command-line-tools-reference/kube-apiserver/ 解答切换集群 kubectl config user-context KSRS00501 远程到 master 并切换到 root ssh master01sudo -i 修改 kube-apiserver, 养成 修改之前备份文件的好习惯 mkdir bakyamlcp /etc/kubernetes/manifests/kube-apiserver.yaml bakyam...
CKS 题库 14、启用API server认证
Context由 kubeadm 创建的 cluster 的 Kubernetes API 服务器,出于测试目的, 临时配置允许未经身份验证和未经授权的访问,授予匿名用户 cluster-admin 的访问权限. Task重新配置 cluster 的 Kubernetes APl 服务器,以确保只允许经过身份验证和授权的 REST 请求。 使用授权模式 Node , RBAC 和准入控制器 NodeRestriction 。 删除用户 system:anonymous 的 ClusterRoleBinding 来进行清理。 注意:所有 kubectl 配置环境/文件也被配置使用未经身份验证和未经授权的访问。 你不必更改它,但请注意,一旦完成 cluster 的安全加固, kubectl 的配置将无法工作。 您可以使用位于 cluster 的 master 节点上,cluster 原本的 kubectl 配置文件 /etc/kubernetes/admin.conf ,以确保经过身份验证的授权的请求仍然被允许。 模拟环境里,初始化这道题的脚本为b.sh 参考h...
CKS 题库 13、Container安全上下文
ContextContainer Security Context应在特定namespace中修改Deployment。 Task按照如下要求修改 sec-ns 命名空间里的 Deployment secdep 用ID为 30000 的用户启动容器(设置用户ID为: 30000) 不允许进程获得超出其父进程的特权(禁止allowPrivilegeEscalation) 以只读方式加载容器的根文件系统(对根文件的只读权限) 参考https://kubernetes.io/zh-cn/docs/tasks/configure-pod-container/security-context/ 解答w切换集群 kubectl config use-context KSMV00102 修改 deployment secdep kubectl -n sec-ns edit deployment secdep 在template字段下面的spec里面,添加或修改如下红字内容,并保存(考试中也是在Deployment下有两个image的) 请注意,考试和模拟环境中,先检查s...
CKS 题库 12、Sysdig & falco
Task: 使用运行时检测工具来检测 Pod tomcat123 单个容器中频发生成和执行的异常进程。 有两种工具可供使用: sysdig falco 注: 这些工具只预装在 cluster 的工作节点 node02 上,不在 master 节点。 使用工具至少分析 30 秒 ,使用过滤器检查生成和执行的进程,将事件写到 /opt/KSR00101/incidents/summary 文件中, 其中包含检测的事件, 格式如下: timestamp , uid/username , processName 保持工具的原始时间戳格式不变。 注: 确保事件文件存储在集群的工作节点上。 请注意,考试时,考题里已表明sysdig在工作节点上,所以你需要ssh到开头写的工作节点上。但在模拟环境,你需要ssh到node02这个工作节点。 解答切换集群 kubectl config use-context KSSC00401 切换到 node02 节点 使用root ssh node02sudo -i 找到containerd的socket crictl info...


