kubectl用于运行Kubernetes集群命令的管理工具。本文概述涵盖了kubectl语法,对命令操作的描述,并列举了常用命令。

Kubectl命令详细列表请查看:Kubernetes kubectl 命令表

语法

$ kubectl [command] [TYPE] [NAME] [flags]
  • command:子命令,指定要在一个或多个资源执行的操作。
  • TYPE:资源类型,指定资源类型Resource types。
  • NAME:资源名称,指定Resource的Name。
  • flags:命令参数

常用Kubectl命令

kubectl get – 输出一个/多个资源。
kubectl describe – 输出指定的一个/多个资源的详细信息。
kubectl logs – 输出pod中一个容器的日志。
kubectl create – 通过文件名或控制台输入,创建资源。
kubectl delete – 通过文件名、控制台输入、资源名或者label selector删除资源。
kubectl exec – 在容器内部执行命令。
kubectl run – 在集群中使用指定镜像启动容器。
kubectl annotate – 更新资源的注解。
kubectl api-versions – 以“组/版本”的格式输出服务端支持的API版本。
kubectl apply – 通过文件名或控制台输入,对资源进行配置。
kubectl attach – 连接到一个正在运行的容器。
kubectl autoscale – 对replication controller进行自动伸缩。
kubectl cluster-info – 输出集群信息。
kubectl config – 修改kubeconfig配置文件。
kubectl edit – 编辑服务端的资源。
kubectl expose – 输入replication controller,service或者pod,并将其暴露为新的kubernetes service。
kubectl label – 更新资源的label。
kubectl patch – 通过控制台输入更新资源中的字段。
kubectl port-forward – 将本地端口转发到Pod。
kubectl proxy – 为Kubernetes API server启动代理服务器。
kubectl replace – 通过文件名或控制台输入替换资源。
kubectl rolling-update – 对指定的replication controller执行滚动升级。
kubectl scale – 为replication controller设置新的副本数。
kubectl version – 输出服务端和客户端的版本信息。

命令行中输入kubectl --help后的结果如下图所示:

root:~# kubectl --help
kubectl controls the Kubernetes cluster manager.Find more information at: https://kubernetes.io/docs/reference/kubectl/overview/Basic Commands (Beginner):create         Create a resource from a file or from stdin.expose         Take a replication controller, service, deployment or pod and expose it as a new
Kubernetes Servicerun            Run a particular image on the clusterset            Set specific features on objectsBasic Commands (Intermediate):explain        Documentation of resourcesget            Display one or many resourcesedit           Edit a resource on the serverdelete         Delete resources by filenames, stdin, resources and names, or by resources and
label selectorDeploy Commands:rollout        Manage the rollout of a resourcescale          Set a new size for a Deployment, ReplicaSet, Replication Controller, or Jobautoscale      Auto-scale a Deployment, ReplicaSet, or ReplicationControllerCluster Management Commands:certificate    Modify certificate resources.cluster-info   Display cluster infotop            Display Resource (CPU/Memory/Storage) usage.cordon         Mark node as unschedulableuncordon       Mark node as schedulabledrain          Drain node in preparation for maintenancetaint          Update the taints on one or more nodesTroubleshooting and Debugging Commands:describe       Show details of a specific resource or group of resourceslogs           Print the logs for a container in a podattach         Attach to a running containerexec           Execute a command in a containerport-forward   Forward one or more local ports to a podproxy          Run a proxy to the Kubernetes API servercp             Copy files and directories to and from containers.auth           Inspect authorizationAdvanced Commands:diff           Diff live version against would-be applied versionapply          Apply a configuration to a resource by filename or stdinpatch          Update field(s) of a resource using strategic merge patchreplace        Replace a resource by filename or stdinwait           Experimental: Wait for a specific condition on one or many resources.convert        Convert config files between different API versionskustomize      Build a kustomization target from a directory or a remote url.Settings Commands:label          Update the labels on a resourceannotate       Update the annotations on a resourcecompletion     Output shell completion code for the specified shell (bash or zsh)Other Commands:api-resources  Print the supported API resources on the serverapi-versions   Print the supported API versions on the server, in the form of "group/version"config         Modify kubeconfig filesplugin         Provides utilities for interacting with plugins.version        Print the client and server version informationUsage:kubectl [flags] [options]Use "kubectl <command> --help" for more information about a given command.
Use "kubectl options" for a list of global command-line options (applies to all commands).

容器技术之kubectl常用命令相关推荐

  1. 云原生容器技术之 Docker 常用命令

  2. 容器编排技术 -- Kubernetes kubectl scale 命令详解

    容器编排技术 -- Kubernetes kubectl scale 命令详解 1 kubectl scale 2 语法 3 示例 4 Flags kubectl scale 扩容或缩容 Deploy ...

  3. 容器编排技术 -- Kubernetes kubectl rolling-update 命令详解

    容器编排技术 -- Kubernetes kubectl rolling-update 命令详解 1 kubectl rolling-update 2 语法 3 示例 4 Flags kubectl ...

  4. 容器编排技术 -- Kubernetes kubectl replace 命令详解

    容器编排技术 -- Kubernetes kubectl replace 命令详解 1 kubectl replace 2 语法 3 示例 4 Flags kubectl replace 使用配置文件 ...

  5. 容器编排技术 -- Kubernetes kubectl patch 命令详解

    容器编排技术 -- Kubernetes kubectl patch 命令详解 1 kubectl patch 2 语法 3 示例 4 Flags kubectl patch 使用(patch)补丁修 ...

  6. 容器编排技术 -- Kubernetes kubectl label 命令详解

    容器编排技术 -- Kubernetes kubectl label 命令详解 1 kubectl label 2 语法 3 示例 4 Flags kubectl label 更新(增加.修改或删除) ...

  7. 容器编排技术 -- Kubernetes kubectl get 命令详解

    容器编排技术 -- Kubernetes kubectl get 命令详解 1 kubectl get 2 语法 3 示例 4 Flags kubectl get 获取列出一个或多个资源的信息. 可以 ...

  8. 容器编排技术 -- Kubernetes kubectl edit 命令详解

    容器编排技术 -- Kubernetes kubectl edit 命令详解 1 kubectl edit 2 语法 3 示例 4 Flags kubectl edit 使用默认编辑器 编辑服务器上定 ...

  9. 容器编排技术 -- Kubernetes kubectl delete 命令详解

    容器编排技术 -- Kubernetes kubectl delete 命令详解 1 kubectl delete 2 语法 3 示例 4 Flags kubectl delete 通过配置文件名.s ...

最新文章

  1. 读书笔记(2) OpenLayers中的图层
  2. FootSwitch脚踏开关:三位USB静音脚踏板脚踏开关脚踏键盘鼠标
  3. Linux集群服务知识点总结及通过案例介绍如何实现高性能web服务
  4. 编译Android VNC Server
  5. Linux/MacOS 安装 Oh my zsh
  6. 自动打包_全自动打包机行业发展如何?全自动打包机行业发展现状分析
  7. js 获得明天0点时间戳_js实现一个简单钟表动画(javascript+html5 canvas)
  8. LDA(线性判别分析)详解 —— matlab
  9. 【智驾深谈】想拿自动驾驶融资,先过VC这16问
  10. linux系统小米球(ngrok)实现内网穿透
  11. NOIP2018 摸鱼记
  12. Linux 共享文件夹
  13. 试简述smtp通信的三个阶段的过程_POP3_SMTP_IMAP初步介绍
  14. 磁盘空间的三种分配方式
  15. python无限循环一段句子,python无限循环语句如何实现
  16. WindowsXP注册表详解
  17. 微信引流推广:美拍视频简单的引流方法分享
  18. 将Raspberry Pi用作台式PC的17个最佳Raspbian应用
  19. 【鼠标手势】Mouselnc使用笔记/Mouselnc+AHK=无敌好用/鼠标手势分享
  20. 一文解决浏览器跨域问题

热门文章

  1. php脚本超时 结束执行代码
  2. UIViewController生命周期的理解
  3. WebApi系列~自主宿主HttpSelfHost的实现
  4. 路由重分布列表控制例子
  5. postgresql 怎么读_大数据采集和抽取怎么做?这篇文章终于说明白了!
  6. centos7与centos6区别
  7. Zookeeper JavaApi 增删改查
  8. java手机状态栏圆形图标,android实现状态栏添加图标的函数实例
  9. [转载] Java中日期格式转换
  10. scala 线性回归_Scala的特征线性化