udemy学习-第三章调度器

调度器章节

image.png
image.png

任务:
Manually schedule the pod on node01.
答案:


image.png

image.png

任务和答案:


image.png

任务:
Create a taint on node01 with key of spray, value of mortein and effect of NoSchedule
答案:
kubectl taint nodes node01 spray=mortein:NoSchedule
概念:
总结:key 是分类标签,value 是具体内容,二者配合可以实现更细粒度的调度控制。没有固定值,主要看你的需求!

image.png

任务:
Remove the taint on controlplane, which currently has the taint effect of NoSchedule.
答案:
kubectl taint nodes controlplane node-role.kubernetes.io/control-plane:NoSchedule-

任务:
Apply a label color=blue to node node01
答案:
kubectl label node node01 color=blue

其实k8s命令还挺直接的,要加污点就是kubectl taint nodes xx,要对某个node加标签就是kubectl label node node01 xx=xx

任务:
Create a new deployment named blue with the nginx image and 3 replicas.
答案:
kubectl create deployment blue --image=nginx --replicas=3

任务和答案:


image.png

The status OOMKilled indicates that it is failing because the pod ran out of memory. Identify the memory limit set on the POD.

任务:
The elephant pod runs a process that consumes 10Mi of memory. Increase the limit of the elephant pod to 20Mi.
Delete and recreate the pod if required. Do not modify anything other than the required fields.
答案:


image.png

任务和答案:
默认的命名空间是default


image.png

任务和答案:

image.png

任务和答案:
Deploy a DaemonSet for FluentD Logging.
要写yaml文件然后apply

任务:
How many static pods exist in this cluster in all namespaces?
答案:
kubectl get pods --all-namespaces |wc -l

概念

image.png

任务和答案:
创建static pod需要设置restart=Never


image.png

一个比较复杂的任务:
要删掉一个static pod,但不在当前节点上,要先去看这个pod在哪个节点,再根据进程去找对应的配置文件路径,删掉后再去看pod


image.png

image.png

image.png

任务:
What is the priority value assigned to system-node-critical?
答案:


image.png

概念:
preemptionPolicy
这个字段控制在调度时,优先级较低的Pod是否可以抢占(preempt)优先级更高的Pod。它的值决定了抢占策略。

在 system-node-critical 这个PriorityClass中,preemptionPolicy 的值是 PreemptLowerPriority,意味着优先级较低的Pod可以抢占优先级更高的Pod,以确保关键系统Pod的运行。

任务:
Create another PriorityClass named low-priority with a value of 1000. Do not set this class as a global default.
答案:
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: low-priority
value: 1000
globalDefault: false
description: "This priority class is used for low-priority pods."
然后执行kubectl get priorityclasses这样去查看

任务:
What is the name of the POD that deploys the default kubernetes scheduler in this environment?
答案:
kubectl get pods --namespace=kube-system
Kubernetes 的核心组件(如调度器、API 服务器、控制器管理器等)都运行在 kube-system 命名空间里,这是 Kubernetes 预定义的系统命名空间,用于存放集群的系统级 Pod 和资源。

所以,调度器 Pod 也在 kube-system 命名空间中运行。

任务和答案:


image.png
image.png

一些概念

admission controller


image.png

他的配置文件如下所示


image.png
image.png
任务

Reconfigure the API server to enable the ImagePolicyWebhook admission plugin and ensure it can access the configuration files.

ImagePolicyWebhook admission plugin enabled on kube-apiserver?
admission-control-config-file flag set on kube-apiserver?
imgvalidation volume mounted in kube-apiserver?

image.png

一些概念

变异准入控制器(Mutating Admission Controller):在资源被创建或修改之前,可以修改请求中的对象,比如自动添加标签或注释。
验证准入控制器(Validating Admission Controller):在资源被创建或修改之后,验证请求的合法性,确保符合策略。

NamespaceAutoProvision:作为变异(Mutating)控制器
NamespaceExists:作为验证(Validating)控制器

NamespaceAutoProvision 会在资源创建时自动为命名空间提供一些变异操作(比如自动创建命名空间或添加标签)。
NamespaceExists 会在资源提交后验证命名空间是否存在,确保请求的合法性。

一些概念

TLS secret 是用来存储 TLS(传输层安全协议)证书和私钥的 Kubernetes 资源。它们用于为服务提供加密通信,确保数据在传输过程中安全、私密,常用于 HTTPS 和 Webhook 等场景。
如何创建:

kubectl -n webhook-demo create secret tls webhook-server-tls \
    --cert "/root/keys/webhook-server-tls.crt" \
    --key "/root/keys/webhook-server-tls.key"

一些概念

namespace和deployment的区别
Namespace 就像是一个虚拟的隔离空间,用来把不同的资源(如 Deployment、Service 等)分开管理,避免冲突。而Deployment 是用来定义和管理应用的副本(Pods),确保应用持续运行。

关系是:Deployment 需要在某个 Namespace 里创建,属于那个命名空间的资源。你可以在不同的 Namespace 中有相同名字的 Deployment,它们互不干扰。

一些概念

image.png

一些概念

指标服务器(Metrics Server)是一个集群级别的组件,用于收集和存储节点和Pod的资源使用数据(如CPU和内存),以便监控和自动扩展等功能。它是Kubernetes监控的基础之一。

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • K8S一、二进制搭建1.安装要求(1)CentOS 7(2)禁止swap(3)集群间互通 2.操作系统初始化(1)...
    Saka_2859阅读 572评论 0 0
  • 6. kubernetes 资源和调度 一、资源配额与限制 资源配额用于管理命名空间(NameSpace)中对象...
    升职哦阅读 843评论 0 1
  • JSON到YAML的格式转换: https://json2yaml.com/convert-yaml-to-jso...
    ben_782f阅读 429评论 0 0
  • 污点、容忍度 给了节点选则的主动权,我们给节点打一个污点,不容忍的 pod就运行不上来,污点就是定义在 节点上的键...
    菜头_355f阅读 973评论 0 2
  • Troubleshooting kubeadm As with any program, you might ru...
    JerryAi阅读 2,672评论 0 0

友情链接更多精彩内容