openshift-docs
  • 不知所措的openshift kubernetes
  • 3scale
    • 在openshift使用3scale-operator部署3scale
  • Hyperledger-Fabric
    • Hyperledger Fabric on openshift 3.11
  • adminer
    • helm部署adminer
  • admission-controller
    • k8s nameapce增加默认node-selector和defaultTolerations
  • cert-manager
    • cert-manager-1.5升级到1.6
  • cicd
    • Argocd定时备份到us3
    • Argocd添加服务流程
    • Argocd自定义健康检查
    • helm安装argocd
    • k8s1.22部署gitlab对接keycloak
    • 使用Tekton+Helm-Chart+ArgoCD构建GitOps CICD
    • 使用 Tekton 构建CI流程
    • 使用argocd-notifications通知Tekton触发api-test
    • 使用 docker buildx 构建多CPU架构镜像
    • 使用image-syncer同步多CPU架构镜像到私有仓库
    • 开源helm chart 发布到 https://artifacthub.io/
    • 快速编写通用helm chart
  • client-go
    • k8s client-go 创建ingress示例
  • cluster-monitor-opertor
    • Openshift3.11 alertmanager 持久化
    • cluster-monitor-operator alertmanager配置
    • cluster-monitor-operator添加外部metrics
    • openshift3.11-cluster-monitoring-operator数据持久化
  • config-syncer
    • k8s使用config-syncer(kubed)同步secret
  • dns
    • k8s coredns 优化
    • k8s 使用coredns 自定义hosts 解析
  • dnsmasq
    • MAC 环境使用 dnsmasq 配置openshift相关自定义域名
    • 配置dnsmasq apps通配解析
  • elasticsearch
    • Elasticsearch查询重复数据
    • elasticsearch-kibana-8.10创建向量索引模板
    • openshift3.11中使用ECK安装filebeat+elasticsearch+kibana收集日志初探
    • openshift3.11部署eck1.6+es7.14.1
    • 使用kibana修改数据流索引mapping
  • etcd
    • k8s 1.22 使用cronjob 备份etcd
    • k8s1.22使用CronJob定时备份etcd到US3
    • 使用cronjob备份etcd
    • 恢复openshift3.11-etcd数据快照
  • flowiseai
    • argocd2.2.1+helm3.9-chart+k8s1.22部署flowise
  • ingress-nginx
    • ingress-nginx启用header名称中下划线
  • ipfs
    • golang计算文件ipfs cid
    • helm安装ipfs-cluster
  • kafka
    • banzaicloud-stable/kafka-operator+local-path迁移主机
    • 使用bitnami/kafka部署外部可访问的 kafka
  • keycloak
    • openshift使用keycloak登录
  • kong
    • Kong使用ip-pestriction插件配置IP白名单
    • kong admin api 使用 go-kong 调用
    • kong manager页面显示空白,报错net:ERR_HTTP2_PROTOCOL_ERROR
    • kong helm 安装
    • kong 自定义默认error html
    • 使用kong转发TCP服务
  • kube-flannel
    • kube-flannel-v0.20.1升级v0.22.2
  • kubeadm
    • RockLinux+kubeadm+k8s-1.22.16 升级到1.22.17
    • RockLinux+kubeadm+k8s-1.22.2 升级到1.22.16
  • kubevirt
    • Kubevirt on Openshift
    • kubebirt 中使用 cloud-init
    • kubevirt限制vm发布主机
    • openshift-3.11-kubevirt从v0.19.0升级到v0.27.0
    • 使用alpine-make-vm-image制作alpine-qcow2云镜像
    • 使用virtualbox自定义Alpine-vrit云镜像
  • load-balance
    • ucloud 添加负载均衡报文转发配置
  • metrics-sever
    • k8s-1.22安装metrics-server
  • mongodb
    • 使用argocd部署mongo-express
    • 阿里云 Mongodb副本集实例使用
  • mysql
    • Helm部署mysql
    • helm安装phpmyadmin
    • mysql批量修改utf8mb3为utf8mb4字符集
    • 部署MySQL Server Exporter
  • openfaas
    • OpenFaaS定时任务
    • OpenFaas使用Go模板创建Function
    • helm 安装openfaas
  • operator
    • 使用Operator-SDK构建基于Helm 的 Operator
  • playwright
    • 使用playwright截图Kibana图表
  • prometheus-operator
    • helm+kube-prometheus-stack-prometheus-operator+local-path(storageclass)部署的prometheus迁移主机
    • k8s 1.22 环境 kube-prometheus-stack 22.x 升级至 41.x
    • 使用helm+kube-prometheus-stack只部署prometheus
  • proxy
    • 使用快代理使用海外代理访问海外网站
  • rancher
    • helm 安装rancher 2.6.3
    • rancher-backup使用US3备份
    • rancher2.6.3升级至rancher2.6.9
    • rancher2.6.9对接keycloak
    • 解决rancher-v2.6.3报helm-operator更新rancher-webhook异常问题
    • 解决更新rancher2.6.13后报webhook和fleet chart版本不支持
  • raspberry-pi
    • mac os golang编译ARM环境go-sqlite3项目
    • 无头(headless) raspberry pi 4 ssh wifi 安装(mac)
    • 树莓派4B+raspberry-pi-os-buster在线安装k3s
    • 树莓派Raspberry Pi OS 设置静态ip
    • 树莓派raspberry-pi-os(32bit)安装docker
    • 树莓派raspberry pi os开启ssh
    • 树莓派安装centos7并简单优化
  • rbac
    • openshift给没能打开web terminal终端的用户添加权限
  • registry
    • 使用image-syncer同步所需镜像到仓库
  • ssh
    • Mac OSX ssh隧道使用方法
  • storage
    • lvm分区配置备份与恢复测试
    • openshift3.11使用nfs-client-provisioner+UCloud-UFS提供动态pv存储
    • openshift3.11使用nfs-client-provisioner+阿里云NAS提供动态nfs
    • openshift3.11配置local volume
    • openshift动态nfs
  • tracing
    • Ipfs cluseter使用分布式追踪系统jaeper tracing
  • troubleshooting
    • coredns service 连接超时(connection timed out; no servers could be reached)
    • etcdDatabaseHighFragmentationRatio 异常处理
    • helm更新服务报错提示statefulset更新是被禁止的
    • k8s如果防止容器中出现僵尸进程
    • kubevirt api server 证书过期问题导致openshfit调度异常
    • macOS Chrome访问https://registry-console-default.appsxxx.xxx.xxx/页面显示ERR_CERT_INVALID,且不能点继续
    • master 主机df 卡死
    • openshift project Terminaing处理
    • OpenShift Docker Registry 500
    • 解决openshift3.11 node NotReady csr Pending
    • openshift3.11-pvc-delete-Terminating-hang
    • openshift3.11清理Terminating 状态project
    • pod pending event报错cni无可用IP
    • ucloud环境开启selinux后/var/log/messages不能写入问题
    • ucloud环境开启selinux
    • 解决openshift3.11不能下载redhat registry.access.redhat.com中镜像问题
    • 证书未过期但是报NET::ERR_CERT_AUTHORITY_INVALID证书错误处理
  • walletconnect
    • WalletConnect-Relay 部署
Powered by GitBook
On this page
  • 主机规划
  • 备份prometheus
  • 停止prometheus
  • 查看pvc
  • 备份pvc pv yaml
  • 备份pv数据
  • 迁移prometheus
  • 设置monitor 主机label
  • 删除旧pvc
  • 重建pv pvc
  • 使用helm 更新prometheus

Was this helpful?

  1. prometheus-operator

helm+kube-prometheus-stack-prometheus-operator+local-path(storageclass)部署的prometheus迁移主机

主机规划

主机名
ip
node label
备注

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

kubectl get pvc prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-0 -o yaml > prometheos0.pvc.yaml
kubectl get pvc prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-1 -o yaml > prometheus1.pvc.yaml
kubectl get pv pvc-bde439cc-2889-4a81-ba68-f38a93c83c4e -o yaml > prometheus0.pv.yaml
kubectl get pv pvc-2d48398a-91d8-47f5-973b-d03f37f0a898 -o yaml > prometheus1.pv.yaml

备份pv数据

查看pv prometheus0.pv.yaml prometheus1.pv.yaml得知pv 所在主机及目录分别为:

logging1
/data/local-path-provisioner/pvc-bde439cc-2889-4a81-ba68-f38a93c83c4e_monitoring_prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-0
logging2
/data/local-path-provisioner/pvc-2d48398a-91d8-47f5-973b-d03f37f0a898_monitoring_prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-1

在monitor1主机执行

# copy prometheos-0 pv 数据到monitor1临时目录
scp -r 172.16.13.77:/data/local-path-provisioner/pvc-bde439cc-2889-4a81-ba68-f38a93c83c4e_monitoring_prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-0 /data/local-path-provisioner/pvc-bde439cc-2889-4a81-ba68-f38a93c83c4e_monitoring_prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-0.bak

monitor2 执行

# copy prometheos-1 pv 数据到monitor1临时目录
scp -r 172.16.36.25:/data/local-path-provisioner/pvc-2d48398a-91d8-47f5-973b-d03f37f0a898_monitoring_prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-1 /data/local-path-provisioner/pvc-2d48398a-91d8-47f5-973b-d03f37f0a898_monitoring_prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-1.bak

迁移prometheus

设置monitor 主机label

kubectl label node monitor1 monitor=true
kubectl label node monitor2 monitor=true

删除旧pvc

kubectl delete pvc prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-0 prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-1

重建pv pvc

重建prometheus-0 pv pvc

复制备份pv 为新pv yaml

cp prometheus0.pv.yaml prometheus0.new.pv.yaml

编辑 prometheus0.new.pv.yaml,清理多余内容(主要是uid、resourceVersion、creationTimestamp、status等数据), 并修改storage 大小,内容如下:

apiVersion: v1
kind: PersistentVolume
metadata:
  annotations:
    pv.kubernetes.io/provisioned-by: rancher.io/local-path
  finalizers:
  - kubernetes.io/pv-protection
  name: pvc-bde439cc-2889-4a81-ba68-f38a93c83c4e
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 200Gi
  hostPath:
    path: /data/local-path-provisioner/pvc-bde439cc-2889-4a81-ba68-f38a93c83c4e_monitoring_prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-0
    type: DirectoryOrCreate
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - monitor1.solarfs.k8s
  persistentVolumeReclaimPolicy: Delete
  storageClassName: local-path
  volumeMode: Filesystem

创建新prometheus-0 pv

kubectl apply -f prometheus0.new.pv.yaml

复制备份pvc 到 prometheus0.new.pvc.yaml

cp prometheus0.pvc.yaml prometheus0.new.pvc.yaml

编辑prometheus0.new.pvc.yaml,清理多余内容(主要是uid、resourceVersion、creationTimestamp、status等数据), 并修改storage 大小,内容如下:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  annotations:
    pv.kubernetes.io/bind-completed: "yes"
    pv.kubernetes.io/bound-by-controller: "yes"
    volume.beta.kubernetes.io/storage-provisioner: rancher.io/local-path
    volume.kubernetes.io/selected-node: monitor1.solarfs.k8s
  finalizers:
  - kubernetes.io/pvc-protection
  labels:
    app: prometheus
    app.kubernetes.io/instance: prometheus-community-kube-prometheus
    app.kubernetes.io/managed-by: prometheus-operator
    app.kubernetes.io/name: prometheus
    app.kubernetes.io/version: 2.26.0
    operator.prometheus.io/name: prometheus-community-kube-prometheus
    operator.prometheus.io/shard: "0"
    prometheus: prometheus-community-kube-prometheus
  name: prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-0
  namespace: monitoring
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 200Gi
  storageClassName: local-path
  volumeMode: Filesystem
  volumeName: pvc-bde439cc-2889-4a81-ba68-f38a93c83c4e

创建新prometheus-0 pvc

kubectl apply -f prometheus0.new.pvc.yaml

查看pvc 状态, Bound 状态为正常

# 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   200Gi      RWO            local-path     3h6m

重建prometheus-1 pv pvc

步骤同prometheus-0, 略

备份数据修改为pv path目录

在monitor1主机执行

mv /data/local-path-provisioner/pvc-bde439cc-2889-4a81-ba68-f38a93c83c4e_monitoring_prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-0.bak /data/local-path-provisioner/pvc-bde439cc-2889-4a81-ba68-f38a93c83c4e_monitoring_prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-0
# 重置目录权限及属主
chmod 777 /data/local-path-provisioner/pvc-bde439cc-2889-4a81-ba68-f38a93c83c4e_monitoring_prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-0
chmod 777 /data/local-path-provisioner/pvc-bde439cc-2889-4a81-ba68-f38a93c83c4e_monitoring_prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-0/prometheus-db
chown 1000:2000 -R  /data/local-path-provisioner/pvc-bde439cc-2889-4a81-ba68-f38a93c83c4e_monitoring_prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-0/prometheus-db/*

在monitro2 主机执行

mv /data/local-path-provisioner/pvc-2d48398a-91d8-47f5-973b-d03f37f0a898_monitoring_prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-1.bak /data/local-path-provisioner/pvc-2d48398a-91d8-47f5-973b-d03f37f0a898_monitoring_prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-1
# 重置目录权限及属主
chmod 777 /data/local-path-provisioner/pvc-2d48398a-91d8-47f5-973b-d03f37f0a898_monitoring_prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-1
chmod 777 /data/local-path-provisioner/pvc-2d48398a-91d8-47f5-973b-d03f37f0a898_monitoring_prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-1/prometheus-db
chown 1000:2000 -R /data/local-path-provisioner/pvc-2d48398a-91d8-47f5-973b-d03f37f0a898_monitoring_prometheus-prometheus-community-kube-prometheus-db-prometheus-prometheus-community-kube-prometheus-1/prometheus-db/*

使用helm 更新prometheus

修改helm 更新values

kube-prometheus-stack-values.yaml, 增加 nodeSelector 配置

prometheus:
  ...
  prometheusSpec:
    replicas: 2
    nodeSelector:
      monitor: 'true'

执行helm upgrade

helm upgrade --install prometheus-community kube-prometheus-stack-19.1.0.tgz -f kube-prometheus-stack-values.yaml -n  monitoring --create-namespace

检查prometheus pod

kubectl get pod|grep kube-prometheus
# 显示如下
prometheus-prometheus-community-kube-prometheus-0          2/2     Running   0          176m
prometheus-prometheus-community-kube-prometheus-1          2/2     Running   0          176m
Previousprometheus-operatorNextk8s 1.22 环境 kube-prometheus-stack 22.x 升级至 41.x

Last updated 3 years ago

Was this helpful?