Kubernetes 基本操作

[TOC]

Kubernetes deployment的scale out, scale down

扩容

kubectl scale deployments/ --replicas=4
查看扩容结果:
kubectl get deployments

$ kubectl get pods -o wide
NAME                                   READY     STATUS    RESTARTS   AGE       IP           NODE
kubernetes-bootcamp-5c69669756-rgzzp   1/1       Running   0          9m        172.18.0.5   minikube
kubernetes-bootcamp-5c69669756-zw7x6   1/1       Running   0          11m       172.18.0.2   minikube

缩容

kubectl scale deployments/kubernetes-bootcamp --replicas=2
kubernetes-bootcamp缩容到两个副本;
查看缩容结果:

$ kubectl get pods -o wide
NAME                                   READY     STATUS        RESTARTS   AGE       IP           NODE
kubernetes-bootcamp-5c69669756-p6969   1/1       Terminating   0          9m        172.18.0.7   minikube
kubernetes-bootcamp-5c69669756-rgzzp   1/1       Running       0          9m        172.18.0.5   minikube
kubernetes-bootcamp-5c69669756-t6rrt   1/1       Terminating   0          9m        172.18.0.6   minikube
kubernetes-bootcamp-5c69669756-zw7x6   1/1       Running       0          11m       172.18.0.2   minikube
$ kubectl get pods -o wide
NAME                                   READY     STATUS    RESTARTS   AGE       IP           NODE
kubernetes-bootcamp-5c69669756-rgzzp   1/1       Running   0          9m        172.18.0.5   minikube
kubernetes-bootcamp-5c69669756-zw7x6   1/1       Running   0          11m       172.18.0.2   minikube

Rolling Update

通过指定新的镜像对deployment进行升级:
kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=jocatatlin/kubernetes-bootcamp:v2

kubectl set image =

rollout管理:

  • rollout状态查看:
    kubectl rollout status deployments/
  • rollout撤销:
    kuberctl rollout undo deployments/

你可能感兴趣的:(Kubernetes 基本操作)