k8s常用命令
k8s版本 1.6.2一、常用命令1. node查看nodekubectl get node 或 kubectl get nodes[root@docker176 ~]# kubectl get nodeNAMESTATUSAGEVERSION192.168.14.175Ready7dv1.6.2192...
·
在这里插入代码片k8s版本 1.6.2
一、常用命令
1. node
查看node
kubectl get node 或 kubectl get nodes
[root@docker176 ~]# kubectl get node
NAME STATUS AGE VERSION
192.168.14.175 Ready 7d v1.6.2
192.168.14.176 Ready 33m v1.6.2
删除node
kubectl delete node nodeName
2. 查看namespaces
kubectl get ns 等同于
kubectl get namespaces
[root@docker176 ~]# kubectl get ns
NAME STATUS AGE
b1 Active 78d
b1-z1 Active 50d
b111 Active 50d
default Active 79d
demo Active 13d
kube-public Active 79d
kube-system Active 79d
monitoring Active 8d
不带 -n 或 --namespaces
3. 查看指定空间信息
kubectl get all 等同于 kubectl get pod,svc,deploy,rs。all 包括 所有 pod,svc,deploy,rs
kubectl get all 查看namespace=default的空间,查看指定空间 kubectl -n monitoring get all
[root@docker176 ~]# kubectl get all
NAME READY STATUS RESTARTS AGE
po/es-kibana-744328589-s6ps6 3/3 Running 6 7d
po/logstash-agent-jqpm3 1/1 Running 2 7d
po/logstash-agent-pm0dl 1/1 Running 0 42m
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc/es-kibana 10.254.0.137 <nodes> 6379:31379/TCP,5601:31601/TCP 48d
svc/fcsp-es 10.254.0.136 <nodes> 9200:31200/TCP 48d
svc/kubernetes 10.254.0.1 <none> 443/TCP 79d
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
deploy/es-kibana 1 1 1 1 48d
NAME DESIRED CURRENT READY AGE
rs/es-kibana-744328589 1 1 1 48d
4.查看describe信息
kubectl -n namespace describe pod podName
kubectl -n ${namespace} describe pod ${podName}
二、常用get命令说明
[root@docker176 ~]# kubectl get --help
Display one or many resources.
Valid resource types include:
* all
* certificatesigningrequests (aka 'csr')
* clusters (valid only for federation apiservers)
* clusterrolebindings
* clusterroles
* componentstatuses (aka 'cs')
* configmaps (aka 'cm')
* daemonsets (aka 'ds')
* deployments (aka 'deploy')
* endpoints (aka 'ep')
* events (aka 'ev')
* horizontalpodautoscalers (aka 'hpa')
* ingresses (aka 'ing')
* jobs
* limitranges (aka 'limits')
* namespaces (aka 'ns')
* networkpolicies
* nodes (aka 'no')
* persistentvolumeclaims (aka 'pvc')
* persistentvolumes (aka 'pv')
* pods (aka 'po')
* poddisruptionbudgets (aka 'pdb')
* podsecuritypolicies (aka 'psp')
* podtemplates
* replicasets (aka 'rs')
* replicationcontrollers (aka 'rc')
* resourcequotas (aka 'quota')
* rolebindings
* roles
* secrets
* serviceaccounts (aka 'sa')
* services (aka 'svc')
* statefulsets
* storageclasses
* thirdpartyresources
This command will hide resources that have completed, such as pods that are in the Succeeded or Failed phases. You can
see the full results for any resource by providing the '--show-all' flag.
By specifying the output as 'template' and providing a Go template as the value of the --template flag, you can filter
the attributes of the fetched resources.
Examples:
# List all pods in ps output format.
kubectl get pods
# List all pods in ps output format with more information (such as node name).
kubectl get pods -o wide
# List a single replication controller with specified NAME in ps output format.
kubectl get replicationcontroller web
# List a single pod in JSON output format.
kubectl get -o json pod web-pod-13je7
# List a pod identified by type and name specified in "pod.yaml" in JSON output format.
kubectl get -f pod.yaml -o json
# Return only the phase value of the specified pod.
kubectl get -o template pod/web-pod-13je7 --template={{.status.phase}}
# List all replication controllers and services together in ps output format.
kubectl get rc,services
# List one or more resources by their type and names.
kubectl get rc/web service/frontend pods/web-pod-13je7
# List all resources with different types.
kubectl get all
更多推荐
已为社区贡献8条内容
所有评论(0)