Kubectl

Kubectl #

集群信息查询 #

  • kubectl cluster-info

node #

  • kubectl get nodes
  • kubectl describe node

常用操作 #

获取 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 #


参考 #