所有命令都验证过,有更好的方式,欢迎留言~~~
CKA 习题和真题汇总
CKA考试经验:报考和考纲
CKA :2019年12月英文原题和分值
CKA考试习题:K8S基础概念--API 对象 CKA考试习题:调度管理- nodeAffinity、podAffinity、Taints CKA考试习题:K8S日志、监控与应用管理 CKA考试习题:网络管理-Pod网络、Ingress、DNS CKA考试习题:存储管理-普通卷、PV、PVC CKA考试习题:安全管理--Network Policy、serviceaccount、clusterrole CKA考试习题:k8s故障排查 CKA真题:题目和解析-1 CKA真题:题目和解析-2 CKA真题:题目和解析-3 CKA真题:题目和解析-4 CKA真题:题目和解析-5 CKA真题:题目和解析-6CKA真题:手动配置TLS BootStrap
更多CKA资料或交流:可加 wei xin :wyf19910905
调度管理 大 纲• 理解资源限制对Pod调度的影响
• 使用label selector调度Pod
• 手动调度Pod
• 理解DaemonSet
• 调度失败原因分析
• 使用多调度器
• 了解调度器的配置
nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution 硬性过滤规则支持指定 多条件之间的逻辑或运算
matchExpressions可以指定多个,单个matchExpressions内是与运算 podAffinity:与nodeAffinity的主要区别是,labelSelector匹配的对象不是node,而是集中已调度或将要调度pod topologyKey: 作用是--待调度的pod和目标pod是分配在哪个级别?同一个节点?机架?AZ?或自定义的node分组?-- 对node分组,依据label-key = topologyKey,每个label-value取值为一组
手动调度和DaemonSet 手动调度Pod(不经过调度器) DaemonSet:每个节点来一份 Taints:避免 Pod 调度到特定 Node 上 Tolerations:允许 Pod 调度到有特定 taints 的 Node 上operator:为Exist时,只需要匹配key
调度结果和失败原因分析
• 查看调度结果
kubectl get pod [podname] –o wide
• 查看调度失败原因(event)
kubectl describe pod [podname]
• 调度失败错误列表( kubernetes 1.9版本)
– https://github.com/kubernetes/kubernetes/blob/release-1.9/plugin/pkg/scheduler/algorithm/predicates/error.go#L25-L58
• 调度失败错误列表( kubernetes 1.9以上版本)
– https://github.com/kubernetes/kubernetes/blob/master/pkg/scheduler/algorithm/predicates/error.go#L25-L58
{ "kind" : "Policy", "apiVersion" : "v1", "predicates" : [ {"name" : "PodFitsHostPorts"}, {"name" : "PodFitsResources"}, {"name" : "NoDiskConflict"}, {"name" : "NoVolumeZoneConflict"}, {"name" : "MatchNodeSelector"}, {"name" : "HostName"} ], "priorities" : [ {"name" : "LeastRequestedPriority", "weight" : 1}, {"name" : "BalancedResourceAllocation", "weight" : 1}, {"name" : "ServiceSpreadingPriority", "weight" : 1}, {"name" : "EqualPriority", "weight" : 1} ], "hardPodAffinitySymmetricWeight" : 10, "alwaysCheckAllPredicates" : false }
调度管理习题1. 通过命令行,使用nginx镜像创建一个pod并手动调度到集群中的一个节点。
– Pod的名称为cat manual-deployment.yaml apiVersion: v1 kind: Pod metadata: name: hwcka-002-fly namespace: default labels: run: hwcka-002-fly spec: nodeName: node1 containers: -image: nginx name: hwcka-002-fly kubectl create -f manual-deployment.yaml
参考链接:https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodename
2. 通过命令行,创建两个deployment。
– 需要集群中有2个节点
– 第1个deployment名称为,使用nginx镜像,拥有2个pod,并配
置该deployment自身的pod之间在节点级别反亲和# kubectl create -f podAntiAffinity.yaml # cat podAntiAffinity.yam apiVersion: extensions/v1beta1 kind: Deployment metadata: labels: run: hwcka-002-app1-fly name: hwcka-002-app1-fly spec: replicas: 2 selector: matchLabels: run: hwcka-002-app1-fly strategy: {} template: metadata: creationTimestamp: null labels: run: hwcka-002-app1-fly spec: containers: - image: nginx name: hwcka-002-app1-fly resources: {} affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: run operator: In values: - hwcka-002-app1-fly topologyKey: kubernetes.io/hostname status: {}
– 第2个deployment名称为,使用nginx镜像,用有2个pod,并配
置该deployment的pod与第1个deployment的pod在节点级别亲和# kubectl create -f podAffinity.yaml # cat podAffinity.yaml apiVersion: extensions/v1beta1 kind: Deployment metadata: creationTimestamp: null labels: run: hwcka-002-app2-fly name: hwcka-002-app2-fly spec: replicas: 2 selector: matchLabels: run: hwcka-002-app2-fly strategy: {} template: metadata: creationTimestamp: null labels: run: hwcka-002-app2-fly spec: containers: - image: nginx name: hwcka-002-app2-fly resources: {} affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: run operator: In values: - hwcka-002-app2-fly topologyKey: kubernetes.io/hostname podAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: run operator: In values: - hwcka-002-app1-fly topologyKey: kubernetes.io/hostname status: {}
参考链接:https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
作者:琦彦