Kubectl

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

Github stars #

This a Bash Script that will help you forget the kubectl’s default, difficult to remember, sorting feature by making it simpler.


命令 #

autoscale #


参考 #


本文访问量

本站总访问量

本站总访客数 人次