Kuberntes 中无法删除 PV 的解决方法
Kuberntes 中无法删除 PV 的解决方法
一 背景
系统内有一个已经不再使用的 PV ,已经删除了与其关联的 Pod 及 PVC ,并对其执行了删除命令,但是无法正常删除,一直出于如下状态:
$ kubectl get pv NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE pv-nfs-gysl 1Gi RWO Recycle Terminating default/www-vct-statefulset-pvc-gysl-0 managed-nfs-storage 22h
二 解决方法
$ kubectl patch pv pv-nfs-gysl -p '{"metadata":{"finalizers":null}}' persistentvolume/pv-nfs-gysl patched $ kubectl get pv No resources found.
通过系统帮助信息,我们可以获取patch的简要使用说明:
patch: 使用 strategic merge patch 更新一个资源的 field(s)。
更多帮助信息:
# kubectl patch -h Update field(s) of a resource using strategic merge patch, a JSON merge patch, or a JSON patch. JSON and YAML formats are accepted. Examples: # Partially update a node using a strategic merge patch. Specify the patch as JSON. kubectl patch node k8s-node-1 -p '{"spec":{"unschedulable":true}}' # Partially update a node using a strategic merge patch. Specify the patch as YAML. kubectl patch node k8s-node-1 -p $'spec:\n unschedulable: true' # Partially update a node identified by the type and name specified in "node.json" using strategic merge patch. kubectl patch -f node.json -p '{"spec":{"unschedulable":true}}' # Update a container's image; spec.containers[*].name is required because it's a merge key. kubectl patch pod valid-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve-hostname","image":"new image"}]}}' # Update a container's image using a json patch with positional arrays. kubectl patch pod valid-pod --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"new image"}]' Options: --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. -f, --filename=[]: Filename, directory, or URL to files identifying the resource to update -k, --kustomize='': Process the kustomization directory. This flag can't be used together with -f or -R. --local=false: If true, patch will operate on the content of the file, not the server-side resource. -o, --output='': Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file. -p, --patch='': 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. -R, --recursive=false: Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. --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] Usage: kubectl patch (-f FILENAME | TYPE NAME) -p PATCH [options] Use "kubectl options" for a list of global command-line options (applies to all commands).
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
阿里云服务器与普通服务器区别在哪?如何选择?
阿里云服务器与普通的IDC机房或服务器厂商相比,阿里云服务器ECS具有高可用性、安全性和弹性优势。魏艾斯博客从以上几个方面详细说下这二者的区别及如何选择。 注册账号之前点我领取阿里云千元代金券,用于购买阿里云上百款云产品时可以用来抵用,节约财务成本。 一、高可用性 阿里云比普通IDC机房使用更严格的IDC标准、服务器准入标准以及运维标准,保证云计算基础框架的高可用性、数据的可靠性以及云服务器的高可用性。也就是稳定性比较高。 阿里云提供的每个地域都存在多可用区。当您需要更高的可用性时,可以利用多可用区部署方案搭建主备服务或者双活服务。对于面向金融领域的两地三中心的解决方案,您也可以通过多地域和多可用区搭建出更高的可用性服务。其中包括容灾、备份等服务,阿里云都有非常成熟的解决方案。如果某个可用区出现问题了,可以快速切换到好用的可用区上去,业务不停机。 提升可用性的产品和服务。包括云服务器ECS、负载均衡SLB、关系型数据库RDS以及数据迁移服务DTS等。行业合作伙伴以及生态合作伙伴。帮助您完成更稳定的架构,并且保证服务的持续性。多种多样的培训服务。让您从业务端到底层服务端,在整条链路上实现...
- 下一篇
运维编排场景系列----分批到机器上运行命令
场景简介 当某一任务需对多个实例进行云助手操作命令,而且需查看在部分实例上由云助手发布的内容与已存在的内容是否会引起冲突,若无冲突则余下实例可以全部执行此任务。由上述内容可以通过Tag的方式查找需要操作的实例,并使用OOS云助手来实现自动化部署,设置分批执行来解决验证发布内容在部分实例的运行情况。 解决方案 任务分解:1.通过tagKey-tagValue来查找需要操作的实例2.设置执行的批次3.循环批次内的实例执行云助手命令4.执行所有批次 一、打开控制台,找到运维编排 二、创建模版根据以上的任务步骤来看可以把此任务创建成以下模版。点击创建模版 或在公共模版中查找此模版ACS-ECS-BulkyRunCommandByTag 模版内容如下 FormatVersion: OOS-2019-06-01 Description: Run command on ECS instances by specifying tag. Parameters: commandContent: Description: Command content to run in ECS instance. Typ...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- Red5直播服务器,属于Java语言的直播服务器
- MySQL8.0.19开启GTID主从同步CentOS8
- SpringBoot2整合MyBatis,连接MySql数据库做增删改查操作
- Eclipse初始化配置,告别卡顿、闪退、编译时间过长
- CentOS关闭SELinux安全模块
- CentOS8,CentOS7,CentOS6编译安装Redis5.0.7
- 设置Eclipse缩进为4个空格,增强代码规范
- SpringBoot2整合Redis,开启缓存,提高访问速度
- SpringBoot2编写第一个Controller,响应你的http请求并返回结果
- Docker快速安装Oracle11G,搭建oracle11g学习环境