etcd-auto-defrag:基于 etcd 的自动碎片整理工具项目

etcd碎片整理增强

Branch1Tags0

etcd-auto-defrag

etcd automatic defragmentation plugin.

Function Introduction

Customers hope to execute etcd defragmentation tasks on demand, minimizing impact on the cluster.

After running job.yaml, it will automatically compress the etcd database according to the configured DB_SIZE_THRESHOLD threshold.

Specifications:

  1. Traverse cluster nodes, if etcd db size exceeds the configured threshold (default 1G), then execute compact and defrag.
  2. If it is a master node, first transfer the leader to any other member that has been defragged, then execute defrag.
  3. If execution fails, retry according to configuration (default 2 times).

Compilation Preparation

  1. Install make, gcc, docker, docker minimum 18.09, recommended 23.0 or above version, and be able to use buildx.

    Can be installed through yum install.

Build

Execute build in the code root directory.

docker buildx build . -f build/Dockerfile --provenance=false -t cr.openfuyao.cn/openfuyao/etcd-auto-defrag:latest --load

Deployment

  1. Import the image package generated during build into the cluster.

    ctr -n k8s.io image import etcd-auto-defrag.tar
    
  2. Please refer to the yaml file example under example, modify the required and optional parameters, then apply in the environment.

    kubectl apply -f job.yaml
    

Function Introduction

After running job.yaml, it will automatically compress the etcd database according to the configured DB_SIZE_THRESHOLD threshold:

  1. If etcd db size exceeds DB_SIZE_THRESHOLD, then execute compact and defrag commands.
  2. Otherwise, log and exit.

You can view logs using kubectl command.

kubectl get po -n kube-system |grep etcd-auto
kubectl logs -n kube-system {PODNAME}

Introduction

etcd碎片整理增强

Customize your domain