K8S常用命令
k8s常用命令
修改完成后reload配置文件
systemctl daemon-reload
重启Docker
systemctl restart docker
开机自启
systemctl enable docker
停止k8s
systemctl stop kubelet
重启k8s
systemctl restart kubelet
卸载K8S
sudo kubeadm reset -f
sudo rm -rvf $HOME/.kube
sudo rm -rvf ~/.kube/
sudo rm -rvf /etc/kubernetes/
sudo rm -rvf /etc/systemd/system/kubelet.service.d
sudo rm -rvf /etc/systemd/system/kubelet.service
sudo rm -rvf /usr/bin/kube*
sudo rm -rvf /etc/cni
sudo rm -rvf /opt/cni
sudo rm -rvf /var/lib/etcd
sudo rm -rvf /var/etcd
sudo apt-get remove kube*
查看节点状态
kubectl get nodes
查看POD
kubectl get pod -n kube-system
kubectl -n kube-system get secret $(kubectl -n kube-system get secret | grep kuboard-user | awk ‘{print $1}’) -o go-template=‘{{.data.token}}’ | base64 -d
查看POD日志
kubectl logs -f mynginx
POD启动出现问题
kubectl describe pod 名称
Deployment自愈启动
kubectl create deployment mytomcat --image=tomcat:8.5.68
查看本次部署
kubectl get deploy
删除本次部署
kubectl delete deploy tomcat
集群内部访问(ClusterIP)
Service-Pod的服务发现与负载均衡(暴露端口)
kubectl expose deploy mynginx --port=8000 --target-port=80 -type=ClusterIP
删除
kubectl delete service mynginx
查看Service
kubectl get service
查看标签,标签相同的统一暴露端口
kubectl get pod --show-labels
Service访问:service的IP+Port访问
curl 10.96.118.16:8000
域名访问:访问名.所在名称空间.svc
mynginx.default.svc:8000
集群外部访问(节点访问)NodePort
kubectl expose deploy mynginx --port=9000 --target-port=80 --type=NodePort
Kubernetes Dashboard登陆Token
kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk ‘{print $1}’)
eyJhbGciOiJSUzI1NiIsImtpZCI6ImxlRkpGVC1jMlVETmdidVdObzE3ODc0QVlGdDdUMWlpbnR5SThUQlh6WXcifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLThybW5wIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI4YzViMzIxNy1iYmZjLTQ0N2EtYjkyMi0xNzFlZDdjMTAzZGEiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZXJuZXRlcy1kYXNoYm9hcmQ6YWRtaW4tdXNlciJ9.OiQQP1bV96arZA9kzVsMBfK9GzL8dvW2U054sRU1gOiJPAOsHoQjJSCit2evTyPMaIMugy20QBkGpk8mB3-MHWl-lCA79y0d3ajCVZnGr-8zCi7F4U5DKDoZLsV1ZsGNQbUJdedF63aHwrSq76VD4psTqWo3V3QRL4SX5texxZmo62v5UrZ6Z6bz-mIWKlBnlYTHZXK5R8_cKjvoqfB8jUnEfcOctuzbBDAqh9HLyzCOZ1_jrAD6HBI2wlUOzjOIYd1wyWYSXb-v9OSumS-5YH8IeaymgV5c6wC9IKihITY07FKNtW8X3PXuKOSJigAjraZ_NUArX4eRtJghY5oogw
Kuberenetes登陆Token
kubectl -n kube-system get secret $(kubectl -n kube-system get secret | grep kuboard-user | awk ‘{print $1}’) -o go-template=‘{{.data.token}}’ | base64 -d
eyJhbGciOiJSUzI1NiIsImtpZCI6ImxlRkpGVC1jMlVETmdidVdObzE3ODc0QVlGdDdUMWlpbnR5SThUQlh6WXcifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJrdWJvYXJkLXVzZXItdG9rZW4tYzRwd2MiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoia3Vib2FyZC11c2VyIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiNmNkNDM0NDYtYmNiOS00NTE4LTg2ZjgtMWVlODRmYTZkZGUzIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50Omt1YmUtc3lzdGVtOmt1Ym9hcmQtdXNlciJ9.v0uqITiCUu0TPQwii_JMN5Bxtim3l9UbhCl4Vo6ok7zScbd1Er4L4ibMxRe4v5SD9zDUH0eU83Rtu_8FYow2NtDeuxwr5Xabuz2Eo2Qfe1F1yJr-ugF5lYTVt34TlFyUmR8tJTVWt3JWAc3EtLoG2-5iEgPlLdxzw-2sBhTNDkaxAFdUyXYLkLbysqjMMVrZ23f8-ZtUP0WseeG8f4Qk2AcWw5HHXRJ6MhHhFdyz7_JpSUkdinIWRY0XsUnQ7_TYGfAo2NPJSztw5LSoyJYuVawJoXn2FPyeNJtjK_ws4nZ92Lp0eBoUEgmjNPmR-umfkuFbI5qtK–20NZFWRhqcg
更多推荐
所有评论(0)