Skip to content

etcd maintenance service#

To facilitate etcd maintenance, MKE 4 deploys the etcd maintenance host service on all controller nodes. You run maintenance operations through the etcd-maintenance subcommands on any controller node, as the root user:

Subcommand                            Description
etcd-maintenance status Prints the status of every etcd member, and whether a defragmentation is in progress, as JSON.
etcd-maintenance defrag Defragments every etcd member in turn.
etcd-maintenance cleanup Deletes expired Kubernetes events from etcd and compacts the database.

The binary is installed at /usr/local/bin/etcd-maintenance. Run it with its full path, as sudo does not search /usr/local/bin on some distributions, such as RHEL.

To configure the etcd maintenance service, edit the etcd section of the mke4.yaml configuration file:

etcd:
  maintenanceService:
    grpcPort: <desired_grpc_port>

The etcd maintenance services on the controller nodes communicate through the gRPC port, the default for which is port 5557. This communication requires a client certificate that is signed by the etcd CA.

Note

Starting with MKE 4.2.2, MKE 4 removes the HTTP API that the etcd maintenance service served on localhost:18088. Update any scripts that call this API, such as curl http://localhost:18088/cluster/status, to use the etcd-maintenance subcommands instead. The service no longer listens on port 18088, and the deprecated httpPort parameter has no effect.

The etcd maintenance service provides automated maintenance operations for the underlying etcd database in your cluster. Detailed in the table below, these operations serve to prevent etcd from running out of storage space and help maintain optimal cluster performance.

Operation                                                                      Detail
Kubernetes event cleanup and etcd compaction
  • Forwarding of cleanup to the etcd leader node.
  • Performance of all cleanup operations by the leader node.
  • A lock prevents concurrent cleanup operations.
etcd defragmentation
  • If enabled, runs automatically once the cleanup operation completes.
  • Processes etcd members in sequential order.
  • Pauses between members to avoid cluster disruption
  • A lock prevents concurrent defragmentation operations
Maintenance operations scheduling You can schedule the cleanup and compaction operation and the etcd defragmentation operation to run automatically at specific times.

The etcd maintenance service runs on all control plane nodes and ensures only one maintenance operation is run at a time.
Maintenance operations auditing The service records an audit entry for each defragmentation and cleanup operation it attempts, capturing when the operation ran and whether it succeeded. Auditing is always on.
Run etcdctl The etcdctl subcommand, which is a manual tool rather than an automated operation, runs etcdctl against the etcd instance on the local controller node, to locate the endpoint and TLS certificates.

Scheduled cluster backups also run through the etcd maintenance service and share its per-node operation lock, so a backup and a maintenance operation do not run at the same time on the same controller. Cluster-wide defragmentation is the exception: it acquires the lock only on the coordinating controller, not on the other controllers whose etcd members it defragments.

  • A scheduled backup waits for the lock for up to its 10-minute attempt window. If another operation still holds the lock, the service skips that run and retries at the next scheduled time.
  • Cleanup, defragmentation, and storage-quota recovery wait for the lock for up to 15 minutes. If another operation still holds the lock, the operation fails.

Best Practices

  • Set etcd maintenance to take place during periods of when cluster usage is minimal, such as weekends or early morning hours.
  • Run etcd maintenance at weekly or monthly intervals. The minimum allowed interval is 72 hours (3 days), and daily schedules are not permitted.
  • Enable both cleanup and defragmentation operations, to ensure optimal etcd health.
  • Monitor the first few maintenance runs to verify successful completion.
  • Set appropriate timeout intervals. Configure the defragTimeoutSeconds parameter based on your cluster size and etcd database size, taking into account that larger clusters may need longer timeout intervals.
  • Retain recent events with minTTLToKeepSeconds, as needed for troubleshooting. For insance, 86400 for 24 hours.