Kubectl #
集群信息查询 #
kubectl cluster-info
node #
kubectl get nodes
kubectl describe node
常用操作 #
设置 #
设置 role #
# 添加
kubectl label node ime-rd5-edge0-node2-kunlun kubernetes.io/role=master
kubectl label node ime-rd5-edge0-node2-kunlun kubernetes.io/role=worker
# 删除
kubectl label node ime-rd5-edge0-node2-kunlun kubernetes.io/role=worker
# 重置 role
kubectl label --overwrite nodes <your_node> kubernetes.io/role=<your_new_label>
获取 service ip, port #
kubectl get service/servicename -o jsonpath='{.spec.clusterIP}:{.spec.ports[*].port}'
kubectl get 结果排序 #
--sort-by=
##### pod
# name
kubectl --sort-by=.metadata.name get pod
# status
kubectl --sort-by=.status.phase get pod
# restarts
kubectl --sort-by='.status.containerStatuses[0].restartCount' get pod
# age
kubectl --sort-by=.status.startTime get pod
# ip
kubectl --sort-by=.status.podIP get pod
# node
kubectl --sort-by=.spec.nodeName get pod
##### deployment
# name
kubectl --sort-by=.metadata.name get deployment
# age
kubectl --sort-by=.metadata.creationTimestamp get deployment
# uptodate
kubectl --sort-by=.status.updatedReplicas get deployment
# available
kubectl --sort-by=.metadata.availableReplicas get deployment
# containers
kubectl --sort-by=.spec.template.spec.containers[*].name get deployment
# images
kubectl --sort-by=.spec.template.spec.containers[*].image get deployment
##### service
# name
kubectl --sort-by=.metadata.name get service
# age
kubectl --sort-by=.metadata.creationTimestamp get service
# type
kubectl --sort-by=.spec.type get service
# clusterip
kubectl --sort-by=.spec.clusterIP get service
# port
kubectl --sort-by=.spec.ports[*].port get service
参考:
AATHITH/kubesort #
This a Bash Script that will help you forget the kubectl’s default, difficult to remember, sorting feature by making it simpler.
叶王 © 2013-2024 版权所有。如果本文档对你有所帮助,可以请作者喝饮料。