MySQL Replication
Use replication for read scaling and recovery.
MySQL replication writes to a primary and replays changes on replicas so reads can be offloaded.
Key ideas
- Primary writes and generates binlog
- Replicas pull and replay the binlog
- Stable network identity matters
In Kubernetes
- StatefulSet keeps instance order
- Headless Service provides stable DNS
- Separate read/write Services if needed
Risks
- Replication lag can break consistency
- Primary failure needs a failover plan
Practical notes
- Start with a quick inventory:
kubectl get nodes,kubectl get pods -A, andkubectl get events -A. - Compare desired vs. observed state;
kubectl describeusually explains drift or failed controllers. - Keep names, labels, and selectors consistent so Services and controllers can find Pods.
Quick checklist
- The resource matches the intent you described in YAML.
- Namespaces, RBAC, and images are correct for the target environment.
- Health checks and logs are in place before promotion.