废话不多说,直接上demo,通过上一篇一本也了解 yaml键值对的含义,这里就不一一介绍了。
deploy.yaml
通过kubectl create命令创建,创建deploy的时候,它创建了一个 ReplicaSet 来启动3个 nginx pod。
然后立即执行kubectl get 将获得如下结果:
我们可以看到Deployment已经创建了3个 replica,所有的 replica 都已经是最新的了(包含最新的pod template),可用的(根据Deployment中的.spec.minReadySeconds声明,处于已就绪状态的pod的最少个数)。执行kubectl get rs和kubectl get pods会显示Replica Set(RS)和Pod已创建。
您可能会注意到 ReplicaSet 的名字总是<Deployment名字>-<pod template的hash值>。
注意: 您必须在 Deployment 中的 selector 指定正确的 pod template label(在该示例中是 app = nginx),不要跟其他的 controller 的 selector 中指定的 pod template label 搞混了(包括 Deployment、Replica Set、Replication Controller 等)。Kubernetes 本身并不会阻止您任意指定 pod template label ,但是如果您真的这么做了,这些 controller 之间会相互打架,并可能导致不正确的行为。
kubernetes ds6000cOm 之RC 18669144449 RSDeploy
原文地址:http://blog.51cto.com/14114139/2324887