Kubernetes集群管理

Kubernetes集群管理

一、Node管理

1.Node的隔离与恢复

在硬件升级、硬件维护等情况下,需要将相应的node进行隔离,暂时脱离Kubernetes集群的调度范围。kubernetes提供了一种机制,既可以将Node加入集群调度,也可以将node脱离集群调度。

创建资源配置文件,在spec部分指定unschedulable为true:

apiVersion: v1
kind: Node
metadata:
  name: centos7-1
  labels:
    kubernetes.io/hostname: centos7-1
spec:
  podCIDR: 10.244.1.0/24                                                                                                                                               
  unschedulable: true

通过kubectl replace命令完成对Node状态的修改:

[root@centos7:/root/kubernetes/manifests/ops]
# kubectl replace -f unschedule_node.yaml

2019-04-07_232021.jpg

查看node状态,可以发现“STATUS”下增加了信息"SchedulingDisabled":

2019-04-07_232308.jpg

这样,系统在次创建pod时不会在向该Node进行调度。

在不使用资源配置文件时候,也可以通过kubectl patch命令完成:

# kubectl patch nodes centos7-1 -p '{"spec":{"unschedulable":true}}'

注意:将node脱离集群调度范围时,在其运行的pod不会自动停止,需要手动停止该node上运行的pod.

同样,将某个node重新纳入集群调度范围,则需要将unschedulable设置为“false”,在执行kubectl replace 或 kubectl path命令即可恢复系统对该Node的调度。

在kubernetes中,kubectl子命令"cordon"和"uncordon"也用于实现将Node进行隔离和恢复调度操作。

如,使用kubectl cordon命令对node进行隔离调度操作:

[root@centos7:/root]
# kubectl cordon centos7-1

2019-04-07_233336.jpg

使用kubectl uncordon命令对node进行恢复调度操作:

[root@centos7:/root]
# kubectl uncordon centos7-1

2019-04-07_233513.jpg
2.Node的扩容:


猜你喜欢

转载自blog.51cto.com/bovin/2375074