长亭百川云 - 文章详情

Kubernetes少儿指导画册

思想花火

55

2024-07-13

最近发现云原生计算基金会(cloud native computing foundation)挺有趣的,竟然做了一个Kubernetes少儿读本。

不过,作者说了,这读本不是给孩子看的,是给那些想要给孩子解释软件工程的家长们看的

Dedicated to all the parents who try to explain software engineering to their children.

内容简单生动,能让人很好的理解什么是Kubernetes,我简单翻译了一下,和大家分享。




Once upon a time there was an app named Phippy. And she was a simple app. She was written in PHP and had just one page. She lived on a hosting provider and she shared her environment with scary other apps that she didn’t know and didn’t care to associate with. She wished she had her own environment: just her and a webserver she could call home.

从前有个名为Phippy的应用程序。她是一个简单的应用程序。她是用PHP编写的,只有一页。她住在一个托管服务提供商那里,并与其他她不知道并且不愿意与之关联的可怕应用共享环境。她希望自己有一个自己的环境:只有她和一个网页服务器,她可以打电话回家。

An app has an environment that it relies upon to run. For a PHP app, that environment might include a webserver, a readable file system, and the PHP engine itself.

应用程序具有运行所依赖的环境。对于PHP应用程序,该环境可能包括Web服务器,可读文件系统以及PHP引擎本身。

One day, a kindly whale came along. He suggested that little Phippy might be happier living in a container. And so the app moved. And the container was nice, but… It was a little bit like having a fancy living room floating in the middle of the ocean.

有一天,一只鲸鱼来了。他建议,小Phippy可能会更快乐地生活在一个容器中。这样应用程序就搬家了。那个容器很好,但是……有点像是一间豪华的起居室漂浮在大海中间。

A container provides an isolated environment in which an app, together with its environment, can run. But those isolated containers often need to be managed and connected to the external world. Shared file systems, networking, scheduling, load balancing, and distribution are all challenges.

容器提供了一个隔离的环境,在其中可以运行应用程序及其环境。但是那些孤立的容器通常需要被管理并连接到外部世界。共享文件系统,网络,调度,负载平衡和分发都是挑战。

The whale shrugged his shoulders. “Sorry, kid,” he said, and disappeared beneath the ocean’s surface. But before Phippy could even begin to despair, a captain appeared on the horizon, piloting a gigantic ship. The ship was made of dozens of rafts all lashed together, but from the outside, it looked like one giant ship.

“Hello there, friend PHP app. My name is Captain Kube” said the wise old captain.

鲸鱼耸了耸肩膀。“抱歉,孩子,”他说,消失在海面之下。但是在Phippy甚至可能开始绝望之前,一名船长出现在地平线上,驾驶着一艘巨大的船。这艘船是由数十根绑在一起的木筏制成的,但从外面看,它就像一艘巨型船。

“你好,PHP应用朋友。我的名字叫Kube船长。“聪明的老船长说到。

“Kubernetes” is the Greek word for a ship’s captain. We get the words Cybernetic and Gubernatorial from it. The Kubernetes project focuses on building a robust platform for running thousands of containers in production.

“ Kubernetes”是希腊语中的船长。我们从中得到了控制论和州长一词。Kubernetes项目专注于构建一个强大的平台,以在生产中运行数千个容器。

“I’m Phippy,” said the little app.

“Nice to make your acquaintance,” said the Captain as he slapped a name tag on her.

“我是Phippy,”小应用程序说。

“很高兴认识你,”船长在他身上贴上一个名字标签时说道。

Kubernetes uses labels as “nametags” to identify things. And it can query based on these labels. Labels are open-ended: You can use them to indicate roles, stability, or other important attributes.

Kubernetes使用标签作为“名称标签”来识别事物。它可以基于这些标签进行查询。标签是开放式的:您可以使用它们来指示角色,稳定性或其他重要属性。

Captain Kube suggested that the app might like to move her container to a pod on board the ship. Phippy happily moved her container inside of the pod aboard Kube’s giant ship. It felt like home.

Kube船长建议,该应用程序可能希望将其容器移动到船上的吊舱中。Phippy高兴地将自己的容器移到了Kube的巨型船上的吊舱中。感觉就像家。

In Kubernetes, a Pod represents a runnable unit of work. Usually, you will run a single container inside of a Pod. But for cases where a few containers are tightly coupled, you may opt to run more than one container inside of the same Pod. Kubernetes takes on the work of connecting your pod to the network and the rest of the Kubernetes environment.

在Kubernetes中,Pod表示可运行的工作单元。通常,在Pod内运行一个容器。但是,对于几个容器紧密耦合的情况,你可以选择在同一Pod内运行多个容器。Kubernetes负责将你的Pod连接到网络以及Kubernetes其他环境的工作。

Phippy had some unusual interests. She was really into genetics and sheep. And so she asked the captain, “What if I want to clone myself… On demand… Any number of times?”

“That’s easy,” said the captain. And he introduced her to the replication controllers.

Phippy有一些不同寻常的兴趣。她真的很喜欢遗传学和羊。于是她问船长:“如果我想克隆自己……按需……任意次?”

“那很容易,”船长说。然后,他向她介绍了复制控制器。

Replication controllers provide a method for managing an arbitrary number of pods. A replication controller contains a pod template, which can be replicated any number of times. Through the replication controller, Kubernetes will manage your pods’ lifecycle, including scaling up and down, rolling deployments, and monitoring.

复制控制器提供了一种用于管理任意数量的Pod的方法。复制控制器包含一个Pod模板,该模板可以被复制任意次。通过复制控制器,Kubernetes将管理您的Pod的生命周期,包括扩大和缩小,滚动部署和监视。

For many days and nights the little app was happy with her pod and happy with her replicas. But only having yourself for company is not all it’s cracked up to be…. even if it is N copies of yourself.

Captain Kube smiled benevolently, “I have just the thing.”

No sooner had he spoken than a tunnel opened between Phippy’s replication controller and the rest of the ship. With a hearty laugh, Captain Kube said, “Even when your clones come and go, this tunnel will stay here so you can discover other pods, and they can discover you!”

在许多日夜里,这个小应用很满意她的pod和复制品。但是,只有一个连队的自己并不是一个很厉害的事儿……就算是有N个自己也不是。

Kube船长仁慈地笑了笑,“我有东西。”

他刚开口说话就在Phippy的复制控制器和船的其余部分之间打开了一条隧道。库伯船长笑着说:“即使你的克隆来来去去,这条隧道也会留在这里,这样您就可以发现其他pods,他们也可以找到你!”

A service tells the rest of the Kubernetes environment (including other pods and replication controllers) what services your application provides. While pods come and go, the service IP addresses and ports remain the same. And other applications can find your service through Kurbenetes service discovery.

服务会告诉Kubernetes环境的其余部分(包括其他Pod和复制控制器)你的应用程序提供什么服务。当Pod来来往往时,服务IP地址和端口保持不变。其他应用程序可以通过Kurbenetes服务发现来找到你的服务。

Thanks to the services, Phippy began to explore the rest of the ship. It wasn’t long before Phippy met Goldie. And they became the best of friends. One day, Goldie did something extraordinary. She gave Phippy a present. Phippy took one look and the saddest of sad tears escaped her eye.

“Why are you so sad?” asked Goldie.

“I love the present, but I have nowhere to put it!” sniffled Phippy.

But Goldie knew what to do. “Why not put it in a volume?”

多亏了这些服务,Phippy才开始探索轮船的其余部分。很快,Phippy遇到了Goldie。他们成了最好的朋友。有一天,Goldie做了一件非凡的事情。她给了Phippy一份礼物。Phippy看了一眼,她泪崩了。

“你为什么这么伤心?”Goldie问。

“我喜欢这个礼物,但我没地儿搁!”Phippy抽泣着。

但是Goldie知道该怎么办。“为什么不把它放在一个卷里?”

A volume represents a location where containers can access and store information. For the application, the volume appears as part of the local filesystem. But volumes may be backed by local storage, Ceph, Gluster, Elastic Block Storage, and a number of other storage backends.

Phippy loved life aboard Captain Kube’s ship and she enjoyed the company of her new friends (every replicated pod of Goldie was equally delightful). But as she thought back to her days on the scary hosted provider, she began to wonder if perhaps she could also have a little privacy.

“It sounds like what you need,” said Captain Kube, “is a namespace.”

卷代表容器可以访问和存储信息的位置。对于应用程序,该卷显示为本地文件系统的一部分。但是卷可能由本地存储,Ceph,Gluster,Elastic Block Storage和许多其他存储后端支持。

Phippy热爱Kube船长船上的生活,她喜欢新朋友的陪伴(Goldie的每一个复制pod同样令人愉快)。但是当她回想起在可怕的托管服务提供商的日子时,她开始琢磨着也许她也可以拥有一点隐私。

“听起来像你所需要的,”Kube船长说,“是一个命名空间。”

A namespace functions as a grouping mechanism inside of Kubernetes. Services, pods, replication controllers, and volumes can easily cooperate within a namespace, but the namespace provides a degree of isolation from the other parts of the cluster.

命名空间用作Kubernetes内部的分组机制。服务,pod,复制控制器和卷可以在名称空间内轻松协作,但是名称空间提供了与群集其他部分一定的隔离度。

Life was good aboard Captain Kube’s boat. Together with her new friends, Phippy sailed the seas. She had many grand adventures, but most importantly, Phippy had found her home.

And so Phippy lived happily ever after.

库伯船长的船上的生活很美好。Phippy和她的新朋友一起出海航行。她经历了许多大冒险,但最重要的是,Phippy找到了她的家。

因此,Phippy从此过着幸福快乐的生活。

THE END

结束~

See more about Phippy and friends at Phippy.io.

浏览更多关于Phippy和朋友们的故事可以访问:Phippy.io

_REF:_https://www.cncf.io/the-childrens-illustrated-guide-to-kubernetes/


**作者:**阿飞,十余年来一直混迹于信息安全行业,扛过设备,卖过服务,做过审计,查过黑客,反过欺诈,岁月神偷带走了我的苹果肌,留下了一肚子的瘫软,貌似我将要成为一个油腻的中年男人,不过依然对世界充满好奇。

相关推荐
关注或联系我们
添加百川云公众号,移动管理云安全产品
咨询热线:
4000-327-707
百川公众号
百川公众号
百川云客服
百川云客服

Copyright ©2024 北京长亭科技有限公司
icon
京ICP备 2024055124号-2