容器编排技术 -- Kubernetes kubectl delete 命令详解
容器编排技术 -- Kubernetes kubectl delete 命令详解
- 1 kubectl delete
- 2 语法
- 3 示例
- 4 Flags
kubectl delete
通过配置文件名、stdin、资源名称或label选择器来删除资源。
支持JSON和YAML格式文件。可以只指定一种类型的参数:文件名、资源名称或label选择器。
有些资源,如pod,支持优雅的(graceful)删除,因为这些资源一般是集群中的实体,所以删除不可能会立即生效,这些资源在强制终止之前默认定义了一个周期(宽限期),但是你可以使用--grace-period flag来覆盖该值,或者通过pass --now设置该周期为1。
如果托管Pod的Node节点已经停止或者无法连接API Server,使用delete命令删除Pod需等待时间更长。要强制删除资源,需指定- force flag,且设置周期(宽限期)为0。
如果执行强制删除Pod,则调度程序会在节点释放这些Pod之前将新的Pod放在这些节点上,并使之前Pod立即被逐出。
注意:执行delete命令时不会检查资源版本,如果在执行delete操作时有人进行了更新操作,那么更新操作将连同资源一起被删除。
语法
$ delete ([-f FILENAME] | TYPE [(NAME | -l label | --all)])
示例
使用 pod.json中指定的资源类型和名称删除pod。
kubectl delete -f ./pod.json
根据传入stdin的JSON所指定的类型和名称删除pod。
cat pod.json | kubectl delete -f -
删除名为“baz”和“foo”的Pod和Service。
kubectl delete pod,service baz foo
删除 Label name = myLabel的pod和Service。
kubectl delete pods,services -l name=myLabel
强制删除dead node上的pod
kubectl delete pod foo --grace-period=0 --force
删除所有pod
kubectl delete pods --all
Flags
Name | Shorthand | Default | Usage |
---|---|---|---|
all | false | select all resources in the namespace of the specified resource types. | |
cascade | true | If true, cascade the deletion of the resources managed by this resource (e.g. Pods created by a ReplicationController). Default true. | |
filename | f | [] | Filename, directory, or URL to files containing the resource to delete. |
force | false | Immediate deletion of some resources may result in inconsistency or data loss and requires confirmation. | |
grace-period | -1 | Period of time in seconds given to the resource to terminate gracefully. Ignored if negative. | |
ignore-not-found | false | Treat "resource not found" as a successful delete. Defaults to "true" when --all is specified. | |
include-extended-apis | true | If true, include definitions of new APIs via calls to the API server. [default true] | |
now | false | If true, resources are signaled for immediate shutdown (same as --grace-period=1). | |
output | o | Output mode. Use "-o name" for shorter output (resource/name). | |
recursive | R | false | Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. |
selector | l | Selector (label query) to filter on. | |
timeout | 0s | The length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object |
容器编排技术 -- Kubernetes kubectl delete 命令详解相关推荐
- 容器编排技术 -- Kubernetes kubectl replace 命令详解
容器编排技术 -- Kubernetes kubectl replace 命令详解 1 kubectl replace 2 语法 3 示例 4 Flags kubectl replace 使用配置文件 ...
- 容器编排技术 -- Kubernetes kubectl run 命令详解
容器编排技术 -- Kubernetes kubectl run 命令详解 1 kubectl run 2 语法: 3 示例: 4 其它详细说明 kubectl run 创建并运行一个或多个容器镜像. ...
- 容器编排技术 -- Kubernetes kubectl scale 命令详解
容器编排技术 -- Kubernetes kubectl scale 命令详解 1 kubectl scale 2 语法 3 示例 4 Flags kubectl scale 扩容或缩容 Deploy ...
- 容器编排技术 -- Kubernetes kubectl rolling-update 命令详解
容器编排技术 -- Kubernetes kubectl rolling-update 命令详解 1 kubectl rolling-update 2 语法 3 示例 4 Flags kubectl ...
- 容器编排技术 -- Kubernetes kubectl patch 命令详解
容器编排技术 -- Kubernetes kubectl patch 命令详解 1 kubectl patch 2 语法 3 示例 4 Flags kubectl patch 使用(patch)补丁修 ...
- 容器编排技术 -- Kubernetes kubectl label 命令详解
容器编排技术 -- Kubernetes kubectl label 命令详解 1 kubectl label 2 语法 3 示例 4 Flags kubectl label 更新(增加.修改或删除) ...
- 容器编排技术 -- Kubernetes kubectl get 命令详解
容器编排技术 -- Kubernetes kubectl get 命令详解 1 kubectl get 2 语法 3 示例 4 Flags kubectl get 获取列出一个或多个资源的信息. 可以 ...
- 容器编排技术 -- Kubernetes kubectl edit 命令详解
容器编排技术 -- Kubernetes kubectl edit 命令详解 1 kubectl edit 2 语法 3 示例 4 Flags kubectl edit 使用默认编辑器 编辑服务器上定 ...
- 容器编排技术 -- Kubernetes kubectl create 命令详解
容器编排技术 -- Kubernetes kubectl create 命令详解 1 kubectl create 2 语法 3 示例 4 Flags kubectl create 通过配置文件名或s ...
最新文章
- Eclipse 中 Debug 模式跳转到 exitCurrentThread 的问题解决
- pcss评分_GTA5画质设置 N卡画质选项设置指南
- java高并发下的数据安全
- eclipse 中 Android sdk 无法更新的问题
- 删除list中的一个节点
- python读取print输出的内容_Python文件中将print的输出内容重定向到变量中
- html目录参数加密,从HTML文件中取出JS加密需要的参数,并调用js内的加密算法
- shell信息查看脚本linux,每次登录Shell时使用shell脚本查看Linux上的系统信息
- 蓝桥杯2018年第九届C/C++省赛B组第七题-螺旋折线
- java使用python爬虫,如何使用 Python 爬虫爬取 Java 题库?
- 《卡巴斯基全系列》大客户key31个,有了它不用到处找卡巴斯基的KEY了!
- 计算机科技想象作文600字,科技想象作文600字四篇
- node-sass安装失败完美解决方法
- 脑地形图用matlab怎么画,利用MATLAB绘制GTOPO30的DEM地形图
- 2021年中考计算机考试,2021年初中信息技术考试操作题
- dalvik模式和art模式的区别
- 什么是服务器托管(服务器托管方式的特点)
- 计算机三级网络技术笔记(选择题)
- 异步编程的实现方式以及区别
- matlab在高等数学中的,matlab在高等数学中的应用
热门文章
- jQuery .tmpl() 用法
- Magento 创建唯一优惠券 Create unique coupon code in Magento
- SVG矢量绘图 path路径详解(基本画法)
- Magento:Service Temporarily Unavailable ?
- php 备份数据库 Backup Your MySQL Database Using PHP
- FullCalendar 五:FullCalendar应用——编辑与删除日程事件
- Linux Shell高级技巧(二)
- volatile深入
- CMake和Make——简介和对比
- 【今日CS 视觉论文速览】11 Dec 2018