翻译自Linux Foundation开源软件学园的课程——kubernetes入门(LFS158)

Linux Foundation开源软件学园-Linux_云技术_Kubernetes专业考试认证_K8s_CKA_CKS

【翻译】

虽然已经不再是推荐的controller,Replication Controller是一个复杂的操作器(operator),用来保证在任何时间点运行了指定数量的Pod副本,以及应用容器的期望版本,通过持续地比对被管应用的期望状态与实际状态。如果实际运行的pod数量多与期望的pod数量,replication controller会随机地终止超过期望状态数量的Pod。(例如期望有3个副本,实际运行了5个副本,那么Replication Controller会随机kill掉两个pod)。如果实际运行的pod数量少于期望状态,那么Replication Controller将会请求创建额外的pod,来使实际运行的pod数量与期望的Pod数量一致。

我们通常不会单独来部署一个Pod,它如果因为某些错误被终止时,Pod不能够重启,这因为它缺乏了kubernetes通过其他方式承诺的“自愈”的特性。推荐的方式是使用其他类型的operator来运行和管理Pod。

然而,默认推荐的controller是Deployment,它配置了ReplicaSet控制器来管理应用Pod的生命周期。

拓展阅读:

Replication Controller

ReplicationController | Kubernetes

Deployment

Deployments | Kubernetes

ReplicaSet

ReplicaSet | Kubernetes

通过阅读k8s官方文档的Replication Controller:

   如果pod被删除、被终止或者运行出错,还需要运维人员进行手动维护的话,是非常糟糕的现象。但是Pod自己也没有自动化拉起的手段(没有自愈功能),因此必须要靠外部手段来对它进行启停。有点像操作系统上的守护进程(process supervisor),不过和守护进程不一样的是,Replication Controller可以跨多个节点守护多个Pod。

   通过查阅kimi了解到,replicationcontroller的功能相对比较简单,不支持滚动更新,更新应用的时候只能停止旧pod再起新pod等一些不足,因此逐渐被deployment和replicaset所替换掉了。

通过泛读ReplicaSet的官方文档了解到,ReplicaSet可以和Deployment结合在一起使用,从而支持滚动更新等特性,因此它比Replication Controller更优秀。通常更建议的是,让更高阶的Deployment来管理RepliacaSet,而不是用户直接去控制ReplicaSet。

【原文】

Although no longer a recommended controller, a ReplicationController is a complex operator that ensures a specified number of replicas of a Pod are running at any given time the desired version of the application container, by constantly comparing the actual state with the desired state of the managed application. If there are more Pods than the desired count, the replication controller randomly terminates the number of Pods exceeding the desired count, and, if there are fewer Pods than the desired count, then the replication controller requests additional Pods to be created until the actual count matches the desired count. Generally, we do not deploy a Pod independently, as it would not be able to restart itself if terminated in error because a Pod misses the much desired self-healing feature that Kubernetes otherwise promises. The recommended method is to use some type of an operator to run and manage Pods.

In addition to replication, the ReplicationController operator also supports application updates.

However, the default recommended controller is the Deployment which configures a ReplicaSet controller to manage application Pods' lifecycle.

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐