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

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

kubectl patch

使用(patch)补丁修改、更新资源的字段。

支持JSON和YAML格式。

请参阅https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/HEAD/docs/api-reference/v1/definitions.html中说明,查找资源字段是否为可变的。

语法

$ patch (-f FILENAME | TYPE NAME) -p PATCH

示例

使用patch更新Node节点。

kubectl patch node k8s-node-1 -p '{"spec":{"unschedulable":true}}'

使用patch更新由“node.json”文件中指定的类型和名称标识的节点

kubectl patch -f node.json -p '{"spec":{"unschedulable":true}}'

更新容器的镜像

kubectl patch pod valid-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve-hostname","image":"new image"}]}}'
kubectl patch pod valid-pod --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"new image"}]'

Flags

Name Shorthand Default Usage
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.
filename f [] Filename, directory, or URL to files identifying the resource to update
include-extended-apis   true If true, include definitions of new APIs via calls to the API server. [default true]
local   false If true, patch will operate on the content of the file, not the server-side resource.
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').
patch p   The patch to be applied to the resource JSON file.
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.
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].
type   strategic The type of patch being provided; one of [json merge strategic]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

最新文章

  1. 智能手环功能模块设计_智能手环的设计的方案.doc
  2. Loadrunner连接负载机失败,提示Failed to connect to the load generator.Check the output window for more detail
  3. SQLServer 事务的隔离级别
  4. Docker的启动与停止命令
  5. java浏览文件夹_一个用java实现简单的文件浏览器
  6. 作业四:灯泡异常问题
  7. BeagleBone Black 连接USB摄像头,并实现采集、存储及传输
  8. U-Mail邮件服务器教您揭穿冒充发件人的伎俩
  9. Flutter:布局
  10. 移动硬盘损坏如何恢复数据
  11. Android事件总线 EventBus3.0用法学习
  12. 基于HDP使用Flume实时采集MySQL中数据传到Kafka+HDFS或Hive
  13. 理解redux-thunk
  14. 你以为买到了牛逼的Python课程,其实被割了韭菜!
  15. 成都哪个java培训机构好
  16. 【Java】 # 使用java调用MySQL的函数、存储过程
  17. 90G图片分享图片批量压缩zip和解压unzip
  18. LaTex使用方法和技巧——以IEEE会议论文模板为例
  19. 03 | ssh基础知识,连接服务器的那些事
  20. 放弃升职主管,入坑测试,从3.5K到13.5K,薪资足足翻4倍!

热门文章

  1. WordPress 主题教程 #4a:Header 模板
  2. Linux Shell脚本入门教程系列之(十六) Shell输入输出重定向
  3. 零基础 Amazon Web Services (AWS) 入门教程图文版(二)
  4. Linux流量监控工具 – iftop
  5. UIWebView加载Loading...两种方法
  6. 多线程的第三种模式(callable)
  7. Gamma分布和逆Gamma分布
  8. 动态规划——看似dp的贪心问题最大乘积(蓝桥杯试题集)
  9. PyOpenGL之3D界面详解(一)
  10. LeetCode 563. Binary Tree Tilt