|
| 1 | +## run a mysql application consistent snapshot demo |
| 2 | + |
| 3 | +#### 0. have px cluster up & running |
| 4 | + |
| 5 | +#### 1. apply mysql namespace & application |
| 6 | + |
| 7 | +``` |
| 8 | +kubectl apply -f /assets/mysql/mysql.yml |
| 9 | +``` |
| 10 | + |
| 11 | +#### 2. check for mysql pod readiness |
| 12 | + |
| 13 | +``` |
| 14 | +kubectl wait --for=condition=ready pod -l app=mysql -n mysql |
| 15 | +``` |
| 16 | + |
| 17 | +#### 3. apply demo data |
| 18 | + |
| 19 | +``` |
| 20 | +POD=$(kubectl get pods -n mysql -l app=mysql -ojson | jq -r '.items[0].metadata.name') |
| 21 | +``` |
| 22 | + |
| 23 | +``` |
| 24 | +kubectl exec $POD -n mysql -it -- /bin/mysql -u mysql -psupermysql < /assets/mysql/sample-data.sql |
| 25 | +``` |
| 26 | + |
| 27 | +#### 4. check for data within DB |
| 28 | + |
| 29 | +``` |
| 30 | +kubectl exec $POD -n mysql -it -- /bin/mysql -u mysql -psupermysql pxdemo -e 'SELECT * FROM users' |
| 31 | +``` |
| 32 | + |
| 33 | +#### 5. apply pre/post rules |
| 34 | + |
| 35 | +``` |
| 36 | +kubectl apply -f /assets/mysql/px-mysql-pre-rule.yml |
| 37 | +
|
| 38 | +kubectl apply -f /assets/mysql/px-mysql-post-rule.yml |
| 39 | +``` |
| 40 | + |
| 41 | +#### 6. run snapshot |
| 42 | + |
| 43 | +``` |
| 44 | +kubectl apply -f /assets/mysql/snapshot.yml |
| 45 | +``` |
| 46 | + |
| 47 | +#### 7. validate snapshot |
| 48 | + |
| 49 | +``` |
| 50 | +kubectl get volumesnapshot.volumesnapshot.external-storage.k8s.io/mysql-snap -n mysql -oyaml |
| 51 | +``` |
| 52 | + |
| 53 | +(optionally follow stork pod logs) |
| 54 | + |
| 55 | +#### 8. delete table |
| 56 | + |
| 57 | +``` |
| 58 | +kubectl exec $POD -n mysql -it -- /bin/mysql -u mysql -psupermysql pxdemo -e 'DROP TABLE users; SHOW TABLES' |
| 59 | +``` |
| 60 | + |
| 61 | +#### 9. run snapshot restore |
| 62 | + |
| 63 | +``` |
| 64 | +kubectl apply -f /assets/mysql/restore-snap.yml |
| 65 | +``` |
| 66 | + |
| 67 | +check status |
| 68 | + |
| 69 | +``` |
| 70 | +kubectl get volumesnapshotrestore.stork.libopenstorage.org/mysql-snap-inrestore -n mysql -o yaml |
| 71 | +``` |
| 72 | + |
| 73 | +(wait for status successful) |
| 74 | + |
| 75 | +#### 10. validate data restore |
| 76 | + |
| 77 | +check for mysql pod readiness |
| 78 | + |
| 79 | +``` |
| 80 | +kubectl wait --for=condition=ready pod -l app=mysql -n mysql |
| 81 | +``` |
| 82 | + |
| 83 | +update pod name variable |
| 84 | + |
| 85 | +``` |
| 86 | +POD=$(kubectl get pods -n mysql -l app=mysql -ojson | jq -r '.items[0].metadata.name') |
| 87 | +``` |
| 88 | + |
| 89 | +``` |
| 90 | +kubectl exec $POD -n mysql -it -- /bin/mysql -u mysql -psupermysql pxdemo -e 'SELECT * FROM users' |
| 91 | +``` |
0 commit comments