CKS 2021最新真题--练习题02.docx
《CKS 2021最新真题--练习题02.docx》由会员分享,可在线阅读,更多相关《CKS 2021最新真题--练习题02.docx(12页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、CKS 2021最新真题-练习题021 AppArmor2 PodSecurityPolicy3 sysdig & faloc4 镜像安全5 NetworkPolicy6 dockerfile 检测7 pod 操作8 Trivy9 创建secret10 kube-benct11 gVsior12 NetworkPolicy13 kubelet 参数配置14 审计15 clusterrole16 serviceAccount1 AppArmor题目概述ContextAppArmor is enabled on the clusters worker node. An AppArmor profi
2、le is prepared, but not enforced yet.You may use your browser to open one additional tab to access theAppArmor documentation.TaskOn the clusters worker node, enforce the prepared AppArmor profile located at /etc/apparmor.d/nginx_apparmor .Edit the prepared manifest file located at /cks/4/pod1.yaml t
3、o apply the AppArmor profile.Finally, apply the manifest file and create the pod specified in it.解析$ ssh rootvms62.rhce.cc$ vim /etc/apparmor.d/nginx_apparmor# nginx-profile-3$ apparmor_status | grep nginx$ apparmor_parser -q /etc/apparmor.d/nginx_apparmor$ vim /cks/4/pod1.yamlannotations:container.
4、apparmor.security.beta.kubernetes.io/podx: localhost/nginx-profile-3$ kubectl apply -f /cks/4/pod1.yaml2 PodSecurityPolicy题目概述contextA PodsecurityPolicy shall prevent the creati on of privileged Pods in a specific namespace.TaskCreate a new PodSecurityPolicy named prevent-psp-policy, which prevents
5、the creation of privileged Pods.Create a new ClusterRole named restrict-access-role, which uses the newly created PodSecurityPolicy prevent-psp-policy.Create a new serviceAccount named psp-denial-sa in the existing namespace development.Finally, create a new clusterRoleBinding named dany-access-bind
6、, which binds the newly created ClusterRole restrict-access-role to the newly created serviceAccount psp-denial-sa.解析3 sysdig & faloc题目概述You may use your browser to open one additional tab to access sysdigs documentation or Falcos documentation.Task:Use runtime detection tools to detect anomalous pr
7、ocesses spawning and executing frequently inthe single container belorging to Pod redis.Two tools are available to use:sysdigfalcoThe tools are pre-installed on the clusters worker node only; they are notavailable on the basesystem or the master node.Using the tool of your choice (including any non
8、pre-installed tool), analyse the containersbehaviour for at least 30 seconds, using filters that detect newly spawning and executingprocesses.Store an incident file at /opt/2/report , containing the detected incidents, one per line, in thefollowing format:timestamp,uid, processNameKeep the tools ori
9、ginal timestamp-format as-is.Make sure to store the incident fileon the clusters worker node.解析$ ssh rootvms62.rhce.cc$ docker ps | grep redis$ sysdig -l | grep time$ sysdig -l | grep uid$ sysdig -l | grep proc$ sysdig -M 30 -p *%evt.time,%user.uid,%proc.name container.id=b1dacef30135 /opt/2/report4
10、 镜像安全题目概述contextA container image scanner is set up on the cluster, but its not yet fully integrated into the clusters configuration. When complete, the container image scanner shall scan for and reject the use of vulnerable images.TaskYou have to complete the entire task on the clusters master node
11、, where all services and files have been prepared and placed.Given an incomplete configuration in directory /etc/kubernetes/aa and a functional containerimage scanner with HTTPS endpoint http:/192.168.26.60:1323/image_policy:1. Enable the necessary plugins to create an image policy2. validate the co
12、ntrol configuration and change it to an implicit deny3. Edit the configuration to point t the provided HTTPS endpoint correctly.Finally , test if the configuration is working by trying to deploy the vulnerable resource/cks/1/web1.yamlYou can find the container image scanners log file at/var/loglimag
13、epolicyiacme.log解析$ ssh rootvms61.rhce.cc$ cd /etc/kubernetes/aa$ vim admission_configuration.jsondefaultAllow: false$ vim kubeconfig.yamlservice: http:/192.168.26.60:1323/image_policy$ vim /etc/kubernetes/manifests/kube-apiserver.yaml- -enable-admission-plugins=NodeRestriction,ImagePolicyWebhook- -
14、admission-control-config-file=/etc/kubernetes/aa/admission_configuration.json.volumeMounts:- mountPath: /etc/kubernetes/aaname: aavolumes:- hostPath:path: /etc/kubernetes/aaname: aa$ systemctl restart kubelet$ kubectl apply -f /cks/1/web1.yaml5 NetworkPolicy题目概述Taskcreate a NetworkPolicy named pod-a
15、ccess torestrict access to Pod products-service running in namespace development.only allow the following Pods to connect to Pod products-service :Pods in the namespace testingPods with label environment: staging, in any namespaceMake sure to apply the NetworkPolicy.You can find a skelet on manifest
16、 file at /cks/6/p1.yaml解析$ kubectl get po -n development -show-labels# NAME READY STATUS RESTARTS AGE LABELS# products-service 1/1 Running 8 94d environment=staging$ kubectl get ns -show-labels.# testingActive94d.$ kubectl label ns testing name=testing$ vim /cks/6/p1.yamlapiVersion: networking.k8s.i
17、o/v1kind: NetworkPolicymetadata:name: pod-accessnamespace: developmentspec:podSelector:matchLabels:environment: stagingpolicyTypes:- Ingressingress:- from:- namespaceSelector:matchLabels:name: testing- from:- namespaceSelector:matchLabels:podSelector:matchLabels:environment: staging$ kubectl apply -
18、f /cks/6/p1.yaml6 dockerfile 检测题目概述TaskAnalyze and edit the given Dockerfile (based on the ubuntu:16.04 image) /cks/7/Dockerfile fixing two instructions present in the file being prominent security/best-practice issues.Analyze and edit the given manifest file /cks/7/deployment.yaml fixing two fields
19、 present in the file being prominent security/best-practice issues.解析$ vim /cks/7/Dockerfile#USER root$ vim /cks/7/deployment.yaml# securityContext:# Capabilities: add:NET_BIND_SERVICE, drop: , privileged: TRUE7 pod 操作题目概述contextlt is best-practice to design containers to best teless and immutable.T
20、asklnspect Pods running in namespace testing and delete any Pod that is either not stateless or not immutable.use the following strict interpretation of stateless and immutable:Pods being able to store data inside containers must be treated as not stateless.You dont have to worry whether data is act
21、ually stored inside containers or not already.Pods being configured to be privileged in any way must be treated as potentially not stateless and not immutable.解析$ kubectl get po -n testing$ kubectl get po -n testing frontent -o yaml | egrep priv.*: true# privileged: true$ kubectl delete po -n testin
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- CKS 2021最新真题-练习题02 2021 最新 练习题 02
限制150内