k8s命令工具
1. master节点
-
查看node节点加入命令
> kubeadm token create --print-join-command
-
查看创建节点日志
> kubectl describe pods -l app=${pod_name} > kubectl describe pod ${pod_name} -n ${name_space}
-
重启k8s集群
master节点执行: > kubectl drain k8s-node1 --delete-local-data --force --ignore-daemonsets > kubectl delete node k8s-node1 在相应node节点执行: > kubeadm reset > rm -rf /var/lib/cni/ $HOME/.kube/config /etc/cni/net.d master节点执行: > kubectl drain k8s-node2 --delete-local-data --force --ignore-daemonsets > kubectl delete node k8s-node2 在相应node节点执行: > kubeadm reset > rm -rf /var/lib/cni/ $HOME/.kube/config /etc/cni/net.d 删除master节点: > kubectl drain k8s-master --delete-local-data --force --ignore-daemonsets > kubectl delete node k8s-master > kubeadm reset > rm -rf /var/lib/cni/ $HOME/.kube/config /etc/cni/net.d
-
实时查看 Deployment 对象的状态变化
> kubectl rollout status deployment/${deployment_name}
-
修改镜像信息信息
> kubectl set image deployment/nginx-deployment nginx=nginx:1.91
-
回滚上一版本
> kubectl rollout undo deployment/nginx-deployment
-
查看Deployment 变更对应的版本
> kubectl rollout history deployment/nginx-deployment
-
回滚到执行版本
> kubectl rollout undo deployment/nginx-deployment --to-revision=2
-
暂停滚动更新
> kubectl rollout pause deployment/nginx-deployment
因为我们每修改一次deployment,都会生成一个新的ReplicaSet对象,这样显得有些多余和浪费资源,所以,当我们需要修改deployment的时候,先暂时暂停滚动更新,等到我们一次性修改完成后,再重新恢复即可。
-
恢复滚动更新
> kubectl rollout resume deployment/nginx-deployment