k8s操作必备命令 掌握以下命令 就可以初步掌握了k8s
kubectl get pods --all-namespaces 获取所有命名空间 kubectl delete namespaces kubernetes-dashboard 删除命名空间 kubectl get clusterrolebinding 获取clusterrolebinding用户(角色与用户的绑定关系) kubectl delete clusterrolebinding dashboard-admin 删除binding kubectl delete clusterrole 删除角色 kubectl get nodes -o yaml 获取nodes详细信息 sudo kubectl logs kubernetes-dashboard-6dccb458d5-x7xft --namespace=kubernetes-dashboard systemctl status kubelet 查看kubelet状态 systemctl start kubelet 启动kubelet systemctl daemon-reload && systemctl restart kubelet 重启kubelet systemctl daemon-reload && systemctl stop kubelet 停止kubelet journalctl -f -u kubelet.service/journalctl -xefu kubelet 查看kubelet日志 kubectl drain nodename --force --ignore-daemonsets --delete-local-data kubectl delete node nodename //去除节点 kubectl create -f xxx.yaml #创建pods 或 services kubectl delete -f xxx.yaml #删除 pods 或 services kubectl delete pods --all --grace-period=0 --force # 删除所有的pods kubectl get services #查看应用被映射到节点的哪个端口 kubectl get pods #查看当前pod //k8s停机重启 swapoff -a systemctl start kubelet //master主机root用户需要执行(node不需要执行) export KUBECONFIG=/etc/kubernetes/admin.conf 非root用户需要执行 mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config