Scaling Up etcd Members
By default, Replicated PV Mayastor allows the creation of three etcd members. If you wish to increase the number of etcd replicas, you will encounter an error. However, you can make the necessary configuration changes discussed in this guide to make it work.
#
Overview of StatefulSetsStatefulSets are Kubernetes resources designed for managing stateful applications. They provide stable network identities and persistent storage for pods. StatefulSets ensure ordered deployment and scaling, support persistent volume claims, and manage the state of applications. They are commonly used for databases, messaging systems, and distributed file systems. Here is how StatefulSets function:
- For a StatefulSet with N replicas, when pods are deployed, they are created sequentially in order from {0..N-1}.
- When pods are deleted, they are terminated in reverse order from {N-1..0}.
- Before a scaling operation is applied to a pod, all of its predecessors must be running and ready.
- Before a pod is terminated, all of its successors must be completely shut down.
- Replicated PV Mayastor uses etcd database for persisting configuration and state information. Etcd is setup as a Kubernetes StatefulSet when Replicated PV Mayastor is installed.
Command
Output
note
Take a snapshot of the etcd. Refer to the Disaster Recovery documentation for more details.
- From etcd-0/1/2, we can see that all the values are registered in the database. Once we scale up etcd with "n" replicas, all the key-value pairs should be available across all the pods.
To scale up the etcd members, the following steps can be performed:
- Add a new etcd member
- Add a peer URL
- Create a PV (Persistent Volume)
- Validate key-value pairs
#
Step 1: Adding a New etcd Member (Scaling Up etcd Replica)To increase the number of replicas to 4, use the following kubectl scale
command:
Command
Output
The new pod will be created on available nodes but will be in a pending state as there is no PV/PVC created to bind the volumes.
Command
Output
#
Step 2: Add a New Peer URLBefore creating a PV, we need to add the new peer URL mayastor-etcd-3= and change the cluster's initial state from "new" to "existing" so that the new member will be added to the existing cluster when the pod comes up after creating the PV. Since the new pod is still in a pending state, the changes will not be applied to the other pods as they will be restarted in reverse order from {N-1..0}. It is expected that all of its predecessors must be running and ready.
Command
Output
#
Step 3: Create a Persistent VolumeCreate a PV with the following YAML. Change the pod name/claim name based on the pod's unique identity.
note
This is only for the volumes created with "manual" storage class.
YAML
Output
#
Step 4: Validate Key-Value PairsRun the following command from the new etcd pod and ensure that the values are the same as those in etcd-0/1/2. Otherwise, it indicates a data loss issue.
Command