问题
今天机器上有个pv不用了,删除关联pvc后,删除pv时候出现问题,如下,删除mysql-wordpress
[root@cbov10-devk8s56-117 mysql]# kubectl get pv|grep mysql mysql-pv-volume 5Gi RWO Retain Bound default/mysql-pv-claim manual 153d mysql-wordpress 5Gi RWX Retain Bound basic-server/mysql-wordpress mysql-wordpress 66m
[root@cbov10-devk8s56-117 mysql]# kubectl delete pv mysql-wordpress persistentvolume "mysql-wordpress" deleted ^C [root@cbov10-devk8s56-117 mysql]# kubectl delete pv mysql-wordpress persistentvolume "mysql-wordpress" deleted ^C
一直删除不掉
解决方案
[root@cbov10-devk8s56-117 mysql]# kubectl patch pv mysql-wordpress -p '{"metadata":{"finalizers":null}}' persistentvolume/mysql-wordpress patched
[root@cbov10-devk8s56-117 mysql]# kubectl get pv|grep mysql mysql-pv-volume 5Gi RWO Retain Bound default/mysql-pv-claim manual 153d
思考
patch : 合并,补丁。
这里以“补丁”的方式(JSON 格式的)修改一个 API 对象的指定字段 ,这也是kubernetes声明式API的最主要的能力。
kubernetes大神张磊分享过,推荐订阅下他的极客专栏,写的非常好。
来源:https://www.cnblogs.com/haoprogrammer/p/12362061.html