CKAD 模拟题库 | 6. 运行旧版应用程序

模拟题目:

设置配置环境:

[candidate@node-1] $ kubectl config use-context k8s

Task

  1. 修复清单文件 /ckad/credible-mite/www.yaml 中的任何 API 弃用问题 以便可以将应用程序部署在 k8s cluster 上 。
    注意:该应用程序是为 Kubernetes v1.15 开发的 。
    k8s cluster 运行着 Kubernetes v1.26
  2. 请在 garfish namespace 中 部署 更新后的 清 单文件 /ckad/credible-mite/www.yaml 中指定的应用程序 。

参考:

kubectl explain deployment.spec
kubectl explain deployment.spec.selector

1.8版本之前 .spec.selector 可以省略
1.8版本之后 .spec.selector 不可以省略

继续阅读“CKAD 模拟题库 | 6. 运行旧版应用程序”

CKAD 模拟题库 | 5. CPU和内存 限制

模拟题目:

设置配置环境:

[candidate@node-1] $ kubectl config use-context k8s

Task

namespace haddock 中名为 nosql 的 Deployment 的 Pod 因其容器已用完资源而无法启动。
请更新 haddock Deployment ,使 Pod

  • 为其容器请求 15Mi 的内存
  • 将内存限制为 haddock namespace 设置的最大内存容量一半
    您可以在 /ckad/chief-cardinal/nosql.yaml 找到 nosql Deployment 的配置清单。

参考:

https://kubernetes.io/zh-cn/docs/concepts/configuration/manage-resources-containers/

file

继续阅读“CKAD 模拟题库 | 5. CPU和内存 限制”

CKAD 模拟题库 | 4. CPU和内存 请求

模拟题目:

设置配置环境:

[candidate@node-1] $ kubectl config use-context k8s

Task

在现有的 namespace pod-resources 中创建一个名为 nginx-resources 的 Pod 。
镜像为 nginx:1.16 ,为其容器指定资源请求 40m 的 CPU 和 50Mi 的内存

参考:

https://kubernetes.io/zh-cn/docs/concepts/configuration/manage-resources-containers/
file

继续阅读“CKAD 模拟题库 | 4. CPU和内存 请求”

CKAD 模拟题库 | 3. Dockerfile

模拟题目:

设置配置环境:

[candidate@node-1] $ kubectl config use-context k8s

Task

一个Dockerfile 已经存在于 /ckad/DF/Dockerfile

  1. 使用已存在的 Dockerfile ,构建一个名为 centos
    和标签为 8.2 的容器镜像。您可以安装和使用您选择的工具。
  2. 使用您选择的工具,以 O CI 格式导出构建的容器镜像,并将其存储在 /ckad/DF/centos 8.2.tar

参考:

docker -h

继续阅读“CKAD 模拟题库 | 3. Dockerfile”

CKAD 模拟题库 | 2. CronJob-2

模拟题目:

设置配置环境:

[candidate@node-1] $ kubectl config use-context k8s

Task

  1. 在清单文件 /ckad/CKAD00016/periodic.yaml 中定义此 Pod
  2. 在一个 busybox :stable 容器中运行命令 dat e 该 命令必须每分钟运行一次,并且必须在 10 秒内完成运行,或者被 Kubernetes 终止运行。
    注意: C ron J ob 名称和容器名称都必须为 hello
  3. 在上述清单文件中创建此资源,并验证此 Job 至少成功执行一次。

参考:

https://kubernetes.io/zh-cn/docs/tasks/job/automated-tasks-with-cron-jobs/
https://kubernetes.io/zh-cn/docs/concepts/workloads/controllers/job/

kubectl explain cronjob.spec

file

继续阅读“CKAD 模拟题库 | 2. CronJob-2”

CKAD 模拟题库 | 1. CronJob-1

模拟题目:

设置配置环境:

[candidate@node-1] $ kubectl config use-context k8s

Task

  1. 创建一个名为 ppi 并执行一个运行以下单一容器的 Pod 的 CronJob
- name: pi
  image: perl:5
  command: ["perl", " Mbignum=bpi", " wle", "print bpi(2000)"]
  • CronJob配置 为:
    • 每隔 5 分钟执行一次
    • 保留 2 个已完成的 Job
    • 保留 4 个失败的 Job
    • 永不重启 Pod
    • 在 8 秒后终止 Pod
  1. 为测试目的,从 CronJob ppi 中 手动创建并执行一个名为 ppi test 的 Job 。
    • job完成与否不重要

参考:

https://kubernetes.io/zh-cn/docs/tasks/job/automated-tasks-with-cron-jobs/
https://kubernetes.io/zh-cn/docs/concepts/workloads/controllers/job/

kubectl explain cronjob.spec

cron 表示法
https://tool.lu/crontab/
file

继续阅读“CKAD 模拟题库 | 1. CronJob-1”

CKS 模拟真题 Killer.sh | Preview Question 2

Use context: kubectl config use-context infra-prod

There is an existing Open Policy Agent + Gatekeeper policy to enforce that all Namespaces need to have label security-level set. Extend the policy constraint and template so that all Namespaces also need to set label management-team. Any new Namespace creation without these two labels should be prevented.

Write the names of all existing Namespaces which violate the updated policy into /opt/course/p2/fix-namespaces.


继续阅读“CKS 模拟真题 Killer.sh | Preview Question 2”

CKS 模拟真题 Killer.sh | Preview Question 1

Use context: kubectl config use-context infra-prod

You have admin access to cluster2. There is also context gianna@infra-prod which authenticates as user gianna with the same cluster.

There are existing cluster-level RBAC resources in place to, among other things, ensure that user gianna can never read Secret contents cluster-wide. Confirm this is correct or restrict the existing RBAC resources to ensure this.

I addition, create more RBAC resources to allow user gianna to create Pods and Deployments in Namespaces security, restricted and internal. It's likely the user will receive these exact permissions as well for other Namespaces in the future.


继续阅读“CKS 模拟真题 Killer.sh | Preview Question 1”

CKS 模拟真题 Killer.sh | Question 22 | Manual Static Security Analysis

(can be solved in any kubectl context)

The Release Engineering Team has shared some YAML manifests and Dockerfiles with you to review. The files are located under /opt/course/22/files.

As a container security expert, you are asked to perform a manual static analysis and find out possible security issues with respect to unwanted credential exposure. Running processes as root is of no concern in this task.

Write the filenames which have issues into /opt/course/22/security-issues.

NOTE: In the Dockerfile and YAML manifests, assume that the referred files, folders, secrets and volume mounts are present. Disregard syntax or logic errors.


继续阅读“CKS 模拟真题 Killer.sh | Question 22 | Manual Static Security Analysis”