CKA
1. RBAC权限问题

Q: 创建一个名为Deployment-clusterrole的新ClusterRole,它仅允许创建以下资源类型:Deployment, statefulset,Daemonset 在现有名称空间 app-team1中创建一个名为cicd-token的新ServiceAccount。将新的ClusterRole部署群集绑定到新的服务帐户cicd-token,限于命名空间app-team1。

参考: https://kubernetes.io/docs/reference/access-authn-authz/rbac/

A:

 

2. pod驱逐

Q: 将名为ek8s-node-1的节点设置为不可用,并重新计划在其上运行的所有Pod。

参考:

A:

 

3. 升级

Q: 给定现有的运行版本1.18.8的Kubernetes集群,请升级所有Kubernetes控制平面和主节点上的节点组件仅适用于1.19.0版。 Be sure to drain the master node before upgrading it and uncordon it after the upgrade. do not upgrade the worker nodes,etcd,the container manager,the CNI plugin,the DNS service or any other addons.

参考:

https://v1-19.docs.kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade/#drain-the-control-plane-node

https://v1-19.docs.kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade/#upgrade-the-first-control-plane-node

A:

 

4. ETCD备份和恢复

Q: 备份 https://172.0.0.1:2379 的etcd 到 /var/lib/backup/etcd-snapshot.db

恢复 /data/backup/etcd-snapshot-previous.db 的快照

参考:

# 创建备份,参考⽹址:

https://kubernetes.io/docs/tasks/administer-cluster/configure-upgrade-etcd/#built-in-snapshot

A:

 

5. 网络策略

Q: 创建一个名为allow-port-from-namespace的新NetworkPolicy,以允许现有命名空间中的Pod my-app连接到同一命名空间中其他Pod的端口9200。确保新的NetworkPolicy 不允许访问未在端口9200上侦听的Pod,不允许来自不在名称空间my-app中的pod进行访问

参考:

https://kubernetes.io/docs/concepts/services-networking/network-policies/#networkpolicy-resource

https://kubernetes.io/docs/concepts/services-networking/network-policies/#default-deny-all-ingress-traffic

A:

6. 服务暴露

Q: 重新配置已经存在的deployment front-end,并添加一个names是http 的80/tcp端口暴露给已存在的nginx容器.创建一个名为front-end-svc的新服务,以暴露容器端口http。

配置新服务,使其还通过节点所在的节点上的NodePort公开各个Pod预定的。

参考: https://kubernetes.io/docs/concepts/services-networking/service/

A:

 

7. ingress

Q: 创建一个新的nginx Ingress资源,如下所示:

Name: ping Namespace: ing-internal

Exposing service hello on path /hello using service port 80

参考: https://kubernetes.io/docs/concepts/services-networking/ingress/#the-ingress-resource

A:

8. 扩缩容

Q: scale the deployment testpod to 4 pods.

A:

9. pod分配

Q: Schedule a pod as follows:

Name: nginx

image: nginx

Node selector: disk=ssd

参考: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#step-two-add-a-nodeselector-field-to-your-pod-configuration

A:

 

10. 污点查看

Q: 检查以查看准备就绪的节点数(不包括污染了NoSchedule的节点),然后将编号写入/opt/num.txt。

参考: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/

A:

 

11. 多容器的pod

Q: 创建一个多容器的pod , nginx + redis + memcached + consul

参考 : https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/

A:

 

12. 创建pv

Q: 创建一个pv with name app-config,of capacity 4Gi and access mode ReadWriteMany.The type of volume is hostPath and its location is /srv/app-config.

https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/#create-a-persistentvolume

A:

 

13. pvc使用扩容pv

Q: 创建一个新的pvc ,

名称: pv-volume 类: csi-hostpath-sc 容量: 10Mi

Create a new pod which mounts the PersistenVolumeClaim as a volume: Name: web-server image: nginx Mount path: /usr/share/nginx/html

配置新的Pod以在卷上具有ReadWriteOnce访问权限。

扩容: using kubectl edit or kubectl patch expand the PersistentVolumeClaim to a capacity of 70Mi and record that change

参考: https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/

https://kubernetes.io/docs/concepts/storage/storage-classes/#the-storageclass-resource

https://kubernetes.io/zh/docs/concepts/workloads/controllers/deployment/#updating-a-deployment

A:

 

14. 日志

Q: 监视pod bar的日志,并提取 error file-not-found 相对应的日志行,将它们写到/opt/test/bar

A:

 

15. sidecar

Q: 在现有的pod legacy-app中添加一个busybox sidecar容器。新的sidecat容器必须运行

/bin/sh -c tail -n+1 /var/log/legacy-app.log

使用名为log的卷挂载使文件/var/log/legacy-app.log 可用于sidecar容器。 不要修改现有容器。 不要修改日志文件的路径,两个容器都必须在/ var/log/legacy-app.log中访问它。

参考: https://kubernetes.io/zh/docs/concepts/storage/volumes/#emptydir

 

A:

 

16. labels

Q: 从pod标签name = overloaded-cpu中,找到运行高cpu工作负载的pod,并写出pod的名称 消耗最多的cpu到文件 /opt/test1.txt(已存在)。

A:

 

17. 故障处理

Q: 一个名为wk8s-node-0的kubernetes woker节点处于未就绪状态。调查这种情况的原因,以及 执行任何适当的步骤以使节点进入“就绪”状态,以确保进行了任何更改永恒的

A: