Version v3.7.0 of the documentation is no longer actively maintained. The site that you are currently viewing is an archived snapshot. For up-to-date documentation, see the latest version.
Administration
Here are some administration SOP for etcd:
- Create Cluster
- Remove Cluster
- CLI Environment
- Reload Config
- Management Scripts
- Append Member
- Remove Member
Check ETCD: FAQ for more questions.
Create Cluster
To create an etcd cluster, define the etcd cluster in inventory first:
Then run the etcd.yml playbook.
If there’s an existing etcd cluster, this playbook will update the config and restart all the etcd instances
Pigsty has a safeguard mechanism to prevent accidental purge. etcd_safeguard is false by default,
For provisioned etcd cluster in prod env, you can enable safeguard to prevent accidental clean.
Since Pigsty v3.6+, the etcd.yml playbook and etcd role are focused solely on cluster installation and member addition. All removal operations have been moved to the dedicated etcd-rm.yml playbook using the etcd_remove role.
Remove Cluster
To remove an existing etcd cluster, you can use the dedicated etcd-rm.yml:
If the etcd_safeguard is set to true, the playbook will abort.
CLI Environment
Pigsty use etcd v3 API by default. (v2 support is dropped since v3.6.0)
Here’s an example of client environment config.
You can do CRUD with the following commands after setting up the envs:
Reload Config
In case of permanent etcd cluster membership changes, You’ll have to refresh the 4 etcd endpoints references:
- config file of existing etcd members and client env var
- patroni dcs endpoint config
- vip-manager dcs endpoint config
To refresh etcd config file /etc/etcd/etcd.conf on existing members and client env vars:
Update patroni reference to etcd endpoints:
Update vip-manager reference to etcd endpoints (if you are using PGSQL L2 VIP):
Append Member
ETCD Reference: Add a member
Pigsty can perform etcd cluster expansion with bin/etcd-add script or the etcd.yml playbook.
You can add new members to existing etcd cluster in 5 steps:
- issue
etcdctl member addcommand to tell existing cluster that a new member is coming (use learner mode) - update inventory group
etcdwith new instance - init the new member with
etcd_init=existing, to join the existing cluster rather than create a new one (VERY IMPORTANT) - promote the new member from leaner to follower
- update etcd endpoints reference with reload-config
Manual Approach
Automated Approach (Recommended)
Use the bin/etcd-add script to simplify the process:
The etcd-add script will:
- Validate IP addresses
- Execute the etcd.yml playbook with appropriate parameters
- Provide safety warnings and countdown timers
- Guide you through post-operation configuration updates
Remove Member
To remove a member from existing etcd cluster, you have two approaches:
Automated Approach (Recommended)
Use the bin/etcd-rm script for simplified removal:
Or use the dedicated removal playbook:
Manual Approach
For manual removal, it usually takes 3 steps:
- remove/uncomment it from inventory and reload config
- remove it with
etcdctl member remove <server_id>command and kick it out of the cluster - use the etcd-rm.yml playbook to clean up the instance
Removal Parameters
The etcd_remove role supports several configuration options:
etcd_safeguard=true: Prevents accidental removaletcd_rm_data=true: Removes etcd data directories (default: true)etcd_rm_pkg=false: Uninstalls etcd packages (default: false)
Example with custom parameters: