当前位置:网站首页>How to clean up discarded PVs and their corresponding folders
How to clean up discarded PVs and their corresponding folders
2022-07-02 18:44:00 【Migrant worker Lao Wang】
Blog home page :https://tomcat.blog.csdn.net
Blogger's nickname : Lao Wang of migrant workers
Main areas :Java、Linux、K8S
We look forward to your attention, praise and collection comments
Catalog
pv yes k8s Important storage resources in . Since it's storage , That involves taking up disk space . In the use of k8s In the process of clustering , If you don't pay attention to cleaning and discarding pv, Then it's easy to accumulate a lot of garbage pv, Not only is it inconvenient k8s Management of , It may also lead to insufficient disk space .
This article is written by storage class Dynamically supplied pv For example , Demo obsolete pv and nfs Clean up the corresponding folder on the server .
If the pv I'm not familiar with the recycling strategy , Can browse k8s in pv Recycling strategy for This article ( The title of the article on the left contains hyperlinks , You can directly click to jump ).
1 Confirm the status before cleaning
Confirm current k8s Clustered pv Number .
Confirm current nfs The number of files under the shared path of the server .
Confirm current nfs Disk usage of the server .
2 Export obsolete pv stay nfs The corresponding path on the server
kubectl get pv \
-o custom-columns=STATUS:.status.phase,PATH:.spec.nfs.path \
|grep Released \
|awk '{print $2}' \
> 156.txt
there 156.txt Text for storing path information , Because of the master Node's intranet IP by 192.168.130.156, So it's called 156.txt, In their own cleaning process , You can name this file as you like .
Exported text :
/nfs/k8s/aektemp-data-volume-2-geos-object-store-xa21e-1-pvc-00a765e0-f3f8-4ab8-839f-70e3a89e01a7
/nfs/k8s/gektest-data-volume-geos-relational-store-j7ns8-kerc-0-pvc-0117511b-a121-463b-9115-1877e7bee67a
/nfs/k8s/gek-data-volume-gs-spatiotemporal-index-store-nn2h0-coordinator-0-pvc-01290353-91b1-4640-a8c3-a7f859bcdb72
/nfs/k8s/csh05-data-volume-1-geos-object-store-iamgf-0-pvc-021a966b-04f3-4c50-a852-8462e3af95e7
……
/nfs/k8s/aektemp-data-volume-geos-in-memory-store-xvytd-0-pvc-02fa0401-fdba-4368-800d-43d3b957c2bc
/nfs/k8s/aek-queue-data-volume-arcgis-queue-store-0-pvc-036ffb00-f734-44f7-9a8a-d2028092decc
3 clear k8s The abandonment of pv
Write the following code to the computer , And run , You can clean it up pv.
#!/bin/bash
whiteList=`kubectl get pv |grep Released |awk '{print $1}'`
echo "${whiteList}" | while read line
do
kubectl patch pv ${line} -p '{"spec":{"persistentVolumeReclaimPolicy":"Delete"}}'
done
As shown in the figure below , After running the script ,Released State of pv Have been deleted ,pv Quantity from 583 Down to 38.
4 clear nfs Obsolete files on the server
Will be the first 2 The text file generated in step and the following code are written nfs The server , And run ${ Script path } ${ Text path }
, Such as ./cleaner.sh 156.txt
, That is, you can clean up waste files .
#!/bin/bash
whiteList=`cat $1`
echo "${whiteList}" | while read line
do
rm -rf "$line"
done
The results are shown in the following figure , Cleaned up 500 Multiple folders , and 60 many G Of disk space .
If you want to reprint , Please indicate the source of this article : Migrant worker Lao Wang's CSDN Blog https://blog.csdn.net/monarch91 .
边栏推荐
- AI开发调试系列第二弹:多机分布式调测探索之旅
- ESP32-C3入门教程 问题篇⑪——esp-tls: create_ssl_handle failed, tls_io_instance->options.trusted_certs null
- Web版3D可视化工具,程序员应该知道的97件事,AI前沿论文 | 资讯日报 #2022.07.01
- Implementation shadow introduction
- Nm01 function overview and API definition of nm module independent of bus protocol
- iframe嵌套详解
- 初夏,开源魔改一个带击杀音效的电蚊拍!
- Stretchdibits function
- promise 和 Observable 的区别
- 元宇宙链游系统开发(逻辑开发)丨链游系统开发(详细分析)
猜你喜欢
A good programmer is worth five ordinary programmers!
Wechat applet video sharing platform system graduation design (2) applet function
徹底搞懂基於Open3D的點雲處理教程!
Leetcode interview question 16.17 Continuous sequence
Qt官方示例:Qt Quick Controls - Gallery
NM01-独立于总线协议的NM模块功能概述与API定义
Wechat applet video sharing platform system graduation design completion (7) Interim inspection report
LightGroupButton* sender = static_cast<LightGroupButton*>(QObject::sender());
Ali was wildly asked by the interviewer on three sides. Redis dared not write 'proficient' on his resume anymore
深度学习数学基础
随机推荐
NM01-独立于总线协议的NM模块功能概述与API定义
Another double non reform exam 408, will it be cold? Software College of Nanchang Aviation University
在支付宝账户上买基金安全吗
Leetcode interview question 16.11 Diving board
哪个券商公司网上开户佣金低又安全又可靠
如何清理废弃pv和其对应的文件夹
Unity learning shader notes [82] black and white processing of enhanced single channel color rendering
Detailed explanation of cjson usage
Chain game system development (unity3d chain game development details) - chain game development mature technology source code
QQmlApplicationEngine
719. 找出第 K 小的数对距离
Unity学习shader笔记[八十二]增强单通道颜色渲染的黑白处理
Chrome officially supports MathML, which is enabled in chromium dev 105 by default
深度神经网络总结
How to write controller layer code gracefully?
After 22 years in office, the father of PowerShell will leave Microsoft: he was demoted by Microsoft for developing PowerShell
Ali was wildly asked by the interviewer on three sides. Redis dared not write 'proficient' on his resume anymore
300+篇文献!一文详解基于Transformer的多模态学习最新进展
揭秘得物客服IM全链路通信过程
Leetcode interview question 17.04 Vanishing numbers