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

  • 1 kubectl label
  • 2 语法
  • 3 示例
  • 4 Flags

kubectl label

更新(增加、修改或删除)资源上的 label(标签)。

  • label 必须以字母或数字开头,可以使用字母、数字、连字符、点和下划线,最长63个字符。
  • 如果--overwrite 为 true,则可以覆盖已有的 label,否则尝试覆盖 label 将会报错。
  • 如果指定了--resource-version,则更新将使用此资源版本,否则将使用现有的资源版本。

语法

$ label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]

示例

给名为foo的Pod添加label unhealthy=true。

kubectl label pods foo unhealthy=true

给名为foo的Pod修改label 为 'status' / value 'unhealthy',且覆盖现有的value。

kubectl label --overwrite pods foo status=unhealthy

给 namespace 中的所有 pod 添加 label

kubectl label pods --all status=unhealthy

仅当resource-version=1时才更新 名为foo的Pod上的label。

kubectl label pods foo status=unhealthy --resource-version=1

删除名为“bar”的label 。(使用“ - ”减号相连)

kubectl label pods foo bar-

Flags

Name Shorthand Default Usage
all   false select all resources in the namespace of the specified resource types
allow-missing-template-keys   true If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
dry-run   false If true, only print the object that would be sent, without sending it.
filename f [] Filename, directory, or URL to files identifying the resource to update the labels
include-extended-apis   true If true, include definitions of new APIs via calls to the API server. [default true]
local   false If true, label will NOT contact api-server but run locally.
no-headers   false When using the default or custom-column output format, don't print headers (default print headers).
output o   Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-version     DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
overwrite   false If true, allow labels to be overwritten, otherwise reject label updates that overwrite existing labels.
record   false Record current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
recursive R false Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
resource-version     If non-empty, the labels update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource.
selector l   Selector (label query) to filter on, supports '=', '==', and '!='.
show-all a false When printing, show all resources (default hide terminated pods.)
show-labels   false When printing, show all labels as the last column (default hide labels column)
sort-by     If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
template     Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].

容器编排技术 -- Kubernetes kubectl label 命令详解相关推荐

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

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

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

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

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

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

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

    容器编排技术 -- Kubernetes kubectl annotate 命令详解 1 kubectl annotate 2 有效资源类型包括: 3 语法 4 示例 5 Flags kubectl ...

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

    容器编排技术 -- Kubernetes kubectl expose命令详解 1 kubectl expose 2 语法 3 示例 4 其它详细说明 kubectl expose 将资源暴露为新的K ...

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

    容器编排技术 -- Kubernetes kubectl set 命令详解 1 kubectl set 2 语法 3 子命令 kubectl set 配置应用资源. 使用这些命令能帮你更改现有应用资源 ...

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

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

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

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

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

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

最新文章

  1. 自己动手,做一款抬头显示的「Todo Hud」
  2. css中关于居中的那点事儿
  3. Paddle中的自动微分功能测试
  4. 数学之美 系列三 -- 隐含马尔可夫模型在语言处理中的应用
  5. 二叉树的基本特性和二叉树的几种基本操作的机制_深入理解二叉树01 二叉树基础
  6. android---简单的通讯录
  7. centos下防火墙设置
  8. 收集MySQL常用函数,值得收藏!
  9. 观察者模式Observer
  10. 【tool】常见功能测试点
  11. WebSphere的管理员界面
  12. Java Web文件上传原理分析(不借助开源fileupload上传jar包)
  13. 物联网技术及应用计算机,物联网的关键技术及计算机物联网的应用
  14. Adaptation---多屏幕多分辨率的支持和一些概念
  15. 技术学校面试该说什么_我第一次现场技术面试后,香港专业教育学院学到了什么...
  16. 字符串首尾空格去除问题
  17. 记录建hbase对应hive外表坑
  18. windows下使用控制台打开conda虚拟环境
  19. BOOT模式选择启动、Error -6311 PRSC modulefailedtowritetoa register。
  20. 超级计算机排行榜历年,历代游戏主机浮点运算能力排行榜 究竟谁才是真正的性能怪兽...

热门文章

  1. magento: configurable 显示所有属性及获取 Json Config how to get Json Config by product id
  2. 大数——大数判等(hdu2054)
  3. vs2005常用的调试方法
  4. 关于python文件操作
  5. Python——编码风格建议
  6. LeetCode 125. Valid Palindrome
  7. 《剑指Offer》 变态跳台阶
  8. 【今日CV 计算机视觉论文速览 91期】Mon, 1 Apr 2019
  9. iOS 推送通知及推送扩展
  10. Can't locate Config.pm in @INC