A graphical way to understand the Kubernetes

1. container

Before we try to understand Kubernetes, let us take a moment to clarify what the container is, and why they are so popular. After all, talk about the container Choreographer (Kubernetes) in the case of do not know what is in the container does not make sense :)

 

                                                                                              container

"Container" is a container used to store all the items you put in.

Like application code, dependencies and its dependencies until the kernel. The key concept here is isolation. All content and isolate the rest, so you better control them. Isolation container provides three types:

  • Workspace isolation (processes, network)

  • Resource isolation (CPU, memory)

  • File system isolation (jointly file system)

Consider the same as the VM container. They streamlined, fast (start) and the small size. Moreover, all these are not built up. Instead, they use the structure (eg cgroups, namespaces) Linux system exists on which to build a nice abstract.

Now we know what a container, it is easy to understand why they are popular. Not only can distribute application binaries / code can be a practical way to deliver the entire environment needed to run the application, because the container can be built to a very small unit. Resolved "to work on my machine" problems the perfect solution.

2. When using Kubernetes?

All containers are good, software developers are now living much better. So why do we need another technology, such as Kubernetes container arrangement tool?

 

When entering a state, you need to use it to manage numerous containers.

Q: My front end of the container where I want to run a few?

A: Hard to say, the use of container layout tool.

 

Q: How do the front-end and back-end container vessel dialogue newly created?

Answer: IP hard-coded, or use the container layout tool.

 

Q: How rolling upgrades?

A: Hold at each step manually or using a tool container arrangement.

3. Why do I prefer Kubernetes

 

有很多容器编排工具,例如Docker Swarm,Mesos和Kubernetes。我的选择是Kubernetes(因此有了本文),因为Kubernetes是……

就像乐高积木一样,它不仅具有大规模运行容器编排所需的组件,而且还具有使用自定义组件交换内部和外部交换不同组件的灵活性。想要拥有一个自定义的调度程序,也很方便。需要具有新的资源类型,编写一个CRD。此外,社区非常活跃,并且工具迅速发展。

4.Kubernetes架构

 

每个Kubernetes集群都有两种类型的节点,主节点和工作节点。顾名思义,主节点是在工作程序运行有效负载(应用程序)的地方控制和监视群集。

集群可以与单个主节点一起工作,但是最好拥有三个以实现高可用性(称为HA群集)。

让我们仔细看一下主节点及其组成。

etcd:数据库,用于存储有关kubernetes对象,其当前状态,访问信息和其他集群配置信息的所有数据。

API Server:RESTful API服务器,公开端点以操作整个集群。主节点和工作节点中的几乎所有组件都与该服务器通信以执行其职责。

调度程序:负责决定哪个有效负载需要在哪台机器上运行。

控制管理器:这是一个控制循环,它监视集群的状态(通过调用API服务器来获取此数据)并采取措施将其置于预期状态。

 

 

kubelet:是工作节点的心脏。它与主节点API服务器通信并运行为其节点安排的容器。

kube-proxy:使用IP表/IPVS处理Pod的网络需求。

Pod:运行所有容器的Kubernetes的功劳。如果没有Pod的抽象,就无法在kubernetes中运行容器。Pod添加了对容器之间的kuberenetes联网方式至关重要的功能。

                                                                                       快乐的Pod

一个Pod可以有多个容器,并且在这些容器中运行的所有服务器都可以将彼此视为本地主机。这使得将应用程序的不同方面分离为单独的容器,并将它们全部作为一个容器加载在一起非常方便。有多种不同的Pod模式,例如sidecar,proxy和大使,可以满足不同的需求。

Pod网络接口提供了一种将其与同一节点和其他工作节点中的其他Pod通信的机制。

 

 

而且,每个Pod都将分配有自己的IP地址,kube-proxy将使用该IP地址来路由流量,而且此IP地址仅在群集中可见。

所有容器也都可以看到安装在容器内的卷,有时可以使用这些卷在容器之间进行异步通信。例如,假设你的应用是照片上传应用(例如instagram),它可以将这些文件保存在一个卷中,而同一Pod中的另一个容器可以监视该卷中的新文件,并开始对其进行处理以创建多种尺寸,将它们上传到云存储。

5.控制器

在Kubernetes中,有很多控制器,例如ReplicaSet,Replication Controllers,Deployments,StatefulSets和Service。这些是以一种或另一种方式控制Pod的对象。让我们看一些重要的。

 

5.1 ReplicaSet

 

 

ReplicaSet做自己擅长的事情,复制Pod

该控制器的主要职责是创建给定Pod的副本,如果Pod因某种原因死亡,则会通知该控制器,并立即跳入操作以创建新的Pod。

5.2 Deployment

 

试图控制ReplicaSet的部署(头发凌乱)

部署是一个高阶对象,它使用ReplicaSet来管理副本。它通过放大新的ReplicaSet和缩小(最终删除)现有的ReplicaSet来提供滚动升级。

5.3 Service

 

表示为无人机的服务,将数据包传递到相应的Pod

服务是一个控制器对象,其主要职责是在将“数据包”分发到相应节点时充当负载平衡器。基本上,它是一种控制器构造,用于在工作节点之间对相似的Pod(通常由Pod标签标识)进行分组。

假设你的“前端”应用程序想与“后端”应用程序通信,则每个应用程序可能有许多正在运行的实例。你不必担心对每个后端Pod的IP进行硬编码,而是将数据包发送到后端服务(service),然后由后端服务决定如何进行负载平衡并相应地转发。

PS:请注意,服务更像是一个虚拟实体,因为所有数据包路由均由IP表/IPVS/CNI插件处理。它只是使它更容易被视为一个真正的实体,让它们脱颖而出以了解其在Kubernetes生态系统中的作用。

5.4 Ingress

 

进入一个浮动平台,所有数据包都通过该平台流入集群

入口控制器是与外界联系的单点,可以与集群中运行的所有服务进行对话。这使我们可以轻松地在单个位置设置安全策略,监视甚至记录日志。

PS:Kubernetes中还有很多其他控制器对象,例如DaemonSets,StatefulSets和Jobs。还有一些诸如Secrets,ConfigMaps之类的对象,用于存储应用程序的机密和配置。我将在下一篇博客文章介绍它们。

 

相关链接:

  1. https://matthewpalmer.net/kubernetes-app-developer/articles/multi-container-pod-design-patterns.html

原文链接:https://medium.com/tarkalabs/know-kubernetes-pictorially-f6e6a0052dd0

发布了171 篇原创文章 · 获赞 40 · 访问量 12万+

Guess you like

Origin blog.csdn.net/qq_36441027/article/details/104213560