本文共分为俩部分kubernetes双证考试感悟和具体报考流程

 一 最近参加了kubernetes的双证考试认证即CKA、CKS,总体感觉俩点

1 认证目的不是拿证而是学习知识点,单纯的考试还是比较好考的 前提是相关的知识点已经掌握。

CKA的知识点包括RBAC授权,节点调度,升级版本,etcd备份与还原,网络策略,svc应用,ingress应用,pod扩容,pod配置多个容器,pv/pvc使用

,获取pop日志,增加收集日志容器

2 考试题目都是相同或者相类似的考试期间可以使用--help和官网文档,考试全是实际上机操作题,感觉CNCF的主旨是想培养使用者的解决问题的能力。

二报考流程

大致流程:

kubernetes认证安全专家 kubernetes 考证_考试系统

 

 第一步:账号登录 CKA+CKS双证考试资格购买地址: https://training.linuxfoundation.org/certification/certified-kubernetes-securityspecialist 打开会有一个弹窗,点击继续英文站点,

kubernetes认证安全专家 kubernetes 考证_kubernetes认证安全专家_02

 

kubernetes认证安全专家 kubernetes 考证_kubernetes认证安全专家_03

 

kubernetes认证安全专家 kubernetes 考证_nginx_04

 

第二步:下单交费 

kubernetes认证安全专家 kubernetes 考证_kubernetes认证安全专家_05

 

kubernetes认证安全专家 kubernetes 考证_nginx_06

 

第三步:预约考试前检查 

 支付成功后跳转到仪表盘,如果没跳转可直接访问仪表盘查看我的课程https://portal.linuxfoundation.org/portal 正常情况下会看到CKA和CKS认证课程及有效期,至此购买考试资格已经完成,等确定考试的时候再完成后续操作。 

kubernetes认证安全专家 kubernetes 考证_Pod_07

 

kubernetes认证安全专家 kubernetes 考证_kubernetes认证安全专家_08

 

第四步:预约考试 完成上述六项打钩后,点击Schedule 预约考试: 

kubernetes认证安全专家 kubernetes 考证_kubernetes认证安全专家_09

 

kubernetes认证安全专家 kubernetes 考证_kubernetes认证安全专家_10

 

 

kubernetes认证安全专家 kubernetes 考证_Pod_11

 

 第五步:考试环境检查 环境检查

kubernetes认证安全专家 kubernetes 考证_nginx_12

 

kubernetes认证安全专家 kubernetes 考证_kubernetes认证安全专家_13

 

预约完成,等待考试。 如果有事参加不了,要在考试前24小时且工作日内修改时间。 考试系统:https://www.examslocal.com 

 

考前须知

考试形式

 尽量提前10分钟左右进入倒计时页面(https://www.examslocal.com 点击登录->Or Sign In With->点击按钮 My Exams),等待出现进入考试系统的按钮(考官到位会出现),刚开始考官会让你出示证件,然后考官会让你拿摄像头环绕考试环境一周,确保房间无外人、桌面上没杂物,然后考官会让我们在考试系统里打开共享屏幕和摄像头按钮;最后考官会告诉我们一些注意事项,比如记事本功能,以及可以查阅哪些网站资料等等。考试过程中如有意外状况,可以在线与考官交流(文字),并争取你应有的权益;

 开始需要出示证件,有护照最好,如果没有可以使用身份证;如果有必要确认你的英文名可以用信用卡给他们看;

 在线考试,考试系统国内访问速度比较慢,需要一个稳定网络环境(强烈建议考试时间约在早上,越早越好,因为早上网络比较稳定,如果你的网络访问预约考试系统很慢,建议购买可FQ工具,我是早上6点考的没有使用梯子网络也是很好);

 只允许打开两个标签页,一个是考试系统,另一个建议打开官网文档 https://kubernetes.io/zh/docs/home/,将官网相关参考资料保存好书签,方便快速查找内容;

 考试全部都是实操任务题,会给出多个 K8s 集群,要求你在指定集群完成指定的操作;

 K8s集群环境采用ubuntu系统,不用担心,会普通用户执行sudo -i切root就行了,除了k8s升级版本这题用了apt软件包管理执行安装外,其他题操作都一样

CKA
1RBAC授权
Kubectl create clusterrole deployment-clusterrole --verb=create --resource=deployment,statefulset,daemonset
kubectl create -napp-team1 serviceaccount cicd-token
kubectl create rolebinding cicd-token -napp-team1  --clusterrole=deployment-clusterrole --serviceaccount=app-team1:cicd-token 
2节点设置不可用
kubectl drain master-k8s --ignore-daemonsets
3升级版本
apt-get install -y kubeadm=1.20.1-00
kubectl drain master-k8s --ignore-daemonsets
kubectl upgrade plan 
kubectl upgrade apply kubeadm=1.20.1-00
apt-get install -y kubectl=1.20.1-00 kubelet=1.20.1-00 --etcd-upgrade=false
systemctl restart kubele
kubectl uncordon master-k8s
kubectl get node
4etcd备份与恢复
ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379  --cacert=/opt/KUIN00601/ca.crt --cert=/opt/KUIN00601/etcd-clent.crt --key=/opt/KUIN00601/etcd-clent.key \
snapshot save /data/backup/etcd-snapshot.db
systemctl stop etcd
ps  -ef  |grep etcd
mv /var/lib/etcd/default.etcd /var/lib/etcd/default.etcdback
ETCDCTL_API=3 etcdctl --data-dir /data/backup/etcd-snapshot-previous.db snapshot restore snapshotdb
chown -R etcd:etcd /var/lib/etcd/default.etcd
systemctl start etcd
5 网络策略 
kubectl lable namepace big-corp name=big-corp
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-port-namespace
namespace: my-app
spec:
podSelector: {}
policyTypes:
- Ingress
ingress:
- from:
- namespaceSelector:
matchLabels:
name: big-corp
ports:
- protocol: TCP
port: 8080
6SVC暴露应用
kubectl edit deployment front-end
ports:
-  name: http
protocol: TCP
          containerPort: 80  
kubectl expose deployment front-end --port=80 --target-port=80 --type=NodePort --name=front-end-svc
7Ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: pond
namespace: ing-internal
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /hello
pathType: Prefix
backend:
service:
name: hello
port:
number: 5678
8扩容Pod数量
kubectl scale deployment loadbalancer --replicas=5
9nodeSelector 
apiVersion: v1
kind: Pod
metadata:
name: nginx-kusc00401
spec:
containers:
- name: nginx
image: nginx
nodeSelector:
disk: ssd
10统计准备就绪节点数量
kubectl get nodes 
kubectl describe node |grep Taint
11Pod配置多容器
apiVersion: v1
kind: Pod
metadata:
name: kucc4
spec:
containers:
- name: nginx
image: nginx
- name: redis
image: redis
- name: memcache
image: memcache
12创建PV 
apiVersion: v1
kind: PersistentVolume
metadata:
name: app-data
spec:
capacity:
storage: 2Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/svc/app-data"
13 Pod使用PVC
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pv-volume
spec:
storageClassName: csi-hostpath-sc
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Mi
---
apiVersion: v1
kind: Pod
metadata:
name: web-server
spec:
volumes:
- name: pv-volume
persistentVolumeClaim:
claimName: pv-volume
containers:
- name: web-server
image: nginx
ports:
- containerPort: 80
name: "web-server"
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: pv-volume
kubectl edit pvc  pv-volume --save-config
14获取Pod错误日志
kubectc logs pod bar |grep file-not-found >/opt/KUTR00101/bar
15给Pod增加一个容器(边车)
kubectl get pod legacy-app -o yaml >sidecar.yaml
apiVersion: v1
kind: Pod
metadata:
name: legacy-app
spec:
containers:
- name: legacy-app
image: busybox
args:
- /bin/sh
- -c
- >
i=0;
while true;
do
echo "$i: $(date)" >> /var/log/legacy-app.log;
done      
volumeMounts:
- name: varlog
mountPath: /var/log
- name: sidecar
image: busybox
args: [/bin/sh, -c, 'tail -n+1 -f /var/log/legacy-app.log']
volumeMounts:
- name: varlog
mountPath: /var/log
volumes:
- name: varlog
emptyDir: {}

 

16统计使用CPU最高的Pod

kubectl top pod -l name=cup-utilizer --sort-by='cpu' -A
echo "podname" >>/opt/KUR00401.txt

17 节点NotReady处理

kubectl config use-context wk8s
ssh wk8s-node-0
sudo -i
systemctl status kubelet
systemctl start kubelet
systemctl enable kubelet

曾经在幽幽暗暗反反复复中追问 才知道平平淡淡从从容容才是真