【Kubernetes】容器集群管理常用命令笔记

一、集群部署-查询集群状态###

①查询k8s master各组件健康状态:

kubectl get componentstatus

②查询k8s node健康状态:

kubectl get node

二、kubectl-管理工具###


①创建

kubectl run nginx --replicas=3 --labels="app=example" --image=nginx:1.10 --port=80

②查看

kubectl get deploy
kubectl get pods --show-labels
kubectl get pods -l app=example
kubectl get pods -o wide

③发布

kubectl expose deployment nginx --port=88 --type=NodePort --target-port=80 --name=nginx-service
kubectl describe service nginx-service

④故障排查

kubectl describe TYPE NAME_PREFIX
kubectl logs nginx-xxx
kubectl exec –it nginx-xxx bash

⑤更新

kubectl set image deployment/nginx nginx=nginx:1.11
or
kubectl edit deployment/nginx

资源发布管理:
kubectl rollout status deployment/nginx
kubectl rollout history deployment/nginx
kubectl rollout history deployment/nginx --revision=3
kubectl scale deployment nginx --replicas=10

⑥回滚

kubectl rollout undo deployment/nginx-deployment
kubectl rollout undo deployment/nginx-deployment --to-revision=3

⑦删除

kubectl delete deploy/nginx
kubectl delete svc/nginx-service

三、Pod管理–创建/查询/更新/删除###

① 创建pod资源

kubectl create -f pod.yaml

② 查看pods

kubectl get pods nginx-pod

③ 查看pod描述

kubectl describe pod nginx-pod

④ 更新资源

kubectl apply -f pod.yaml

⑤ 删除资源

kubectl delete pod nginx-pod
posted @ 2019-10-22 17:57  爱啦啦  阅读(376)  评论(0编辑  收藏  举报