# 停止服務
systemctl disable kubelet.service
systemctl disable kube-scheduler.service
systemctl disable kube-proxy.service
systemctl disable kube-controller-manager.service
systemctl disable kube-apiserver.service
systemctl stop kubelet.service
systemctl stop kube-scheduler.service
systemctl stop kube-proxy.service
systemctl stop kube-controller-manager.service
systemctl stop kube-apiserver.service
# 刪除所有容器
docker rm -f $(docker ps -qa)
# 刪除所有容器卷
docker volume rm $(docker volume ls -q)
# 解除安裝mount目錄
for mount in $(mount | grep tmpfs | grep '/var/lib/kubelet' | awk '') /var/lib/kubelet /var/lib/rancher; do umount $mount; done
刪除
rm -rf /etc/kubernetes
rm -rf /var/lib/etcd
rm -rf /var/lib/rancher
rm -rf /opt/rke
或者備份
# 備份目錄
mv /etc/kubernetes /etc/kubernetes-bak-$(date +"%y%m%d%h%m")
mv /var/lib/etcd /var/lib/etcd-bak-$(date +"%y%m%d%h%m")
mv /var/lib/rancher /var/lib/rancher-bak-$(date +"%y%m%d%h%m")
mv /opt/rke /opt/rke-bak-$(date +"%y%m%d%h%m")
rm -rf /etc/ceph \
/etc/cni \
/opt/cni \
/run/secrets/kubernetes.io \
/run/calico \
/run/flannel \
/var/lib/calico \
/var/lib/cni \
/var/lib/kubelet \
/var/log/containers \
/var/log/pods \
/var/run/calico
# 清理網路介面
network_inte***ce=`ls /sys/class/net`
for net_inter in $network_inte***ce;
doif ! echo $net_inter | grep -qie 'lo|docker0|eth*|ens*';then
ip link delete $net_inter
fidone
# 清理殘留程序
port_list='80 443 6443 2376 2379 2380 8472 9099 10250 10254'
for port in $port_list
dopid=`netstat -atlnup|grep $port |awk ''|awk -f '/' ''|grep -v -|sort -rnk2|uniq`
if [[ -n $pid ]];then
kill -9 $pid
fidone
pro_pid=`ps -ef |grep -v grep |grep kube|awk ''`
if [[ -n $pro_pid ]];then
kill -9 $pro_pid
fi# 清理iptables表
## 注意:如果節點iptables有特殊配置,以下命令請謹慎操作
sudo iptables --flush
sudo iptables --flush --table nat
sudo iptables --flush --table filter
sudo iptables --table nat --delete-chain
sudo iptables --table filter --delete-chain
systemctl restart docker
k8s 節點擴容
對於已經存在的集群,想要擴容,將乙個新的node假如集群需要在master上執行以下命令,生成token sudo kubeadm token create print join command然後在想要假如的node上執行 sudo kubeadm join假如新加入的node存在以下問題則在此n...
k8s 節點打標籤
node標籤設定後,pod可以根據要求讓pod排程到想要的節點上執行,或者不在某節點執行。或者確保pod排程到具有高效能 比如ssd的機器 的節點山上。1.展示節點標籤 kubectl get node show labels true2.新增節點標籤 3.把pod排程到指定標籤 啟動乙個deplo...
K8s部署prometheus監控K8s細節
prometheus 一些配置檔案可以再github上找到。部署 root kube prometheus manifests 目錄下所有檔案 部署 root kube prometheus manifests setup 目錄下所有檔案 要注意的是自己要建立乙個工作空間 如果報錯執行下面語句 部署...