StatefulSet consists of serviceName, replicas, template and volumeClaimTemplates:
* serviceName is “mysql”, headless service we created in previous section
* replicas is 3, the desired number of pod
* template is the configuration of pod
* volumeClaimTemplates is to claim volume for pod based on storageClassName,
mysql-gp2 that we created in the Define Storageclass section.
Percona Xtrabackup is used in the template to clone source MySQL server to its followers.
Copy/Paste the following commands into your Cloud9 Terminal.
cd ~/environment/templates wget https://eksworkshop.com/beginner/170_statefulset/statefulset.files/mysql-statefulset.yml
StatefulSet “mysql” by following command.
kubectl create -f ~/environment/templates/mysql-statefulset.yml
Watch the status of
kubectl -n mysql rollout status statefulset mysql
It will take few minutes for pods to initialize and have
Open another Cloud9 Terminal and watch the progress of pods creation using the following command.
kubectl -n mysql get pods -l app=mysql --watch
You can see ordered, graceful deployment with a stable, unique name for each pod.
Press Ctrl+C to stop watching.
Check the dynamically created PVC by following command.
kubectl -n mysql get pvc -l app=mysql
We can see
data-mysql-2 have been created with the STORAGECLASS
And now the same information from the EC2 console.
We can see the EBS volumes have been automatically encrypted by the AWS Key Management Service (KMS)