李明
|
ReplicationController
#启动k8s minikube start#删除上次的pod kubectl delete -f pod_nginx.yml
apiVersion: v1kind: ReplicationController metadata: name: nginxspec: replicas: 3 selector: app: nginx template: metadata: name: nginx labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80
image.png #创建一个ReplicationController的横向扩展 kubectl create -f rc_nginx.yml kubectl get pods kubectl get rc
kubectl get rc kubectl get pod kubectl delete pods nginx-h2qbt kubectl get pods kubectl get rc
kubectl scale rc nginx --replicas=2kubectl get rc kubectl scale rc nginx --replicas=5kubectl get pods -o wide
image.png ReplicaSet
apiVersion: apps/v1kind: ReplicaSetmetadata: name: nginx labels: tier: frontendspec: replicas: 3 selector: matchLabels: tier: frontend template: metadata: name: nginx labels: tier: frontend spec: containers: - name: nginx image: nginx ports: - containerPort: 80 #删除ReplicationController创建的pod kubectl delete -f rc_nginx.yml #创建一个ReplicationController的横向扩展 kubectl create -f rs_nginx.yml kubectl get pods -o wide kubectl get pods kubectl get rc
kubectl get rs kubectl get pod kubectl delete pods nginx-h2qbt kubectl get pods kubectl get rs
kubectl scale rs nginx --replicas=2kubectl get rs kubectl scale rs nginx --replicas=5kubectl get pods -o wide
PS:通过这次了解了pod的扩展,ReplicaSet和ReplicationController的方式,基本上可以抛弃上次的直接pod的方式创建app了。下次说说Deployment。
|
2018-10-17 00:42:15