k8s的 Node and Cluster实战 Node and Cluster查看节点# 查看节点清单rootmaster30 ~14:58:52# kubectl get nodesNAME STATUS ROLES AGE VERSION master30.ggg.cloud Ready control-plane 95m v1.30.2 worker31.ggg.cloud Readynone28m v1.30.2 worker32.ggg.cloud Readynone28m v1.30.2# 查看特定节点详细信息rootmaster30 ~15:21:38# kubectl describe node worker31.ggg.cloud#重点关注LabelsConditionsNon-terminated PodAllocated resources等删除节点以 worker31 节点为例。# 设置节点为维护模式rootmaster30 ~15:23:12# kubectl drain worker31.ggg.cloud --ignore-daemonsetsnode/worker31.ggg.cloud already cordoned Warning: ignoring DaemonSet-managed Pods: kube-system/calico-node-6bltt, kube-system/kube-proxy-kx6kn node/worker31.ggg.cloud drained rootmaster30 ~15:23:24# kubectl get nodesNAME STATUS ROLES AGE VERSION master30.ggg.cloud Ready control-plane 97m v1.30.2 worker31.ggg.cloud Ready,SchedulingDisablednone30m v1.30.2 worker32.ggg.cloud Readynone30m v1.30.2# 删除 worker31 节点rootmaster30 ~15:23:27# kubectl delete node worker31.ggg.cloudnodeworker31.ggg.clouddeleted rootmaster30 ~15:23:50# kubectl get nodesNAME STATUS ROLES AGE VERSION master30.ggg.cloud Ready control-plane 97m v1.30.2 worker32.ggg.cloud Readynone31m v1.30.2# 重置删除的 worker31 节点rootworker31 ~15:24:18# kubeadm reset -f[preflight]Running pre-flight checks W080515:24:26.04828710253removeetcdmember.go:106][reset]No kubeadm config, using etcd pod spec to get data directory[reset]Deleted contents of the etcd data directory: /var/lib/etcd[reset]Stopping the kubeletservice[reset]Unmounting mounted directoriesin/var/lib/kubelet[reset]Deleting contents of directories:[/etc/kubernetes/manifests /var/lib/kubelet /etc/kubernetes/pki][reset]Deleting files:[/etc/kubernetes/admin.conf /etc/kubernetes/super-admin.conf /etc/kubernetes/kubelet.conf /etc/kubernetes/bootstrap-kubelet.conf /etc/kubernetes/controller-manager.conf /etc/kubernetes/scheduler.conf]The reset process does not clean CNI configuration. Todoso, you must remove /etc/cni/net.d The reset process does not reset or clean up iptables rules or IPVS tables. If you wish to reset iptables, you mustdoso manually by using theiptablescommand. If your cluster was setup to utilize IPVS, run ipvsadm--clear(or similar)to reset your systems IPVS tables. The reset process does not clean your kubeconfig files and you must remove them manually. Please, check the contents of the $HOME/.kube/config file. #重新加入 worker31 节点 rootworker31 ~ 15:24:26# kubeadm join 10.1.8.30:6443 --token cum331.6m74ji4yo7ffi5tw \ --discovery-token-ca-cert-hash sha256:6f83aa8722974ef53128918a78da3fdcf931db14f779941343e11862cc39c1d8 [preflight] Running pre-flight checks [preflight] Reading configuration from the cluster... [preflight] FYI: You can look at this config file with kubectl-nkube-system get cm kubeadm-config-oyaml [kubelet-start] Writing kubelet configuration to file /var/lib/kubelet/config.yaml [kubelet-start] Writing kubelet environment file with flags to file /var/lib/kubelet/kubeadm-flags.env [kubelet-start] Starting the kubelet [kubelet-check] Waiting for a healthy kubelet. This can take up to 4m0s [kubelet-check] The kubelet is healthy after 501.227089ms [kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap This node has joined the cluster: * Certificate signing request was sent to apiserver and a response was received. * The Kubelet was informed of the new secure connection details. Run kubectl get nodes on the control-plane to see thisnodejointhe cluster.#验证rootmaster30 ~15:24:43# kubectl get nodesNAME STATUS ROLES AGE VERSION master30.ggg.cloud Ready control-plane 99m v1.30.2 worker31.ggg.cloud Readynone22s v1.30.2 worker32.ggg.cloud Readynone32m v1.30.2删除集群删除集群流程删除所有 node删除所有 master具体步骤删除所有node节点rootmaster30 ~15:25:18# kubectl drain worker31.ggg.cloud --ignore-daemonsets --forcerootmaster30 ~15:45:50# kubectl drain worker32.ggg.cloud --ignore-daemonsets --forcerootmaster30 ~15:46:01# kubectl delete node worker31.ggg.cloud worker32.ggg.cloud# 重置节点注意执行位置rootworker31 ~15:24:18# kubeadm reset -frootworker32 ~14:58:56# kubeadm reset -f删除master节点# 删除集群前获取集群配置rootmaster30 ~15:46:12# kubectl get cm kubeadm-config -n kube-system -o yaml kubeadm.yml# 修改kubeadm.yml内容如下rootmaster30 ~15:46:22# vim kubeadm.yml# 删除1-3和22-28行效果如下apiServer: timeoutForControlPlane: 4m0s apiVersion: kubeadm.k8s.io/v1beta3 certificatesDir: /etc/kubernetes/pki clusterName: kubernetes controllerManager:{}dns:{}etcd: local: dataDir: /var/lib/etcd imageRepository: registry.k8s.io kind: ClusterConfiguration kubernetesVersion: v1.30.2 networking: dnsDomain: cluster.local podSubnet:10.224.0.0/16 serviceSubnet:10.96.0.0/12 scheduler:{}rootmaster30 ~15:46:44# kubectl delete node master30.ggg.cloudrootmaster30 ~15:46:47# kubeadm reset -frootmaster30 ~15:46:53# rm -fr .kube/重建集群# 初始化集群rootmaster30 ~15:53:44# kubeadm init --config kubeadm.yml# 也可以使用之前的命令rootmaster30 ~15:53:44# kubeadm init --kubernetes-versionv1.30.2 --pod-network-cidr10.224.0.0/16# 配置凭据rootmaster30 ~15:54:17# mkdir -p $HOME/.kuberootmaster30 ~15:54:17# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/configrootmaster30 ~15:54:17# sudo chown $(id -u):$(id -g) $HOME/.kube/config# 配置网络rootmaster30 ~15:53:59# kubectl apply -f calico.yaml# 加入集群rootworker31 ~15:46:24# kubeadm join 10.1.8.30:6443 --token quq3fd.z2cxskllch0gqo5i \--discovery-token-ca-cert-hash sha256:fc8f6417071df50562346fdfb79f4459ea8ba1c8f05031607ea75794ac593dfa rootworker32 ~15:46:29# kubeadm join 10.1.8.30:6443 --token quq3fd.z2cxskllch0gqo5i \--discovery-token-ca-cert-hash sha256:fc8f6417071df50562346fdfb79f4459ea8ba1c8f05031607ea75794ac593dfa

相关新闻

最新新闻

SerenityOS 命令行选项解析指南:getopt 与 getopt_long 用法、返回值与底层实现

SerenityOS 命令行选项解析指南:getopt 与 getopt_long 用法、返回值与底层实现

SerenityOS 命令行选项解析指南:getopt 与 getopt_long 用法、返回值与底层实现 【免费下载链接】serenity The Serenity Operating System 🐞 项目地址: https://gitcode.com/GitHub_Trending/se/serenity 导读 本文以 getopt(3) 手册 为核心&a…

2026/9/30 14:41:37
轻量服务器还是ECS?大促云服务器选购与避坑实战指南

轻量服务器还是ECS?大促云服务器选购与避坑实战指南

每年大促节点,群里永远有人在问同一个问题:“38元的轻量服务器到底怎么抢?为什么我每次点进去都是已售罄?68元直购和99元的ECS我到底选哪个?”作为一个常年帮团队和自己采购云服务器的老用户,我太清楚这种纠…

2026/9/30 21:32:07
为 AI 代理的 Review 动作编写 Cedar 审批门控策略:review-agent-governance 策略编写实战指南

为 AI 代理的 Review 动作编写 Cedar 审批门控策略:review-agent-governance 策略编写实战指南

为 AI 代理的 Review 动作编写 Cedar 审批门控策略:review-agent-governance 策略编写实战指南 【免费下载链接】agents Multi-harness agentic plugin marketplace for Claude Code, Codex, Cursor, OpenCode, GitHub Copilot, and Google Antigravity 项目地址:…

2026/9/30 19:41:56
PaddleOCR 手写数学公式识别算法 CAN 实战指南:Counting-Aware Network 训练、评估与推理部署

PaddleOCR 手写数学公式识别算法 CAN 实战指南:Counting-Aware Network 训练、评估与推理部署

PaddleOCR 手写数学公式识别算法 CAN 实战指南:Counting-Aware Network 训练、评估与推理部署 【免费下载链接】PaddleOCR Turn any PDF or image document into structured data for your AI. A powerful, lightweight OCR toolkit that bridges the gap between i…

2026/9/30 18:23:43
Spring源码解析:构造器注入的类型转换与候选匹配机制

Spring源码解析:构造器注入的类型转换与候选匹配机制

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/9/29 22:57:57
openai-agents-python 多模型接入指南:深入解析 AnyLLMModel 适配层与 any-llm 路由

openai-agents-python 多模型接入指南:深入解析 AnyLLMModel 适配层与 any-llm 路由

openai-agents-python 多模型接入指南:深入解析 AnyLLMModel 适配层与 any-llm 路由 【免费下载链接】openai-agents-python A lightweight, powerful framework for multi-agent workflows 项目地址: https://gitcode.com/GitHub_Trending/op/openai-agents-pyth…

2026/9/30 21:32:11

日新闻

周新闻

月新闻