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

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

kubectl replace

使用配置文件或stdin来替换资源。

支持JSON和YAML格式。如果替换当前资源,则必须提供完整的资源规范。可以通过以下命令获取:

$ kubectl get TYPE NAME -o yaml

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

语法

$ replace -f FILENAME

示例

使用pod.json中的数据替换pod。

kubectl replace -f ./pod.json

根据传入的JSON替换pod。

cat pod.json | kubectl replace -f -

更新镜像版本(tag)到v4

kubectl get pod mypod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | kubectl replace -f -

强制替换,删除原有资源,然后重新创建资源

kubectl replace --force -f ./pod.json

Flags

Name Shorthand Default Usage
cascade   false Only relevant during a force replace. If true, cascade the deletion of the resources managed by this resource (e.g. Pods created by a ReplicationController).
filename f [] Filename, directory, or URL to files to use to replace the resource.
force   false Delete and re-create the specified resource
grace-period   -1 Only relevant during a force replace. Period of time in seconds given to the old resource to terminate gracefully. Ignored if negative.
include-extended-apis   true If true, include definitions of new APIs via calls to the API server. [default true]
output o   Output mode. Use "-o name" for shorter output (resource/name).
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.
save-config   false If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
schema-cache-dir   ~/.kube/schema If non-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'
timeout   0s Only relevant during a force replace. The length of time to wait before giving up on a delete of the old resource, zero means determine a timeout from the size of the object. Any other values should contain a corresponding time unit (e.g. 1s, 2m, 3h).
validate   true If true, use a schema to validate the input before sending it

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

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

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

  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 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. 嵌入式多媒体设计7--QDockWidget大小调整及隐藏标题
  2. PowerShell渗透工具Nishang
  3. JAVA流程控制详解
  4. 8月第4周国内IT网站/频道Top15:太平洋降至第三
  5. c语言实训作业总结,c语言程序设计上机实践心得报告
  6. import cv2 失败 ImportError:DLL load fail:找不到指定模块
  7. “开发者的面试完全是无稽之谈”
  8. idea git push 码云: Remote: [31mYou do not have permission to push to the repository via HTTPS
  9. 【CPRI】(1)CPRI基本概念和相关术语
  10. 萨姆休斯顿州立大学计算机专业,萨姆休斯顿州立大学排名在2020年USNEWS美国最佳综合大学排名第281...
  11. win11连接不了蓝牙耳机的解决办法
  12. 反向代理和正向代理之间的区别
  13. 用matlab求方程解的三种方法
  14. 2.23 haas506 2.0开发教程 - KeyPad - 矩阵键盘(仅支持M320开发板)
  15. 小甲鱼python课后题和答案简书_【py小甲鱼笔记】-列表
  16. GAN网络学习入门之:A Beginner's Guide to Generative Adversarial Networks (GANs)-翻译
  17. 中国协作机器人行业投资潜力规划及未来发展趋势报告2021-2027年
  18. 推荐一个可以查看火车座位的小程序
  19. 业界毒瘤仙人掌一条龙服务
  20. 如何用FLStudio水果软件下载制作电子音乐及激活码序列号教程(非破解版)

热门文章

  1. 复杂产品的响应式设计【知识篇】
  2. Magento 默认显示全部 magento products per page on grid default value all
  3. 20个让Web Developer开发生涯更加轻松的工具
  4. 全排列及相关扩展算法(五)——递增(递减)进位制数求原排列算法
  5. 斗地主AI算法——第七章の被动出牌(1)
  6. 问题:HikariPool-1 - Shutdown initiated...的解决
  7. Leetcode算法题(C语言)11--有效的数独
  8. LeetCode 374. Guess Number Higher or Lower
  9. 加载本地json文件,并利用批处理调用Chrome显示html
  10. request-爬取一张图片的练习-答案-私