标签:副本 name str namespace default replicat nbsp res pod
1、rc控制器信息查看
[root@k8s-master ~]# kubectl get replicationcontroller NAME DESIRED CURRENT READY AGE myweb 3 3 3 3m [root@k8s-master ~]# kubectl get rc NAME DESIRED CURRENT READY AGE myweb 3 3 3 5m
2、删除rc
[root@k8s-master ~]# kubectl delete rc myweb replicationcontroller "myweb" deleted [root@k8s-master ~]# kubectl get pod NAME READY STATUS RESTARTS AGE nginx 1/1 Running 0 1h nginx2 1/1 Running 0 24m
[root@k8s-master ~]# kubectl get pod NAME READY STATUS RESTARTS AGE myweb-cbt47 1/1 Running 0 4m myweb-fhfgs 1/1 Running 0 4m myweb-fltnm 1/1 Running 0 4m nginx 1/1 Running 0 1h nginx2 1/1 Running 0 30m [root@k8s-master ~]# kubectl edit pod nginx2 #app: myweb 修改nginx的标签名为:myweb pod "nginx2" edited [root@k8s-master ~]# kubectl get pod NAME READY STATUS RESTARTS AGE myweb-cbt47 1/1 Running 0 8m myweb-fltnm 1/1 Running 0 8m nginx 1/1 Running 0 1h nginx2 1/1 Running 0 33m
[root@k8s-master ~]# kubectl describe pod nginx2 #Labels: app=web Name: nginx2 Namespace: default Node: k8s-node2/10.0.128.2 Start Time: Sun, 20 Jan 2019 14:06:50 +0800 Labels: app=web Status: Running IP: 172.16.48.2 [root@k8s-master ~]# kubectl describe pod myweb-cbt47 #Labels: app=myweb Name: myweb-cbt47 Namespace: default Node: k8s-node2/10.0.128.2 Start Time: Sun, 20 Jan 2019 14:32:19 +0800 Labels: app=myweb Status: Running IP: 172.16.48.3 Controllers: ReplicationController/myweb
1、因为控制器设置最少保持3个副本
2、rc控制器是根据Labels 来区分组别的
2、nginx2的标签和myweb控制器的标签一样,所以就删除了存活时间最短的容器
1、修改为2
[root@k8s-master ~]# kubectl get pod NAME READY STATUS RESTARTS AGE myweb-cbt47 1/1 Running 0 9m myweb-fltnm 1/1 Running 0 9m nginx 1/1 Running 0 1h nginx2 1/1 Running 0 35m [root@k8s-master ~]# kubectl edit rc myweb replicas: 2 replicationcontroller "myweb" edited [root@k8s-master ~]# kubectl get pod NAME READY STATUS RESTARTS AGE myweb-cbt47 1/1 Running 0 11m nginx 1/1 Running 0 1h nginx2 1/1 Running 0 36m
2、修改为5
[root@k8s-master ~]# kubectl get pod NAME READY STATUS RESTARTS AGE myweb-cbt47 1/1 Running 0 11m nginx 1/1 Running 0 1h nginx2 1/1 Running 0 36m [root@k8s-master ~]# kubectl edit rc myweb replicas: 5 replicationcontroller "myweb" edited [root@k8s-master ~]# kubectl get pod NAME READY STATUS RESTARTS AGE myweb-7w38b 0/1 ContainerCreating 0 3s myweb-btflm 1/1 Running 0 3s myweb-cbt47 1/1 Running 0 12m myweb-rt3b9 0/1 ContainerCreating 0 3s nginx 1/1 Running 0 1h nginx2 1/1 Running 0 38m
kubernetes云平台管理实战: 服务发现和负载均衡(五)
标签:副本 name str namespace default replicat nbsp res pod
原文地址:https://www.cnblogs.com/luoahong/p/10299989.html