2015-06-08 02:32:13 +00:00
|
|
|
|
# kubectl 使用
|
2019-11-15 03:01:25 +00:00
|
|
|
|
|
2018-12-31 01:06:28 +00:00
|
|
|
|
[kubectl](https://github.com/kubernetes/kubernetes) 是 Kubernetes 自带的客户端,可以用它来直接操作 Kubernetes。
|
2015-06-08 02:32:13 +00:00
|
|
|
|
|
|
|
|
|
使用格式有两种:
|
2016-11-10 11:48:32 +00:00
|
|
|
|
```bash
|
2015-06-08 02:32:13 +00:00
|
|
|
|
kubectl [flags]
|
|
|
|
|
kubectl [command]
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## get
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
|
|
|
|
显示一个或多个资源
|
|
|
|
|
|
2015-06-08 02:32:13 +00:00
|
|
|
|
## describe
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
|
|
|
|
显示资源详情
|
|
|
|
|
|
2015-06-08 02:32:13 +00:00
|
|
|
|
## create
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
|
|
|
|
从文件或标准输入创建资源
|
|
|
|
|
|
2015-06-08 02:32:13 +00:00
|
|
|
|
## update
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
|
|
|
|
从文件或标准输入更新资源
|
|
|
|
|
|
2015-06-08 02:32:13 +00:00
|
|
|
|
## delete
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
|
|
|
|
通过文件名、标准输入、资源名或者 label selector 删除资源
|
|
|
|
|
|
2015-06-08 02:32:13 +00:00
|
|
|
|
## log
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
2018-12-31 08:09:34 +00:00
|
|
|
|
输出 pod 中一个容器的日志
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
2015-06-08 02:32:13 +00:00
|
|
|
|
## rolling-update
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
|
|
|
|
对指定的 replication controller 执行滚动升级
|
|
|
|
|
|
2015-06-08 02:32:13 +00:00
|
|
|
|
## exec
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
|
|
|
|
在容器内部执行命令
|
|
|
|
|
|
2015-06-08 02:32:13 +00:00
|
|
|
|
## port-forward
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
|
|
|
|
将本地端口转发到Pod
|
|
|
|
|
|
2015-06-08 02:32:13 +00:00
|
|
|
|
## proxy
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
|
|
|
|
为 Kubernetes API server 启动代理服务器
|
|
|
|
|
|
|
|
|
|
## run
|
|
|
|
|
|
|
|
|
|
在集群中使用指定镜像启动容器
|
|
|
|
|
|
2015-06-08 02:32:13 +00:00
|
|
|
|
## expose
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
|
|
|
|
将 replication controller service 或 pod 暴露为新的 kubernetes service
|
|
|
|
|
|
2015-06-08 02:32:13 +00:00
|
|
|
|
## label
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
|
|
|
|
更新资源的 label
|
|
|
|
|
|
2015-06-08 02:32:13 +00:00
|
|
|
|
## config
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
|
|
|
|
修改 kubernetes 配置文件
|
|
|
|
|
|
2015-06-08 02:32:13 +00:00
|
|
|
|
## cluster-info
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
|
|
|
|
显示集群信息
|
|
|
|
|
|
2015-06-08 02:32:13 +00:00
|
|
|
|
## api-versions
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
|
|
|
|
以 "组/版本" 的格式输出服务端支持的 API 版本
|
|
|
|
|
|
2015-06-08 02:32:13 +00:00
|
|
|
|
## version
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
|
|
|
|
输出服务端和客户端的版本信息
|
|
|
|
|
|
2015-06-08 02:32:13 +00:00
|
|
|
|
## help
|
2018-12-31 01:06:28 +00:00
|
|
|
|
|
|
|
|
|
显示各个命令的帮助信息
|