- Encrypting data at rest
- Encrypting data in transit
- Backup and disaster recovery
1. Encrypting Data at Rest
By default, etcd writes plaintext data to disk. To safeguard sensitive objects—such as Secrets—enable Kubernetes’ built-in EncryptionConfiguration.Step 1. Create an EncryptionConfiguration
Save the following manifest asencryption-config.yaml:
aescbcuses AES-CBC. Replace<base64-encoded-encryption-key>with a 32-byte Base64 key.identityleaves data unencrypted as a fallback. |
Run the following command to create a 32-byte random key:Copy the output into your
encryption-config.yaml.Step 2. Update the Etcd Static Pod
Modify/etc/kubernetes/manifests/etcd.yaml to include the provider config:
2. Encrypting Data in Transit
Protect etcd client-to-server and peer-to-peer communication with TLS certificates.Step 1. Provision Certificates
You need:- CA certificate (
ca.crt) - Server cert/key (
etcd-server.crt,etcd-server.key) - Peer cert/key (
etcd-peer.crt,etcd-peer.key) - Client cert/key (
etcd-client.crt,etcd-client.key)
Step 2. Configure TLS Flags
Extend your etcd manifest:Monitor your certificates’ expiration dates. Expired certificates break cluster communication and can cause downtime.
3. Backup and Disaster Recovery
Regular snapshots of etcd are essential for restoring cluster state in case of data loss or corruption.Taking a Snapshot
Schedule snapshots via cron or your preferred scheduler. Store backups in a secure, offsite location.
Summary
Securing etcd involves:- Encryption at Rest
UseEncryptionConfigurationto encrypt Secrets (and other resources) on disk. - Encryption in Transit
Enforce TLS for all client and peer connections. - Regular Backups
Automateetcdctl snapshotto maintain up-to-date backups.