2022 National Vocational College Skills Competition Higher Vocational Group CloudComputing Competition Exam Paper
[Schedule Name] Cloud Computing Competition Game 2 - Container Cloud
Table of contents
[Schedule Name] Cloud Computing Competition Game 2 - Container Cloud
[Task 1] Container cloud platform construction [5 points]
[Task 3] Container cloud application deployment: Build CICD based on Kubernetes [8.0 points]
Note: Two cloud hosts with CentOS 7.9 operating system installed are required to complete this task : master and node .
The Chinaskill_Cloud_PaaS.iso image package contains all the files required for this container cloud deployment. Please see the attachment for the files required for operation and maintenance .
The product development and launch cycle of a certain company's technology department is long, and customers' needs often cannot be responded to in a timely manner. Introducing CICD
(Continuous Integration , Continuous Delivery ) has become a top priority for the company. The R & D team decided to build a CICD environment based on Kubernetes , hoping to implement part of the DevOps flow based on this platform
process to reduce the burden of development, deployment, and operation and maintenance.
In order to enable the web application system products developed by the company to be based on server performance, reliability, and high availability
In order to facilitate maintenance, the R&D department decided to use a microservice architecture to implement containerized deployment based on Kubernetes .
The node planning is shown in Table 1 .
Table 1 Container cloud platform node planning
node role |
CPU name |
VCPUS |
Memory |
harddisk |
Master 、Harbor 、CICD |
master |
8 |
12G |
100G |
Worker Node |
node |
8 |
8G |
100G |
[Task 1 ] Container cloud platform construction [5 points ]
[Applicable Platform] Private Cloud
[Topic 1 ] Platform deployment -- deploying container cloud platform [1.5 points ]
Log in to the OpenStack private cloud platform, use the CentOS7.9 image to create two cloud hosts , and use the kubeeasy tool to complete the construction of the Kubernetes 1.22.1 cluster. Then use the nginx image to create a file named
exam Pod , and set the environment variable exam for this Pod with a value of 2022 .
After completion, submit the username, password and IP of the master node to the answer box.
1. Successful Kubernetes cluster deployment will score 1 point; 2. 0.5 points will be awarded if the Pod is successfully created and the environment variables are set correctly . |
[Topic 2 ] Platform deployment -- Deploying Istio service grid [ 0.5 points ]
Complete the installation of the Istio service grid environment on the Kubernetes cluster , and then create a new namespace exam with the command
The namespace enables automatic injection of Sidecar .
After completion, submit the username, password and IP of the master node to the answer box.
1. 0.3 points are awarded for successful operation of all Istio components ; 2. Successful automatic injection of the namespace exam will score 0.2 points. |
[Topic 3 ] Platform deployment -- deploy KubeVirt virtualization [1 point ]
Complete the installation of the KubeVirt virtualization environment on the Kubernetes cluster .
After completion, submit the username, password and IP of the master node to the answer box.
1. 1 point will be awarded if all components of KubeVirt run successfully . |
[Question 4 ] Platform deployment -- deploy Harbor warehouse and Helm package management tools [1 point ]
Complete the deployment of Harbor image warehouse and Helm package management tool on the master node . Then use the nginx mirror to customize a Chart , the Deployment name is nginx , the number of copies is 1 , and then deploy the Chart to default
Under the namespace, the Release name is web .
After completion, submit the username, password and IP of the master node to the answer box.
1. Successful deployment of Harbor warehouse will score 0.5 points; 2. Successful installation of the Helm tool will score 0.2 points; 3. The Chart package is successfully deployed and gets 0.3 points. |
[Topic 5 ] Cluster management -- backup ETCD data [1 point ]
Kubernetes uses ETCD to store real-time operating data of the cluster. In order to prevent Kubernetes from causing server downtime,
If the cluster data is lost, please back up the Kubernetes cluster data to /root/etcd.db .
After completion, submit the IP address, username and password of the master node to the answer box.
1. Successful installation of etcdctl tool will score 0.2 points; 2. Successful ETCD data backup is awarded 0.8 points. |
[Task 2 ] Container cloud application deployment: Docker Compose orchestration deployment [7.0 points ]
[Applicable Platform] Private Cloud
Hyperf is a high-performance, highly flexible progressive PHP coroutine framework with a built-in coroutine server and a large number of commonly used components. Its performance is qualitatively improved compared to traditional PHP-FPM -based frameworks. It provides ultra-high performance while also maintaining With extremely flexible scalability. Please complete the database service MariaDB , cache service Redis , and microservice Hyperf as required .
And the front-end service Nginx is containerized as required.
[Topic 1 ] Containerized MariaDB service [1 point ]
Write a Dockerfile file to build the hyperf-mariadb:v1.0 image. The specific requirements are as follows : ( Required software packages:
Hyperf.tar.gz)
( 1 )Basic image: centos:7.9.2009 ;
( 2 ) Complete the installation of MariaDB service;
( 3 ) Declare port: 3306 ;
( 4 ) Set the password of the database root user to root ;
( 5 ) Import the provided database file hyperf_admin .sql into the database;
( 6 ) Set the service to start automatically at boot.
After completion, build the image and submit the username, password and IP address of the master node to the answer box.
1. 0.5 points are awarded for successful image construction ; 2. Successfully installing the database and importing data will score 0.5 points. |
[Topic 2 ] Containerized Redis service [1 point ]
Write a Dockerfile to build the hyperf-redis:v1.0 image. The specific requirements are as follows : ( Required software packages:
Hyperf.tar.gz)
( 1 )Basic image: centos:7.9.2009 ;
( 2 ) Install Redis service;
( 3 ) Turn off protection mode;
( 4 ) Declare port: 6379 ;
( 5 ) Set the service to start automatically at boot.
After completion, build the image and submit the username, password and IP address of the master node to the answer box.
1. 0.5 points for successful image construction ; 2. The Redis service is successfully installed and configured correctly and gets 0.5 points. |
[Topic 3 ] Containerized Nginx service [0.5 points ]
Write a Dockerfile file to build the hyperf-nginx:v1.0 image. The specific requirements are as follows : ( Required software packages:
Hyperf.tar.gz)
( 1 )Basic image: centos:7.9.2009 ;
( 2 ) Install nginx service;
( 3 ) Declare port: 80 ;
( 4 ) Set the service to start automatically at boot.
After completion, build the image and submit the username, password and IP address of the master node to the answer box.
1. A successful image build will score 0.3 points; 2. Nginx is successfully installed and configured correctly and gets 0.2 points. |
[Topic 4 ] Containerized Hyperf service [1 point ]
Write a Dockerfile file to build the hyperf-servi ce:v1.0 image. The specific requirements are as follows : ( Required software packages:
Hyperf.tar.gz)
( 1 )Basic image: centos:7.9.2009 ;
( 2 ) Install PHP and extensions;
( 3 ) Compile and install Swoole using source code .
After completion, build the image and submit the username, password and IP address of the master node to the answer box.
1. 0.5 points are awarded for successful image construction ; 2. Successful PHP installation will score 0.2 points; 3. Successful installation of Swoole will score 0.3 points. |
[Topic 5 ] Orchestration and deployment of Hyperf framework [3.5 points ]
Write the /root/hyperf/project/docker-compose.yaml file. The specific requirements are as follows:
( 1 ) Container 1 name: hyperf-mysql ; Mirror: hyp erf-mariadb:v1.0 ; Port mapping: 3306:3306 ;
( 2 ) Container 2 name: hyperf-redis ; Image: hyperf-redi s:v1.0 ;
( 3 ) Container 3 name: hyperf-ui ; Image: hyperf-nginx:v1.0 ; Port mapping: 80:8081 ;
( 4 ) Container 4 name: hyperf- service ; Image: hyperf-service:v1.0 .
After completion, arrange and deploy the Hyperf framework, and submit the user name, password and IP address of the master node to the answer box.
1. Successfully orchestrating the docker-compose.yaml file will score 1.5 points; 2. Successfully accessing the service through port 8081 will score 1 point; 3.Hyperf-service successfully connects to the database and Redis and scores 1 point. |
[Task 3 ] Container cloud application deployment: Build CICD based on Kubernetes [8.0 points ]
The company decided to use Kubernetes + GitLab CI to build a CICD environment to shorten the development and launch cycle , meet customer needs in a timely manner, implement part of the DevOps process, reduce the burden , and achieve visual container life cycle management. To apply release and version iteration updates, please complete the CI CD environment deployment of GitLab CI + Kubernetes ( all software packages required to build continuous integration are in the software package CICD-Runner.tar.gz ). CICD Application Department
The system structure is as follows:
[Applicable Platform] Private Cloud
[Question 1 ] Install GitLab environment [1 point ]
Create a new namespace gitlab-ci in the Kubernetes cluster , deploy GitLab to this namespace, the Deployment and Service names are both gitlab , expose port 80 to the outside world as 30880 in NodePort mode , and set the password of the GitLab service root user to admin @123 , import the project package demo -2048. tar . gz into GitLab and name it demo-2048.
After completion, submit the username, password and IP address of the master node to the answer box. (The required software package path
CICD-Runner.tar.gz )
1. GitLab is deployed correctly and can be accessed normally and gets 0.5 points; 2. Successful project import will score 0.5 points. |
[Topic 2 ] Deploy GitLab Runner [2 points ]
Deploy GitLab Runner to the gitlab-ci namespace , the Release name is gitlab-runner , create a persistent build cache directory /home/gitlab-runner/ci-build- cache for GitLab Runner to speed up the build, and add it Register into GitLab . After completion, submit the username, password and IP address of the master node to the answer box. (The required software package path is CICD-Runner.tar.gz)
1. Successful deployment of GitLab Runner will score 0.5 points; 2. Successful registration of GitLab Runner will score 0.5 points; |
3.GitLab Runner 持久化配置成功得 1 分。 |
【题目 3】配置 GitLab[1.5 分]
将 Kubernetes 集群添加到 demo-2048 项目中, 并命名为 kubernetes-agent,项目命名空
间选择 gitlab-ci。
完成后提交 master 节点的用户名、密码和 IP 地址到答题框。(需要用到的软件包路径
CICD-Runner.tar.gz)
1.GitLab Agent 安装成功得 1 分; 2.Kubernetes 连接成功得 0.5 分。 |
【题目 4】构建 CICD[3.5 分]
编写流水线脚本.gitlab-ci.yml 触发自动构建, 具体要求如下:
(1)基于镜像 maven:3.6-jdk-8 构建项目的 drone 分支;
(2)构建镜像的名称: demo:latest;
(3)将镜像推送到 Harbor 仓库 demo 项目中;
(4)将 demo-2048 应用自动发布到 Kubernetes 集群 gitlab-ci 命名空间下。
完成后提交 master 节点的用户名、密码和 IP 地址到答题框。(需要用到的软件包路径
CICD-Runner.tar.gz)
1.项目变异成功得 0.5 分; 2.镜像构建成功得 1 分; 3.服务发布成功得 1 分; 4.服务能正常访问得 1 分。 |
【任务 4】容器云服务运维: Kubernetes 基于容器的运维[6 分]
【适用平台】私有云
【题目 1】Pod 管理--创建 Pod[0.5 分]
在 default 命名空间下使用 nginx:latest 镜像创建一个 QoS 类为 Guaranteed 的 Pod,名称
为 qos-demo。
完成后提交 master 节点的 IP 地址、用户名和密码到答题框。
1.Pod 创建成功得 0.2 分; 2.Pod QoS 类型为 Guaranteed 得 0.3 分。 |
【题目 2】安全管理--配置 Pod 安全上下文[0.5 分]
使用 busybox 镜像启动一个名为 context-demo 的 Pod,为该 Pod 配置安全上下文, 要求
容器内以用户 1000 和用户组 3000 来运行所有进程,并在启动时执行“sleep 1h”命令。
完成后提交 master 节点的 IP 地址、用户名和密码到答题框。
1.Pod 安全上下午配置正确得 0.5 分。 |
【题目 3】CRD 管理--创建自定义资源类型[0.5 分]
在 Kubernetes 集群中自定义一种资源类型 Student,API 为 stable.example.com/v1,单数 形式为 student,复数形式为 students,简写为 stu,作用域为命名空间级,然后在 default 命
名空间下创建一个名为 exam 的 Student 对象。
完成后提交 master 节点的 IP 地址、用户名和密码到答题框。
1.资源类型 Student 定义成功的 0.3 分; 2.exam 创建成功得 0.2 分。 |
【题目 4】解析管理--添加主机别名到 Pod[0.5 分]
使用 nginx 镜像在 default 命名空间下创建一个名为 nginx 的 Pod,并在 Pod 的/etc/hosts
中添加 IP 地址 127.0.0.1 与 chinaskills 的解析。
完成后提交 master 节点的 IP 地址、用户名和密码到答题框。
1.自定义解析配置正确得 0.5 分。 |
【题目 5】HPA 管理--创建 HPA 规则[1 分]
默认情况下 HPA 是无法调整伸缩灵敏度的,但不同的业务场景对伸缩灵敏度的要求不 一样。要求在 default 命名空间下使用 nginx 镜像创建一个名为 web 的 deployment,自定义 HPA 的伸缩灵敏度, 为该 deployment 创建一个名为 web 的 HPA,扩容时立即新增当前 9 倍 数量的副本数, 时间窗口为 5s,伸缩范围为 1-- 1000。例如一开始只有 1 个 Pod,当 CPU 使
用率超过 80%时, Pod 数量变化趋势为: 1 → 10 → 100 → 1000。
完成后提交 master 节点的 IP 地址、用户名和密码到答题框。
1.HPA 创建成功得 0.2 分; 2.HPA 伸缩策略配置正确得 0.8 分。 |
【题目 6】节点亲和性管理--创建硬限制规则的 Pod[0.5 分]
在 default 命名空间下使用 nginx 镜像运行一个 Pod ,名称为 nginx ,要求使用 requiredDuringSchedulingIgnoredDuringExecution 策略将 Pod 调度到具有“disktype=ssd”标
签的节点。
完成后提交 master 节点的用户名、密码和 IP 到答题框。
1.Pod 调度策略配置正确得 0.5 分。 |
【题目 7】网络策略管理--创建 Pod 网络策略[0.5 分]
创建一个网络策略 network-exam,要求只有 internal 命名空间下的 Pod 可以通过 TCP
协议的 8080 端口访问到 mysql 命名空间下的 Pod。
完成后提交 master 节点的 IP、用户名和密码到答题框。
1.网络策略创建成功得 0.2 分; 2.规则配置正确得 0.3 分。 |
【题目 8】驱逐机制管理--配置节点压力驱逐[0.5 分]
设置kubelet 数据存储在/apps/data/kubelet 目录下,并设置当kubelet 的存储空间不足 5%,
或者当容器运行时文件系统可用存储空间不足 5%时开始驱逐 Pod。
完成后提交 master 节点的 IP 地址、用户名和密码到答题框。
1.节点压力驱逐配置正确得 0.5 分。 |
【题目 9】流量管理--创建 Ingress Gateway[0.5 分]
使用提供的软件包 ServiceMesh.tar.gz 将 Bookinfo 应用部署到 default 命名空间下, 使用 Istio Gateway 可 以 实 现应 用程 序 从 外 部 访 问 , 请 为 Bookinfo 应 用创 建 一 个 名 为 bookinfo-gateway 的网关,指定所有 HTTP 流量通过 80 端口流入网格,然后将网关绑定到虚
拟服务 bookinfo 上。
完成后提交 master 节点的 IP 地址、用户名和密码到答题框。
1.Bookinfo 应用部署成功得 0.2 分; 2.Bookinfo 能通过网关访问得 0.3 分。 |
【题目 10】服务网格--创建基于用户身份的路由[0.5 分]
创建一个名为 reviews 路由,要求来自名为 Jason 的用户的所有流量将被路由到服务
reviews:v2。
完成后提交 master 节点的用户名、密码和 IP 到答题框。
1.路由创建成功得 0.2 分; 2.用户限制正确得 0.3 分。 |
【题目 11】服务网格--创建请求路由[0.5 分]
在default 命名空间下创建一个名为reviews-route 的虚拟服务,默认情况下,所有的HTTP 流量都会被路由到标签为 version:v1 的 reviews 服务的 Pod 上。此外, 路径以/wpcatalog/或 /consumercatalog/开头的 HTTP 请求将被重写为/newcatalog,并被发送到标签为 version:v2 的
Pod 上。
完成后提交 master 节点的 IP 地址、用户名和密码到答题框。
1.请求路由创建成功得 0.2 分; |
2.路由策略配置正确得 0.3 分。 |
【任务 5】容器云服务运维: Kubernetes 基于虚拟机的运维[4.0 分]
【适用平台】私有云
【题目 1】VM 管理--创建 VM[0.5 分]
使用镜像 fedora-virt:v1.0 在 default 命名空间下创建一台 vm,名称为 vm-fedora,内存为
1G。
完成后提交 master 节点的 IP 地址、用户名和密码到答题框。
1.VM 创建成功得 0.3 分; 2.VM 配置正确得 0.2 分。 |
【题目 2】存储与卷--创建 emptyDisk 卷[1 分]
使用镜像 fedora-virt:v1.0 在 default 命名空间下创建一台 vmi,名称为 vmi-fedora ,并使
用 emptyDisk 卷为 vmi 挂载一块 2G 的磁盘。
完成后提交 master 节点的 IP 地址、用户名和密码到答题框。
1.VMI 创建成功得 0.4 分; 2.卷挂载成功得 0.6 分。 |
【题目 3】KubeVirt 运维--创建 VMI[1.5 分]
将提供的镜像 exam.qcow2 转换为 docker 镜像 exam:v1.0,然后使用镜像 exam:v1.0 镜像 在 default 命名空间下创建一台 vmi,名称为 exam,将虚拟机的 80 端口以 NodePort 的方式
对外暴露为 30082,并使用数据源在启动时将 VM 的主机名初始化为 exam。
完成后提交 master 节点的 IP 地址、用户名和密码到答题框。
1.qcow2 镜像转化成功得 0.3 分; 2.VMI 创建成功得 0.3 分; |
3.端口暴露成功得 0.3 分; 4.服务能正常访问得 0.4 分; 5.主机名初始化成功得 0.2 分。 |
【题目 4】KubeVirt 运维--启用快照[1 分]
KubeVirt 支持对 VM 进行快照, 请启用 KubeVirt 快照管理功能:
完成后提交 master 节点的 IP 地址、用户名和密码到答题框。
1.快照功能启用成功得 1 分。 |
【任务 6】容器云运维开发:Kubernetes APIs 运维开发[10 分]
【适用平台】私有云
【题目 1】Python 运维开发:基于 Kubernetes Restful API 实现 Deployment 创建[2 分]
在提供的 OpenStack 私有云平台上,使用 k8s-python-dev 镜像创建 1 台云主机,云主机 类型使用 4vCPU/12G 内存/100G 硬盘。该主机中已经默认安装了所需的开发环境, 登录默
认账号密码为“root/1DaoYun@2022”。
使用 Kubernetes Restful API 库,在/root 目录下,创建 api_deployment_manager.py 文件,
要求编写 python 代码,代码实现以下任务:
(1)编写 Python 程序实现 Deployment 资源的创建。Deployment 配置信息如下。如果
同名 Deployment 存在, 先删除再创建。
(2)创建完成后, 查询该 Deployment 的详细信息, 执行结果控制台输出,以 yaml 格
式展示。
创建 Deployment 的 yaml 的配置如下:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.15.4
ports:
- containerPort: 80
1.执行 api_deployment_manager.py 脚本,成功创建 deployment 资源,计 1 分; 2.检查创建的 deployment 资源, 配置信息无误计 1 分。 |
【题目 2】Python 运维开发:基于 Kubernetes Python SDK 实现 Job 创建[1 分]
在前面已建好的 Kubernetes 开发环境云平台上。使用 Kubernetes python SDK 的
“kubernetes”Python 库, 在/root 目录下, 创建 sdk_job_manager.py 文件, 要求编写 python 代
码,代码实现以下任务:
(1)编写 Python 程序实现 Job 资源的创建。 Job 配置信息如下。如果同名 Job 存在,
先删除再创建。
(2)创建完成后, 查询该 Job 的详细信息, 执行结果控制台输出,以json 格式展示。
Job 创建 yaml 的信息如下:
apiVersion: batch/v1
kind: Job
metadata:
name: pi
spec:
template:
spec:
containers:
- name: pi
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
backoffLimit: 4
1.执行 sdk_job_manager.py 脚本, 成功创建job 资源,计 0.5 分; 2.查询job 资源, 配置信息无误,计 0.5 分。 |
【题目 3】Python 运维开发: Pod 资源的 Restful APIs HTTP 服务封装[3 分]
编写 Python 程序实现 Pod 资源管理程序, 将 Pod 资源管理的封装成 Web 服务。
在/root 目录下创建pod_server.py 程序,实现Pod 的增删查改等Web 访问操作。http.server
的 host 为 localhost,端口 8889;程序内部实现 Kubernetes 认证。
提示说明: Python 标准库 http.server 模块,提供了 HTTP Server 请求封装。
需要实现的 Restful API 接口如下:
GET /pod/{name} ,查询指定名称{name}的 Pod;Response 的 Body 以json 格式输出。
POST /pod/{yamlfilename} 创建 yaml 文件名称为{yamlfilename}的 Pod;Response 的
Body 以json 格式。
编码完成后,“手工下载”文件服务器主目录所有*.yaml 文件到 root 目录下,“手动执
行”所编写 pod_server.py 程序, 提交答案进行检测。
1.HTTP 服务成功启动, 计 1 分; 2.发起指定参数的 GET 查询 Pod 请求, 成功查询指定名称的 pod 服务, 计 1 分; |
3.发起指定参数的 POST 创建 Pod 请求, 成功创建 Pod 服务,计 1 分。 |
【题目 4】Python 运维开发: Service 资源 Restful APIs HTTP 服务封装[4 分]
编写 Python 程序实现 Service 资源管理程序,将 Service 资源管理的封装成 Web 服务。
在/root 目录下创建 service_server.py 程序, 实现 Service 的增删查改等 Web 访问操作。
http.server 的 host 为 localhost,端口 8888;程序内部实现 Kubernetes 认证。
提示说明: Python 标准库 http.server 模块,提供了 HTTP Server 请求封装。
需要实现的 Restful API 接口如下:
GET /services/{name} ,查询指定名称{name}的 Service;Response 的 Body 以json 格式
输出。
POST /services/{yamlfilename} 创建 yaml 文件名称为{yamlfilename}的 Service;
Response 的 Body 以json 格式,(手工将文件服务器主目录所有*.yaml 文件下载到 root 目录
下)。
DELETE /services/{name};删除指定名称的 Service;Response 的 Body 以json 格式。
编码完成后,自己手动执行提供 Web HTTP 服务的 service_server.py 程序,提交答案进
行检测。
1.HTTP 服务成功启动, 计 1 分; 2.发起指定参数的 POST 创建 service 请求,成功创建 service 资源,计 1 分; 3.发起指定参数的 GET 查询 service 请求, 成功查询指定名称的 Service,计 1 分; 4.发起指定参数的 DELETE 删除 service 请求,成功删除指定名称的 Service,计 1 分。 |