为了账号安全,请及时绑定邮箱和手机立即绑定

Kubernetes 学习笔记(一):基础定义

标签:
Kubernetes

因近日公司拟开发一个 Microservice Framework,我得以机会涉猎了一些关于 Kubernetes 的内容,遂写此文。

Kubernetes 基础

Kubernetes 基础定义以及简介均来自于这里


什么是 Kubernetes?

Kubernetes is a portable, extensible open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available.

Kubernetes 是 Google 开源的容器集群管理系统,其提供应用部署、维护、扩展机制等功能,利用 Kubernetes 能方便地管理跨机器运行容器化的应用。Kubernetes 可以在物理机或虚拟机上运行。

从引用中可以看出几个要点:

1)Portable(便携性),Extensible(拓展性);

2)Manage containerized(容器化) workloads and services;

3)Facilitate both declarative configuration(配置) and automation(自动化)。


Kubernetes 的几个核心概念:

1)Node(节点)/ Cluster(集群)

A node is a worker machine in Kubernetes, previously known as a minion. A node may be a VM or physical machine, depending on the cluster. Each node has the services necessary to run pods and is managed by the master components. The services on a node include Docker, kubelet and kube-proxy.

集群是一组(一个/多个)节点。我在实践中尝试 Minikube 就是一个 Single-node Kubernetes cluster (单节点的 Kubernetes 集群),其本身是一个虚拟机。

更多关于 Minikube 的内容请移至 Kubernetes 学习笔记(二):初步探索 Minikube。

webp

Minikube 在 Oracle VM VirtualBox 中

Kubelet:节点的代理。

Kube-proxy:Service 使用其连结 Pod。

Docker:Kubernetes 使用的容器技术来创建容器。

*请忽略那个 default 的虚拟机,那个是 Docker Toolbox


2)Pod

A Pod is the basic building block of Kubernetes–the smallest and simplest unit in the Kubernetes object model that you create or deploy. A Pod represents a running process on your cluster.

2.1)Pod 是 Kubernetes 世界里面最小/简单的单元,他是一个/多个容器的集合。

2.2)同一 Pod 中的所有容器都会被 Deploy 到同一个 Node 上,他们共享 Networking,Storage,Process 等等。

2.3)由于容器之间共享 Networking,所以它们使用同一个 IP 地址,可以通过 localhost 互相通信。不同 Pod 之间可以通过 IP 地址进行访问。

2.4)Pods are mortal - 他们会被创建也会被摧毁,但是不会被重新再使用。在 Controllers 中的 ReplicationControllers(复制控制器)会动态的创建/摧毁 Pods。因此每一个 Pod 的 IP 也不能作为一个 stable 的通信方式。于是乎便有了下文中的 Service。


3)Service (服务)

A Kubernetes Service is an abstraction which defines a logical set of Pods and a policy by which to access them - sometimes called a micro-service.

Service 的存在分离了 Frontends 和 Backends。无论 Service 连结的 Pods 产生了什么样的变化,Frontends 都不需要去在意。


4)Namespace (命名空间)

Kubernetes supports multiple virtual clusters backed by the same physical cluster. These virtual clusters are called namespaces.

Kubernetes 里面所有的资源都有一个 Namespace,拥有相同 Namespace 的资源不得重复名称,但是所属不同 Namespace 的资源可以重复。


5)Volume

Volume 作为一个外部挂载资源储备的存在,在 Docker 中也有定义并且广泛使用。

使用 Volume 有两个好处:

5.1)当一个容器故障或者被摧毁时,虽然 Kubernetes 会重新生成,但是内部的内容却会消失。Volume 作为一个外部的资源储备就可以解决这个问题。

5.2)因为一个 Pod 有可能有多个 Containers,挂载的 Volume 也可以实现不同 Containers 之间的资源共享。

一个我所使用到的例子是:我在 Kubernetes 里建立了一个 Jenkins server,用来处理自动化的 Build/Deployment。当需要实现 Deployment 的时候,我们需要 config 目标的 Kubernetes server(我使用的是本地的 Kubernetes server,即 Minikube)。因此一个非常简单的方法就是将本地的 Kubernetes config 文件作为 Volume 挂载至 Jenkins server,而不需要再去 Jenkins 内部 config。

具体的使用方式我会在之后的文章中写到,有兴趣的话可以移至这里


前文中提到/没提到的一些 Terms 例如 Container(容器),Image(镜像)等都可以在 Docker 的学习笔记中找到,有兴趣的话可以移至 TBD。



作者:咕噜拔拔爱苹果
链接:https://www.jianshu.com/p/3610a1882269


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消