常用命令
#查看端口映射
kubectl get svc -n kube-system
#查看 secret
kubectl get secret -n kube-system
#查看 token
kubectl describe secret kubernetes-dashboard --namespace=kube-system
#k8s 無(wú)法啟動(dòng)疙驾,查看日志悍募,查找Failed
journalctl -xefu kubelet
#查看pod錯(cuò)誤日志
kubectl logs kubernetes-dashboard-8556c848b7-4kpzd --namespace=kube-system
#對(duì)資源進(jìn)行配置
kubectl apply -f kubernetes-dashboard.yaml
kubectl delete -f kubernetes-dashboard.yaml
YAML配置文件管理對(duì)象
對(duì)象管理:
# 創(chuàng)建deployment資源
kubectl create -f nginx-deployment.yaml
# 查看deployment
kubectl get deploy
# 查看ReplicaSet
kubectl get rs
# 查看pods所有標(biāo)簽
kubectl get pods --show-labels
# 根據(jù)標(biāo)簽查看pods
kubectl get pods -l app=nginx
# 滾動(dòng)更新鏡像
kubectl set image deployment/nginx-deployment nginx=nginx:1.11
或者
kubectl edit deployment/nginx-deployment
或者
kubectl apply -f nginx-deployment.yaml
# 實(shí)時(shí)觀察發(fā)布狀態(tài):
kubectl rollout status deployment/nginx-deployment
# 查看deployment歷史修訂版本
kubectl rollout history deployment/nginx-deployment
kubectl rollout history deployment/nginx-deployment --revision=3
# 回滾到以前版本
kubectl rollout undo deployment/nginx-deployment
kubectl rollout undo deployment/nginx-deployment --to-revision=3
# 擴(kuò)容deployment的Pod副本數(shù)量
kubectl scale deployment nginx-deployment --replicas=10
# 設(shè)置啟動(dòng)擴(kuò)容/縮容
kubectl autoscale deployment nginx-deployment --min=10 --max=15 --cpu-percent=80