helm+kube-prometheus-stack-prometheus-operator+local-path(storageclass)部署的prometheus迁移主机
主机规划
logging1
172.16.13.77
logging=true
原prometheus0 pvc 主机
logging2
172.16.36.25
logging=true
原prometheus1 pvc 主机
monitor1
172.16.54.227
monitor=true
新prometheus0 pvc 主机
monitor2
172.16.84.64
monitor=true
新prometheus1 pvc 主机
备份prometheus
停止prometheus
kubectl patch prometheus prometheus-community-kube-prometheus --type="merge" -p '{"spec":{"replicas":0}}'查看pvc
kubectl get pvc|grep prometheus-db
# 显示如下
prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-0 Bound pvc-bde439cc-2889-4a81-ba68-f38a93c83c4e 50Gi RWO local-path 52d
prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-1 Bound pvc-2d48398a-91d8-47f5-973b-d03f37f0a898 50Gi RWO local-path 52d备份pvc pv yaml
备份pv数据
查看pv prometheus0.pv.yaml prometheus1.pv.yaml得知pv 所在主机及目录分别为:
在monitor1主机执行
monitor2 执行
迁移prometheus
设置monitor 主机label
删除旧pvc
重建pv pvc
重建prometheus-0 pv pvc
复制备份pv 为新pv yaml
编辑 prometheus0.new.pv.yaml,清理多余内容(主要是uid、resourceVersion、creationTimestamp、status等数据), 并修改storage 大小,内容如下:
创建新prometheus-0 pv
复制备份pvc 到 prometheus0.new.pvc.yaml
编辑prometheus0.new.pvc.yaml,清理多余内容(主要是uid、resourceVersion、creationTimestamp、status等数据), 并修改storage 大小,内容如下:
创建新prometheus-0 pvc
查看pvc 状态, Bound 状态为正常
重建prometheus-1 pv pvc
步骤同prometheus-0, 略
备份数据修改为pv path目录
在monitor1主机执行
在monitro2 主机执行
使用helm 更新prometheus
修改helm 更新values
kube-prometheus-stack-values.yaml, 增加 nodeSelector 配置
执行helm upgrade
检查prometheus pod
Last updated
Was this helpful?