Kubectl 命令
kubectl get : Display one or many resources.
example :
kubectl get pods
获取~/.kube/config中配置的以 user 登录的 namaspace 下的所有 pod 。
kubectl get pods -o wide
List all pods in ps output format with more information (such as node name).
kubectl get services` or `kubectl get svc
List all services.
kubectl get -o json pod wkx-pod-2080863796-awf64
以json格式显示 wkx-pod-2080863796-awf64 的信息。
kubectl create : Create a resource by filename or stdin.
example :
kubectl create -f a.yaml
根据 a.yaml 文件创建 resource 。
kubectl edit : Edit a resource on the server.
example :
kubectl edit pod wkx-pod-2080863796-awf64
对 wkx-pod-2080863796-awf64 进行修改。kubernets 将以滚动升级的方式更新修改。
kubectl delete : Delete resources by filenames, stdin, resources and names, or by resources and label selector.
example :
kubectl delete -f a.yaml
将之前根据a.yaml文件创建的 resource 删除。
kubectl delete pod wkx-pod-2080863796-awf64
删除名为 wkx-pod-2080863796-awf64 的 pod 。
kubectl describe : Show details of a specific resource or group of resources.
example :
kubectl describe pods
显示所有的 pod 的信息。
kubectl describe pods -l app=test
显示 label app=test 的 pod 的信息。
kubectl run : Run a particular image on the cluster.
example :
kubectl run gobuilder --image=docker/kaixing.wu/golang:1.7.4
运行一个 docker/kaixing.wu/golang:1.7.4 的实例。
kubectl exec : Execute a command in a container.
example :
kubectl exec -it gobuilder-998763582-15gvi bash
以 bash 的形式进入 gobuilder-998763582-15gvi 这个 pod 。
本文详细介绍了Kubectl命令的使用方法,包括获取资源信息、创建、编辑、删除资源及执行特定命令等操作。通过实例展示了如何管理和操作Kubernetes集群中的各种资源。
1791

被折叠的 条评论
为什么被折叠?



