首页 > 其他分享 >Kubernetes-Cluster Architecture

Kubernetes-Cluster Architecture

时间:2023-04-16 17:34:32浏览次数:49  
标签:node Node Kubernetes kubelet Cluster API Architecture Pod

title: Kubernetes-Cluster Architecture
date: 2022-05-2 8:00:04
author: liudongdong1
img: https://cdn.pixabay.com/photo/2022/05/05/01/11/cormorant-7175037__340.jpg
cover: false
categories: Storage
tags:
  - Storage

Kubernetes runs your workload by placing containers into Pods to run on Nodes. A node may be a virtual or physical machine, depending on the cluster.

Kubernetes主要由以下几个核心组件组成:

  • etcd保存了整个集群的状态;
  • apiserver提供了资源操作的唯一入口,并提供认证、授权、访问控制、API注册和发现等机制;
  • controller manager负责维护集群的状态,比如故障检测、自动扩展、滚动更新等;
  • scheduler负责资源的调度,按照预定的调度策略将Pod调度到相应的机器上;
  • kubelet负责维护容器的生命周期,同时也负责Volume(CVI)和网络(CNI)的管理;
  • Container runtime负责镜像管理以及Pod和容器的真正运行(CRI);
  • kube-proxy负责为Service提供cluster内部的服务发现和负载均衡;

除了核心组件,还有一些推荐的Add-ons:

  • kube-dns负责为整个集群提供DNS服务
  • Ingress Controller为服务提供外网入口
  • Heapster提供资源监控
  • Dashboard提供GUI
  • Federation提供跨可用区的集群

img

img

List-Watch机制控制器架构

1、客户端提交创建请求,可以通过API Server的Restful API,也可以使用kubectl命令行工具。支持的数据类型包括JSON和YAML。

2、API Server处理用户请求,存储Pod数据到etcd

3、调度器通过API Server查看未绑定的Pod。尝试为Pod分配主机。

4、过滤主机 (调度预选):调度器用一组规则过滤掉不符合要求的主机。比如Pod指定了所需要的资源量,那么可用资源比Pod需要的资源量少的主机会被过滤掉。

5、主机打分(调度优选):对第一步筛选出的符合要求的主机进行打分,在主机打分阶段,调度器会考虑一些整体优化策略,比如把容一个Replication Controller的副本分布到不同的主机上,使用最低负载的主机等。

6、选择主机:选择打分最高的主机,进行binding操作,结果存储到etcd中

7、kubelet根据调度结果执行Pod创建操作: 绑定成功后,scheduler会调用APIServer的API在etcd中创建一个boundpod对象,描述在一个工作节点上绑定运行的所有pod信息。运行在每个工作节点上的kubelet也会定期与etcd同步boundpod信息,一旦发现应该在该工作节点上运行的boundpod对象没有更新,则调用Docker API创建并启动pod内的容器。

image.png

1. Node

.1. Node status

1. Address

  • HostName: The hostname as reported by the node's kernel. Can be overridden via the kubelet --hostname-override parameter.
  • ExternalIP: Typically the IP address of the node that is externally routable (available from outside the cluster).
  • InternalIP: Typically the IP address of the node that is routable only within the cluster.

2. Conditions

Node Condition Description
Ready True if the node is healthy and ready to accept pods, False if the node is not healthy and is not accepting pods, and Unknown if the node controller has not heard from the node in the last node-monitor-grace-period (default is 40 seconds)
DiskPressure True if pressure exists on the disk size—that is, if the disk capacity is low; otherwise False
MemoryPressure True if pressure exists on the node memory—that is, if the node memory is low; otherwise False
PIDPressure True if pressure exists on the processes—that is, if there are too many processes on the node; otherwise False
NetworkUnavailable True if the network for the node is not correctly configured, otherwise False

3. Capacity and Allocatable

  • Describes the resources available on the node: CPU, memory, and the maximum number of pods that can be scheduled onto the node.

4. Info

  • Describes general information about the node, such as kernel version, Kubernetes version (kubelet and kube-proxy version), container runtime details, and which operating system the node uses. The kubelet gathers this information from the node and publishes it into the Kubernetes API.

2. Control Plane-Node Communication

.1. Node to Control Plane

  • The apiserver is configured to listen for remote connections on a secure HTTPS port (typically 443) with one or more forms of client authentication enabled.

.2. Control Plane to node

1. apiserver to kubelet

  • Fetching logs for pods.
  • Attaching (through kubectl) to running pods.
  • Providing the kubelet's port-forwarding functionality.

2. apiserver to nodes, pods, and services

  • from the apiserver to any node, pod, or service through the apiserver's proxy functionality

3. Cloud controller manager

.1. Node controller

  1. Update a Node object with the corresponding server's unique identifier obtained from the cloud provider API.
  2. Annotating and labelling the Node object with cloud-specific information, such as the region the node is deployed into and the resources (CPU, memory, etc) that it has available.
  3. Obtain the node's hostname and network addresses.
  4. Verifying the node's health. In case a node becomes unresponsive, this controller checks with your cloud provider's API to see if the server has been deactivated / deleted / terminated. If the node has been deleted from the cloud, the controller deletes the Node object from your Kubernetes cluster.

.2. Route controller

  • configuring routes in the cloud appropriately so that containers on different nodes in your Kubernetes cluster can communicate with each other.

.3. Service controller

  • integrate with cloud infrastructure components such as managed load balancers, IP addresses, network packet filtering, and target health checking.

4. Container Runtime Interface (CRI)

  • The Kubernetes Container Runtime Interface (CRI) defines the main gRPC protocol for the communication between the cluster components kubelet and container runtime
  • The kubelet acts as a client when connecting to the container runtime via gRPC. The runtime and image service endpoints have to be available in the container runtime, which can be configured separately within the kubelet by using the --image-service-endpoint and --container-runtime-endpoint command line flags

5. Framework

Resource

标签:node,Node,Kubernetes,kubelet,Cluster,API,Architecture,Pod
From: https://www.cnblogs.com/liu-dongdong/p/17323650.html

相关文章

  • Jenkins: Kubernetes Plugin
     envinjenkinscontroller  Jenkinsdynamicslaveagent      PodTemplateinJenkinsUI    Examplefromgitpipeline{agent{kubernetes{cloud'kubernetes'defaultContainer'mav......
  • kubernetes 1.25.0 安装部署
    1.环境说明主机IP地址备注k8s-master192.168.0.200控制节点k8s-node1192.168.0.200工作节点k8s-node2192.168.0.200工作节点2.准备工作(所有节点)分别设置主机名hostnamectlset-hostnamek8s-masterhostnamectlset-hostna......
  • Kubernetes API相关知识
    Kubernetes集群中,所有组件需要操作集群资源时都通过调用kube-apiserver提供的RESTful接口来实现。kube-apiserver进一步和etcd交互,完成资源信息的更新。Kubernetes中的资源本质上是一个API对象,这个对象的期望状态被APIServer保存在etcd中,然后提供RESTful接口用于更新这些对象。......
  • kubernetes-nfs共享存储
    搭建nfs服务端#修改权限chmod-R777/nfs/data#编辑export文件vim/etc/exports/nfs/data*(rw,no_root_squash,sync)(“*“代表所有人都能连接,建议换成具体ip或ip段,如192.168.20.0/24)#配置生效exportfs-r#查看生效exportfs#启动rpcbind、nfs服务systemctlresta......
  • Kubernetes security context capability
    注:以下内容基于经验主义,不一定对。LinuxcapabilityLinux中,root作为特权用户,具有执行所有应用的能力。而普通用户只能执行普通应用。如果普通用户需要执行特权应用,需要进行SUID提权,使得普通用户在执行具有SUID的应用时短暂获得特权用户的身份。这一设计容易出现漏洞,漏洞......
  • kubernetes安装
    初始化kubeadminit的时候要指定cidr,安装CNI网络插件Flannel的时候也要设置对应的CIDR配置文件工作目录/etc/kubernetes总体过程kubectl官方命令使用帮助:https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commandshelm官方命令使用帮助:https://helm.sh/docs/......
  • es 同步索引报错:ElasticSearch ClusterBlockException[blocked by: [FORBIDDEN/12/ind
    es同步索引报错:ElasticSearchClusterBlockException[blockedby:[FORBIDDEN/12/indexread-only/allowdelete(api)]原因:网上有的解决方式是方法一,我试过,没有生效使用的是方法二方法一curl-XPUT-H"Content-Type:application/json"https://localhost:9200/_all/_set......
  • kubernetes 中排查dns解析问题
    参考官方:https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/文档中提供的dnsutils镜像下载不到,修改镜像地址wgethttps://k8s.io/examples/admin/dns/dnsutils.yaml#catdnsutils.yamlapiVersion:v1kind:Podmetadata:name:dnsutilsn......
  • kubernetes persistentVolumeClaim保留机制
    1.默认StatefulSet删除以后,对应的pvc默认是会保存的。2.控制  在1.23以后,有可选 .spec.persistentVolumeClaimRetentionPolicy 字段控制在StatefulSet的生命周期中是否保留或者删除PVC。  您必须启用StatefulSetAutoDeletePVCfeaturegate才能使用此字段。启用......
  • 深入了解Kubernetes(K8s):现代化容器编排和管理平台
    Kubernetes(简称K8s)是一种开源的容器编排和管理平台,用于自动化应用程序在容器化环境中的部署、扩展、管理和运维。Kubernetes最初由Google开发,并于2014年发布为开源项目,现在由CloudNativeComputingFoundation(CNCF)维护和管理。Kubernetes的设计目标是简化容器应用的部署、管理和......