How do you do rolling operations on stateful clusters (databases, Kafka, etcd)?
AdvancedProductionRolling Updates, Delegation and Safe Deployments
Answer
One node at a time with serial: 1, and in the right order: replicas or followers first, leader last. Before each node verify cluster health (all replicas in sync, quorum intact), drain or step down the node, make the change, wait for it to rejoin and catch up, and only then move on.
- hosts: kafka
serial: 1
any_errors_fatal: true
tasks:
- ansible.builtin.include_tasks: assert_cluster_healthy.yml
- ansible.builtin.include_tasks: upgrade_broker.yml
- ansible.builtin.include_tasks: wait_for_isr.yml
Use any_errors_fatal so one failing node halts the whole operation. Test the procedure on a staging cluster, and take backups or snapshots first.
More on Rolling Updates, Delegation and Safe Deployments
How do you do a rolling update with Ansible?BeginnerWhat forms can `serial` take?IntermediateShow the standard pattern for a zero-downtime rolling deploy behind a load balancer.IntermediateWhy do you add a health check inside the deployment play?BeginnerHow do `any_errors_fatal` and `max_fail_percentage` help a rollout?BeginnerHow do you do a canary deployment?Intermediate