批量删除指定状态的pods
kubectl --kubeconfig gxq-config get pods -A|grep Evicted|awk '{print $1" "$2}'|while read LINE
do
namespace=`echo $LINE|awk '{print $1}'`
pod=`echo $LINE|awk '{print $2}'`
kubectl --kubeconfig gxq-config delete pod -n $namespace $pod
done
阿里云增加DNS解析
aliyun alidns AddDomainRecord --region cn-beijing --DomainName 'xx.cn' --Type A --RR 'www' --Value '1.1.1.1'
aliyun alidns AddDomainRecord --region cn-beijing --DomainName 'xx.cn' --Type CNAME --RR 'xxx' --Value 'bbb.yy.cn'
删除指定日期的文件夹
find /path/to/directory -type f -mtime +7 -exec rm -rf {} \;
安装Node Expoter
curl http://47.109.36.211:9090/install_node_expoter.sh | bash
#!/bin/bash
set -e
DOWNLOAD_URL="http://47.109.36.211:9090/node_exporter-1.8.2.linux-amd64.tar.gz"
DOWNLOAD_DIR="/tmp/downloads"
INSTALL_DIR="/opt/node_exporter"
SERVICE_FILE="/etc/systemd/system/node_exporter.service"
LOCK_FILE="/root/.node_exporter_install.lock"
if [ -f $LOCK_FILE ]; then
echo "Node Exporter is already installed. Exiting."
exit 0
fi
mkdir -p $DOWNLOAD_DIR $INSTALL_DIR
wget $DOWNLOAD_URL -O $DOWNLOAD_DIR/node_exporter.tar.gz
tar xf $DOWNLOAD_DIR/node_exporter.tar.gz -C $DOWNLOAD_DIR
mv $DOWNLOAD_DIR/node_exporter-*/node_exporter $INSTALL_DIR/
rm -rf $DOWNLOAD_DIR/node_exporter*
cat <<EOF > $SERVICE_FILE
[Unit]
Description=Prometheus Node Exporter
Documentation=https://github.com/prometheus/node_exporter
After=network-online.target
[Service]
User=root
ExecStart=$INSTALL_DIR/node_exporter
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now node_exporter
touch $LOCK_FILE
echo "Node Exporter installation and configuration completed"