kubectl 可操作资源对象类型
资源对象的名称 | 缩写 |
|---|---|
componentstatuses | cs |
daemonsets | ds |
deployments | |
events | ev |
endpoints | ep |
horizontalpodautoscalers | hpa |
ingresses | ing |
jobs | |
limitranges | limits |
nodes | no |
namespaces | ns |
pods | po |
persistentvolume | pv |
persistentvolumeclaims | pvc |
resourcequotas | quota |
replicationcontrollers | rc |
secrets | |
serviceaccounts | |
services | svc |
根据<directory>目录下所有.yaml、.yml、。json 文件定义进行创建操作
kubectl create -f <directory>查看所有的Pod
kubectl get pods
kubectl get pod <pod-name> -o wide查看rc 和 service 列表
kubectl get rc,service显示Node的详细信息:
kubectl describe nodes <node-name>显示Pod的详细信息
kubectl describe pods <pod-name>显示RC 管理的Pod的信息
kubectl describe rc <rc-name>基于pod.yaml 定义的名称删除Pod:
kubectl delete -f pod.yaml删除所有包含某个label的Pod和service
kubectl delete pods,services -l name=<label-name>删除所有Pod
kubectl delete pods --allkubectl delete rc --all
kubectl delete pods --all
kubectl delete deployment --all
kubectl delete service --all执行Pod的date 命令,默认使用Pod中的第一个容器执行
kubectl exec <pod-name> date指定Pod中某个容器执行date命令
kubectl exec <pod-name> -c <container-name> date通过bash获取Pod中某个容器的TTY, 相当于登录容器
kubectl exec -ti <pod-name> -c <container-name> /bin/bash查看容器输出到stdout 的日志
kubectl logs <pod-name>跟踪查看容器的日志,相当于 tail -f 命令的结果
kubectl logs -f <pod-name> -c <container-name>