etcd-defrag

by jouve

Helm chartv0.2.0App 0.47.0Apache-2.0Verified publisher

Run safe, scheduled etcd defragmentation in Kubernetes

About this chart

etcd-defrag

Deploys ahrtr/etcd-defrag as a Kubernetes CronJob.

The default configuration targets a kubeadm-style, stacked etcd cluster. It schedules the Pod on a control-plane node, reaches the local member over the host network, discovers all members, and defragments the leader last. Set tls.type to kubeadm (default), kubespray, rke2, or custom to select the host-side etcd PKI layout. Container mount paths are fixed.

The container runs as UID 0 by default because kubeadm commonly creates apiserver-etcd-client.key as 0600 root:root. The container otherwise drops all capabilities, disables privilege escalation, and uses a read-only root filesystem.

Usage

Prefer OCI:

helm install etcd-defrag oci://ghcr.io/jouve/charts/etcd-defrag --namespace kube-system

Charts pushed to oci:// are signed keyless with cosign and GitHub Actions OIDC:

cosign verify ghcr.io/jouve/charts/etcd-defrag:<version> \
  --certificate-identity-regexp 'https://github.com/jouve/charts/\.github/workflows/release\.yaml@.*' \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com

Or use the legacy repository:

helm repo add jouve https://jouve.github.io/charts/
helm install etcd-defrag jouve/etcd-defrag --namespace kube-system

For another PKI layout, select custom and provide all three host paths:

tls:
  type: custom
  custom:
    caCert: /custom/etcd/ca.crt
    clientCert: /custom/etcd/client.crt
    clientKey: /custom/etcd/client.key

Parameters

Global parameters

NameDescriptionValue
global.imageRegistryGlobal container image registry""
global.imagePullSecretsGlobal container registry secret names as an array[]

Common parameters

NameDescriptionValue
nameOverrideString to partially override common.names.name""
fullnameOverrideString to fully override common.names.fullname""
namespaceOverrideString to fully override common.names.namespace""
commonLabelsLabels to add to all deployed objects{}
commonAnnotationsAnnotations to add to all deployed objects{}

Image parameters

NameDescriptionValue
image.registryetcd-defrag image registryghcr.io
image.repositoryetcd-defrag image repositoryahrtr/etcd-defrag
image.tagetcd-defrag image tagv0.47.0
image.digestetcd-defrag image digest; overrides the image tag when set""
image.pullPolicyetcd-defrag image pull policyIfNotPresent
image.pullSecretsetcd-defrag image pull secrets[]

CronJob parameters

NameDescriptionValue
scheduleCron schedule17 3 * * *
timeZoneTime zone for the CronJob scheduleEtc/UTC
suspendSuspend subsequent executionsfalse
concurrencyPolicyConcurrent execution policyForbid
startingDeadlineSecondsDeadline in seconds for starting a missed execution300
successfulJobsHistoryLimitNumber of successful Jobs to retain3
failedJobsHistoryLimitNumber of failed Jobs to retain3
activeDeadlineSecondsMaximum duration of one Job in seconds600
backoffLimitNumber of retries before a Job is considered failed0
restartPolicyPod restart policyNever

etcd-defrag parameters

NameDescriptionValue
config.endpointsetcd endpoint URLs["https://127.0.0.1:2379"]
config.clusterDiscover and defragment every member of the clustertrue
config.compactionCompact etcd before defragmenting ittrue
config.continueOnErrorContinue with other endpoints after one endpoint failsfalse
config.moveLeaderMove leadership before defragmenting the leadertrue
config.waitBetweenDefragsDelay between consecutive defragmentation operations60s
config.commandTimeoutCommand timeout, excluding the dial timeout30s
config.dialTimeoutClient connection timeout2s
config.etcdStorageQuotaBytesetcd backend quota in bytes2147483648
config.defragRuleBoolean expression that selects members to defragmentdbSizeFree / dbSize >= 0.2
config.autoDisalarmAutomatically clear NOSPACE alarms after successful defragmentationfalse
config.disalarmThresholdDB-to-quota ratio below which NOSPACE alarms can be cleared0.9
extraArgsExtra arguments passed to etcd-defrag[]

TLS parameters

NameDescriptionValue
tls.typeTLS layout (kubeadm, kubespray, rke2 or custom)kubeadm
tls.custom.caCertHost path of the etcd CA certificate when tls.type is custom""
tls.custom.clientCertHost path of the etcd client certificate when tls.type is custom""
tls.custom.clientKeyHost path of the etcd client key when tls.type is custom""

Pod parameters

NameDescriptionValue
hostNetworkUse the host network to reach a local etcd endpointtrue
dnsPolicyPod DNS policyClusterFirstWithHostNet
podAnnotationsExtra annotations for Pods{}
podLabelsExtra labels for Pods{}
podSecurityContextPod security context{}
containerSecurityContextetcd-defrag container security context{}
resourcesPresetSet container resources according to a common preset (allowed values: none, nano, micro, small, medium, large, xlarge, 2xlarge); ignored when resources is setnano
resourcesSet container resource requests and limits{}
priorityClassNamePriority class assigned to the Pod""
nodeSelectorNode labels for Pod assignment{}
affinityAffinity rules for Pod assignment{}
tolerations[0].effectTaint effect tolerated on control-plane nodesNoSchedule
tolerations[0].keyControl-plane taint keynode-role.kubernetes.io/control-plane
tolerations[0].operatorToleration operator for the control-plane taintExists
extraEnvVarsExtra environment variables for the container[]
initContainersAdd additional init containers to the Pod[]
extraVolumesExtra volumes for the Pod[]
extraVolumeMountsExtra volume mounts for the container[]

ServiceAccount parameters

NameDescriptionValue
serviceAccount.createCreate a ServiceAccounttrue
serviceAccount.nameServiceAccount name; generated when empty and creation is enabled""
serviceAccount.annotationsAdditional ServiceAccount annotations{}
serviceAccount.automountServiceAccountTokenAutomount the ServiceAccount tokenfalse

Extra deployment parameters

NameDescriptionValue
extraDeployExtra Kubernetes objects to deploy with the release[]

Deploy etcd-defrag with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has etcd-defrag on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartetcd-defrag is pinned at v0.2.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply