kubeadm version
kubelet --version
kubectl version
kubeadm config images list  #查看所需的镜像及版本

查看集群状态
kubectl get cs
kubectl get csr  #查看是否有新的客户端请求颁发证书

kubectl get nodes
kubectl get node  #查看node

查看pods
kubectl get pods 
kubectl get pods -o wide
kubectl get pod -A #获取所有pod

创建服务

kubectl create deployment web --image=nginx  #创建一个 Nginx 服务
kubectl expose deployment web --port=80 --type=NodePort #暴露端口并访问 Nginx

kubectl create -f pod.ymal
kubectl apply -f label.ymal #使用配置文件打标签

删除node

kubectl cordon node2 设为不可用
kubectl drain node02 改为维护模式,驱逐节点上的pod 
kubectl drain node02  --delete-local-data --force --ignore-daemonsets 删除删除
kubectl delete pods -n kube-system nginx-6qz6s 强制删除节点上的pod

kubectl delete node node2 #删除节点

删除pod

  • 单纯的删除pod,删除后pod控制器会重启pod
# 删除deployment,删除后,与此deployment关联的pod也会一起删除
kubectl delete deployment xxx

查看Pod:kubectl get pod -o wide
# 删除pod
kubectl delete pod xxx
kubectl delete pod 对应的NAME --force --grace-period=0 强制删除

Deployment

查看deployment:kubectl get deploy
删除deployment:kubectl delete deploy/对应的NAME
yaml创建deployment:kubectl apply -f xxx.yaml

Service

查看service:kubectl get svc -o wide
删除service:kubectl delete service/对应的NAME
yaml创建service:kubectl apply -f xxx.yaml