我是靠谱客的博主 机灵未来,这篇文章主要介绍kubernetes 的管理之:Node 的管理,现在分享给大家,希望可以做个参考。

惯例,先介绍一下关键组件

一、Master

集群控制节点,在每个Kubernetes集群里都需要有一个Master来负责整个集群的管理和控制工作,基本上Kubernetes的所有命令都发个它,它负责具体的执行过程。是整个集群的大脑。

Master上关键进程:

  • Kubernetes API Server(kube-apiserver):提供了HTTP Rest 接口的关键服务进程,是kubernetes里所有资源的增,删,改,查的操作的唯一入口,也是集群控制的入口进程。
  • Kubernetes Controller Manager(kube-controller-manager):kubernetes 里所有资源对象的自动化控制中心,可以将其理解为资源对象的“大总管”。
  • Kubernetes Scheduler(kube-scheduler):负责资源(Pod)的调度。
  • Etcd服务:kubernetes上资源对象的数据被保存在其中。

二、Node

Kubernetes工作负载节点,除了master ,Kubernetes集群中其他的机器被称为Node,Node可以是物理机,也可以是虚拟机,Node 也可以被看错kubernetes上的资源,进行调度和配置。

Node上关键进程

  • kubelet:负责Pod对应容器的创建、起停的任务,与master协作,管理集群。
  • kube-proxy:实现Kubnernetes Service 的通信与负载均衡机制的主要组件。
  • Docker-Engine:Docker 引擎,负责本机的容器创建管理工作。

三、client-go Node 管理

1. Node 的隔离和恢复

其实Node 的隔离和恢复,主要是通过spec.unscheduled 字段进行控制

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
k8s.io/api/core/v1/types.go // NodeSpec describes the attributes that a node is created with. type NodeSpec struct { // PodCIDR represents the pod IP range assigned to the node. // +optional PodCIDR string `json:"podCIDR,omitempty" protobuf:"bytes,1,opt,name=podCIDR"` // ID of the node assigned by the cloud provider in the format: <ProviderName>://<ProviderSpecificNodeID> // +optional ProviderID string `json:"providerID,omitempty" protobuf:"bytes,3,opt,name=providerID"` // Unschedulable controls node schedulability of new pods. By default, node is schedulable. // More info: https://kubernetes.io/docs/concepts/nodes/node/#manual-node-administration // +optional Unschedulable bool `json:"unschedulable,omitempty" protobuf:"varint,4,opt,name=unschedulable"` // If specified, the node's taints. // +optional Taints []Taint `json:"taints,omitempty" protobuf:"bytes,5,opt,name=taints"` // If specified, the source to get node configuration from // The DynamicKubeletConfig feature gate must be enabled for the Kubelet to use this field // +optional ConfigSource *NodeConfigSource `json:"configSource,omitempty" protobuf:"bytes,6,opt,name=configSource"` // Deprecated. Not all kubelets will set this field. Remove field after 1.13. // see: https://issues.k8s.io/61966 // +optional DoNotUse_ExternalID string `json:"externalID,omitempty" protobuf:"bytes,2,opt,name=externalID"` }

当上述Node结构中Unschedulable 字段设置为true,后续被创建的Node就不会被调度到该Node上了。
注:其上运行的Pod不会自动停止,需要人工干预,此行为跟Node“失联”不同。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
client-go/kubernetes/type/core/v1/node.go // NodeInterface has methods to work with Node resources. type NodeInterface interface { Create(*v1.Node) (*v1.Node, error) Update(*v1.Node) (*v1.Node, error) UpdateStatus(*v1.Node) (*v1.Node, error) Delete(name string, options *metav1.DeleteOptions) error DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error Get(name string, options metav1.GetOptions) (*v1.Node, error) List(opts metav1.ListOptions) (*v1.NodeList, error) Watch(opts metav1.ListOptions) (watch.Interface, error) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Node, err error) NodeExpansion }

可以通过上述接口,实现对Node的相关管理。

2、Node 的扩容

在实际生产关系中,会出现服务器资源不足的情况,这样就需要对集群进行扩容,增加Node,那么如何扩容呢?
非常简单,在新的node上安装以上Docker,kubelet,kube-proxy三个服务,并将启动参数master配置为需要加入的集群Master地址即可。kubelet会自动注册,这样就完成了扩容,没有复杂的配置,无需起停集群。

最后

以上就是机灵未来最近收集整理的关于kubernetes 的管理之:Node 的管理的全部内容,更多相关kubernetes内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(66)

评论列表共有 0 条评论

立即
投稿
返回
顶部