Introduction

做之前记得切换到对应context

You can open two browsers Tab, one is the test window,A is used to refer to (official documentation )

Q1:RBAC

Create a new ClusterRole named deployment-clusterrole at only allows the creation of the following resource types:

  • Deployment
  • StatefulSet
  • DaemonSet
    Create a new ServiceAccount named cicd-token in the existing namespace app-team1.
    Limited to namespace app-team1, bind the new ClusterRole -to the new ServiceAccount cicd-token.

kubectl create clusterrole deplyoment-clusterrole --verb=create --resource=deployment,statefulset,daemonset
kubectl create ns app-team1
kubectl create sa cicd-token -n app-team1
kubectl -n app-team1 create rolebinding cici-binding --clusterrole=deployment-clusterrole --serviceaccount=cicd-toekn:app-team1

Q2:Specifies that Node is set to unavailable

Set the node named ek8s-node-1 as unavaliable and reschedule all the pods running on it.


kubectl cordon node1
kubectl drain node1 --delete-local-data --ignore-daemonsets --force

Q3: Upgrading Kubernetes nodes

Given an existing Kubernetes cluster running version 1.20.0,upgrade all of Kubernetes control plane and node components on the master node only to version 1.20.1。

You are also expected to upgrade kubelet and kubectl on the master node。

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.


kubectl cordon node1
kubectl drain node1 --delete-local-data --ignore-daemonsets --force
ssh node1
apt-get update
apt-get install -y kubeadm=1.20.1-00
kubeadm version
kubeadm upgrade plan
kubeadm upgrade apply v1.20.1 --etcd-upgrade=false
apt-get install -y kubelet=1.20.1-00 kubectl=1.20.1-00
sudo systemctl daemon-reload
sudo systemctl restart kubelet
kubectl get nodes

Q4:ETCD backup restore


ETCDETC_API=3 etcdctl --endpoints=127.0.0.1:2379 --cacert=/opt/KUIN00601/ca.crt --cert=/opt/KUIN00601/etcd-client.crt --key=/opt/KUIN00601/etcd-client.key snapshot save /srv/data/etcd-snapshot.db
ETCDETC_API=3 etcdctl --endpoints=127.0.0.1:2379 --cacert=/opt/KUIN00601/ca.crt
--cert=/opt/KUIN00601/etcd-client.crt /var/lib/backup/etcd-snapshot-previous.db

Q5:①Same namespace create NetworkPolicy

Create a new NetworkPolicy named allow-port-from-namespace to allow Pods in the existing namespace internal to connect to port 9000 of other Pods in the same namespace.
Ensure that the new NetworkPolicy:

  • does not allow access to Pods not listening on port 9000.
  • does not allow access from Pods not in namespace corp-bar
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:name: allow-port-from-namespacenamespace: internal
spec:podSelector: {}policyTypes:- Ingressingress:- from:- podSelector: {}- namespaceSelector:matchLabels:project: corb-barports:- protocol: TCPport: 9000

Q6:Create Service

Reconfigure the existing deployment front-end and add a port specifiction named http exposing port 80/tcp of the existing container nginx.

Create a new service named front-end-svc exposing the container prot http.

Configure the new service to also expose the individual Pods via a NodePort on the nodes on which they are scheduled.


kubectl expose deployment front-end --name=front-end-svc  --port=80 --target-port=80 --type=NodePort --protocol=TCP

Q7:Create Ingress

Create a new nginx Ingress resource as follows:

  • Name: ping
  • Namespace: ing-internal
  • Exposing service hi on path /hi using service port 5678

The avaliability of service hi can be checked using the following command,which should return hi:
curl -kL /hi


apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:name: pingnamespace: ing-internalannotations:nginx.ingress.kubernetes.io/rewrite-target: /
spec:rules:- http:paths:- path: /hipathType: Prefixbackend:service:name: hiport:number: 5678

Q8:Scale Deployment

Task

Scale the deployment loadbalancer to 6 pods


kubectl scale deployment loadbalancer --replicas=6

Q9:Make pod assgin to node

Task

Schedule a pod as follows:

  • Name:nginx-kusc00401
  • Image:nginx
  • Node selector:disk=spinning

apiVersion: v1
kind: Pod
metadata:name: nginx-kusc00401
spec:containers:- name: nginximage: nginximagePullPolicy: IfNotPresentnodeSelector:disk: spinning

Q10:Check how many Node nodes are healthy

Task
Check to see how many nodes are ready (not including nodes tainted NoSchedule)and write the number to /opt/KUSC00402/kusc00402.txt.


kubectl describe node |grep -i taints |grep -i -v NoSchedule > /opt/KUSC00402/kusc00402.txt

Q11: Create PODs for multiple Containers

Create a pod named kucc8 with a single app container for each of the following images running inside (there may be between 1 and 4 images specified):
nginx + redis + memcached + consul .


apiVersion: v1
kind: Pod
metadata:name: kucc8
spec:containers:- name: nginximage: nginx- name: redisimage: redis- name: memcachedimage: memcached- name: consulimage: consul

Q12:Create Persistent Volume

Task
Create a persistent volume whit name app-config, of capacity 2Gi and access mode ReadOnlyMany . the type of volume is hostPath and its location is /srv/app-config .


apiVersion: v1
kind: PersistentVolume
metadata:name: app-config
spec:capacity:storage: 2GiaccessModes:- ReadWriteManyhostPath:path: /srv/app-config

Q13:Create PersistentVolumeClaim

Task
Create a new PersistentVolumeClaim:

  • Name: pv-volume
  • Class: csi-hostpath-sc
  • Capacity: 10Mi

Create a new Pod which mounts the PersistentVolumeClaim as a volume:

  • Name: web-server
  • Image: nginx
  • Mount path: /usr/share/nginx/html

Configure the new Pod to have ReadWriteOnce access on the volume.


apiVersion: v1
kind: PersistentVolumeClaim
metadata:name: pv-volume
spec:storageClassName: csi-hostpath-scaccessModes:- ReadWriteOnceresources:requests:storage: 10Mi
---
apiVersion: v1
kind: Pod
metadata:name: web-server
spec:volumes:- name: task-pv-storagepersistentVolumeClaim:claimName: pv-volume- name: web-serverimage: nginxports:- containerPort: 80name: "http-server"volumeMounts:- mountPath: "/usr/share/nginx/html"name: task-pv-storage

Finally,using kubectl edit or Kubectl patch expand the PersistentVolumeClaim to a capacity of 70Mi and record that change

kubecti edit pvc pv-volume
#change 10Mi to 70Mi
#wq

Q14:Monitor Pods logs

Task:
Monitor the logs of pod foobar and:

  • Extract log lines corresponding to error unable-to-access-website
  • Write them to /opt/KUTR00101/bar

kubectl logs foobar |grep unable-to-access-website > /opt/KUTR00101/bar

Q15:Add sidecar container

Context
Without changing its existing containers,an existing Pod needs to be integrated into Kubernetes’s build-in logging architecture (e.g. kubectl logs). Adding a streaming sidecar container is a good and common way to accomplish this requirement.

Task
Add a busybox sidecar container to the existing Pod legacy-app. The new sidecar container has to run the following command:

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

Use a volume mount named logs to make the file **/var/log/legacy-app.log available to the sidecar container.

Don’t modify the existing container.
Don’t modify the path of the log file,both containers must access it at /var/log/legacy-app.log.


apiVersion: v1
kind: Pod
metadata:name: legacy-app
spec:containers:- name: countimage: busyboxargs:- /bin/sh- -c- >i=0;while true;doecho "$i: $(date)" >> /var/log/legacy-app.log;i=$((i+1));sleep 1;done      volumeMounts:- name: logsmountPath: /var/log- name: busyboximage: busyboxargs: [/bin/sh, -c, 'tail -n+1 -f /var/log/legacy-app.log']volumeMounts:- name: logsmountPath: /var/logvolumes:- name: logsemptyDir: {}

Q16:View the POD with the highest CPU usage

Form the pod label name-cpu-loader,find pods running high CPU workloads and write the name of the pod consuming most CPU to the file /opt/KUTR00401/KURT00401.txt(which alredy exists).


kubectl top pods -l app=nginx |head -n2 |tail -n 1 |awk '{print $1} > /opt/KUTR00401/KURT00401.txt

Q17:Cluster troubleshooting

Task
A Kubernetes worker node,named wk8s-node-0 is in state NotReady .
Investigate why this is the case,and perform any appropriate steps to bring the node to a Ready state,ensuring that any changes are made permanent.


kubectl get nodes
ssh root@wk8s-node-0
systemctl status kubelet
systemctl start kubelet
systemctl enable kubelet
systemctl daemon-reload
#switch master
kubectl get nodes

CKA-英文题目-个人答案-(模拟练习用相关推荐

  1. 计算机网络-自顶向下方法(7th) 第二章 Review Questions 英文题目+中文答案

    SECTION 2.1 R1. List five nonproprietary Internet applications and the application-layer protocols t ...

  2. java程序设计模拟题_《Java程序设计》东师模拟题题目及答案

    <Java程序设计>东师模拟题题目及答案 2020-08-30 09:08:37 931 有学员问关于<Java程序设计>东师模拟题题目及答案的题目的参考答案和解析,具体如下: ...

  3. 华为公司面试新员工的有关计算机网络的题目和答案

    一.华为公司面试新员工的有关计算机网络的题目和答案 RFC1918文件规定了保留作为局域网使用的私有地址:            10.0.0.0                 -       10 ...

  4. 剑指offer题目及答案

    剑指offer 最近在牛客网上刷剑指offer的题目,现将题目和答案总结如下: 1. 二维数组的查找 2. 替换空格 3. 从尾到头打印链表 4. 重建二叉树 5. 用两个栈实现队列 6. 旋转数组的 ...

  5. 《大富翁8》中智力问答的题目、答案

    去了一次现金流俱乐部,回来想想还是拿<大富翁8>练练手,当夜就熬到3点,最后以破产告终.还是觉得这个游戏有些弱智,不过比较适合几个朋友或者男女朋友之间娱乐之用,还是有些意思.其中的一些问答 ...

  6. Leetcode 每日一题双题版(2.25+2.24)模拟练细节

    Leetcode 每日一题双题版(2.25+2.24)模拟练细节 前言 刚刚敲了今天刷新的题目,然后昨天的也写了,就想着更新一下blog 两道题都是模拟题,对于模拟,我的看法就是看懂题目,拿捏细节,难 ...

  7. cc2530期末试卷_ZigBee应用技术答案试题题目及答案,期末考试题库,章节测验答案...

    ZigBee应用技术答案试题题目及答案,期末考试题库,章节测验答案 更多相关问题 [判断题] 期现套利与现货并没有实质性联系,现货风险对它们而言无关紧要.()[多选] 历史模拟法在计算VaR时具有() ...

  8. 电中在线计算机应用基础二考试题目及答案,最新电大2015计算机应用基础作业2 答案.doc...

    计算机作业2 单项选择题:第1题:在Word中编辑文本时,编辑区显示的"水印"在打印时( )出现在纸上.(2分)A.不会B.全部C.一部分D.大部分第2题:Word文档以文件形式存 ...

  9. 2022安全员-C证上岗证题目及答案

    题库来源:安全生产模拟考试一点通公众号小程序 2022安全员-C证上岗证题库系安全员-C证考试题目仿真模拟预测!2022安全员-C证上岗证题目及答案依据安全员-C证新考试大纲.安全员-C证模拟考试题库 ...

最新文章

  1. SQLite的数据类型总结
  2. EnterpriseLibrary2.0系列文章及下载
  3. 访问数组元素进行获取
  4. /src/applicationContext.xml
  5. 阿里P8架构师谈:分布式事务的解决方案,以及原理、总结
  6. python+webdriver(三)
  7. keyshot局部打光_keyshot7耳机渲染打光教程
  8. glove中文词向量_《GloVe:Global Vectors for Word Representation》学习
  9. java 二叉树的高度_最全二叉树:完整详解二叉树的遍历以及完全二叉树等6种二叉树...
  10. 再见了,面向对象编程
  11. Symantec BE 安装及备份oracle 完整版
  12. 服务器系统启用flash,基础设置:Windows Server 2012及2012R2 启用IE Flash
  13. jquery prop(“outerHTML“) 获取当前标签和标签内部的html 代码
  14. 国内访问英文版维基百科地址
  15. Elasticsearch构建全文搜索系统
  16. 斗鱼实时计算平台的演进
  17. 使用Canal ClientAdapter实现Mysql的DDL、DML同步到PostgreSQL
  18. 华为华为Mate30pro青春版参数配置
  19. macM1芯片通过第三方安装php
  20. 真正厉害的人,都在延迟满足

热门文章

  1. VS2008的黑色皮肤
  2. 证券法律法规体系所有法律_告诉我法律
  3. ⑨电子产品拆解分析-触摸化妆镜
  4. 整理了100个市面上常用的测试工具,希望能帮助到大家...
  5. 第三十七节 java学习——color类
  6. 获取Windows7特殊文件夹的权限
  7. 最新 Arduino 驱动 12接口/户外 LED显示屏/LED点阵屏/LED单元板
  8. 浅析钓鱼网站原理及模拟搭建
  9. android:inputType 类型详细介绍
  10. EditText输入类型InputType值