查询节点node
bash
kubectl get node
查询节点标签
bash
kubectl get node --show-labels
查询所有pod
bash
kubectl get pod -A
查询指定命名空间下的pod
bash
kubectl get pod -n project-3428
查询pod详细
bash
kubectl -n project-3428 get pod xxxxxxxxxxxx -o wide
POD打标签
bash
kubectl label pod mypod app=web
查看资源quota
bash
> kubectl get quota -n project-12786
NAME AGE REQUEST LIMIT
resourcequota-12786 9d persistentvolumeclaims: 0/50, requests.cpu: 0/1, requests.memory: 0/1Gi, requests.storage: 0/3Gi limits.cpu: 0/1, limits.memory: 0/1Gi
> kubectl get resourcequota -n project-12786
NAME AGE REQUEST LIMIT
resourcequota-12786 9d persistentvolumeclaims: 0/50, requests.cpu: 0/1, requests.memory: 0/1Gi, requests.storage: 0/3Gi limits.cpu: 0/1, limits.memory: 0/1Gi
查看存储类sc
bash
kubectl get sc
查看存储卷PV
bash
kubectl get pv
查看存储卷声明PVC
bash
kubectl -n project-3428 get pvc
查看存储快照类
bash
kubectl get vs -A
kubectl get volumesnapshotclass
查看存储快照
bash
kubectl get volumesnapshot -n 命名空间
查看存储快照yaml
bash
kubectl get volumesnapshot 具体的 -n 命名空间 -o yaml
查询指定命名空间的secret
bash
kubectl get secret -n sc用的命名空间
查看kubevirt虚拟机组,vmpool
bash
kubectl -n project-3524 get virtualmachinepool
kubectl -n project-3524 get virtualmachinepool vp-100
kubectl -n project-3524 get virtualmachinepool vp-100 -o yaml
查看vm虚拟机
bash
kubectl get vm -n project-3428
查看vmi镜像
bash
kubectl get vmi -n project-3428
强制删除pod
bash
kubectl delete pod newhuodai-0 --force --grace-period=0
kubectl delete -f busybox-two.yaml --force
kubectl delete pod -n default nginx-two-765d6fd96d-2csd2
查看csi驱动
bash
> kubectl get csidriver
NAME ATTACHREQUIRED PODINFOONMOUNT STORAGECAPACITY TOKENREQUESTS REQUIRESREPUBLISH MODES AGE
cephfs.csi.ceph.com true false false <unset> false Persistent 14d
local.csi.com false false false <unset> false Persistent 14d
rbd.csi.ceph.com true false false <unset> false Persistent 14d
kubectl get csidrivers
查询endpoint
bash
kubectl get endpoint -n project-3429
查询service
bash
kubectl get svc -n 命名空间
pod扩缩容
bash
kubectl apply -f nginx.yaml
kubectl get pod -n default -o wide
kubectl get deployment -n default
# 扩容
kubectl scale deployment/nginx-100 --replicas=100 -n default
# 缩容
kubectl scale deployment/nginx-100 --replicas=1 -n default
## 查询数量
kubectl get pod -n default | grep Running | wc -l
获取configmap
bash
kubectl get cm coredns -n kube-system -o yaml
进入pod内部
bash
kubectl exec -it calico-node-qz54v -n kube-system bash
查看deployment
bash
kubectl get deployment -n csi-driver
编辑deployment
bash
kubectl edit deployment csi-controller -n csi-driver