udemy学习-第五章

一些概念

在 Kubernetes 中,通常每个应用程序由一个 Deployment 表示,它管理一组运行该应用的 Pods。所以,统计 Deployment 的数量可以帮助你了解有多少个应用在集群中。

根据你之前的命令,似乎只有一个名为 "blue" 的 Deployment。因此,答案应该是 1 个应用。

一些技巧

image.png

任务和回答

We need to take node01 out for maintenance. Empty the node of all applications and mark it unschedulable.

kubectl drain node01 --ignore-daemonsets

"–ignore-daemonsets" 这部分的意思是忽略 DaemonSet 相关的 Pod,不会把它们也一并驱逐掉。
kubectl drain 命令的作用是让节点进入维护状态,把节点上的所有 Pod(除了 DaemonSet 和一些特定情况)都迁移到其他节点上,方便进行维护或升级。它会安全地停止节点上的 Pod,确保集群的正常运行。

DaemonSet 是 Kubernetes 中的一种控制器,用于确保在集群中的每个节点上都运行一个特定的 Pod,比如日志收集、监控或网络插件等。它的作用就像“守护程序”,在每个节点上都守护着一份任务。

任务和回答

The maintenance tasks have been completed. Configure the node node01 to be schedulable again.

kubectl uncordon node01

uncordon 的作用是让之前被标记为不可调度(unschedulable)的节点变回可调度状态,也就是说,允许新的 Pod 被调度到这个节点上,就像把节点“解封”一样,让它重新加入到集群的工作中。

但是新pod创建才会调度到node01上

image.png

任务和回答

Why did the drain command fail on node01? It worked the first time!

Sure! The key point is that the kubectl get pods -o wide command shows all pods and their nodes. If a pod isn't part of a ReplicaSet, it might be a standalone pod, which can cause issues when draining nodes because Kubernetes prefers to manage pods via ReplicaSets for graceful handling. In your case, the pod hr-app on node01 isn't part of a ReplicaSet, so the drain command may fail unless you use --force.

A forceful drain of the node will delete any pod that is not part of a replicaset.

任务和回答

image.png

当你强制驱逐(drain)node01时,hr-app这个Pod会被删除(evicted)掉,因为它没有被控制器(如Deployment)管理,属于孤立的Pod。这样,hr-app就会“消失”在集群中,无法继续运行,直到你重新在其他节点上部署它。
简而言之:hr-app会丢失,无法自动恢复。

任务和回答

image.png

区别cordon和uncordon


image.png

任务和回答

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

相关阅读更多精彩内容

  • K8S一、二进制搭建1.安装要求(1)CentOS 7(2)禁止swap(3)集群间互通 2.操作系统初始化(1)...
    Saka_2859阅读 576评论 0 0
  • 命令汇总查看 命令描述kubectl get svc/services获取 创建的services信息kubect...
    奔跑De猪阅读 716评论 0 0
  • JSON到YAML的格式转换: https://json2yaml.com/convert-yaml-to-jso...
    ben_782f阅读 438评论 0 0
  • kubernetes 安装 [root@master ~]# curl -O ftp://172.100.0.11...
    renne阅读 415评论 0 0
  • 容器技术概念入门篇 从进程说开去 容器本身没有价值,有价值的是“容器编排”。 容器其实是一种沙盒技术。顾名思义,沙...
    白板时钟阅读 2,776评论 0 2

友情链接更多精彩内容