|
| 1 | +# MariaDB Operator Upgrade Runbook |
| 2 | + |
| 3 | +This runbook describes the steps to upgrade the **MariaDB Operator** and perform backup/restore procedures in Kubernetes. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Pre-Upgrade Steps |
| 8 | + |
| 9 | +### 1. Backup current MariaDB configuration |
| 10 | + |
| 11 | +```bash |
| 12 | +kubectl get mariadb -A -o yaml > current-mariadb-config-backup-$(date +%Y%m%d).yaml |
| 13 | +``` |
| 14 | + |
| 15 | +### 2. Retrieve root password |
| 16 | + |
| 17 | +```bash |
| 18 | +export MARIADB_ROOT_PASSWORD=$(kubectl get secret mariadb -n openstack -o jsonpath='{.data.root-password}' | base64 -d) |
| 19 | +``` |
| 20 | + |
| 21 | +### 3. Assess database sizes and usage |
| 22 | + |
| 23 | +```bash |
| 24 | +kubectl exec -n openstack -it mariadb-0 -- mariadb -u root -p"$MARIADB_ROOT_PASSWORD" |
| 25 | +``` |
| 26 | + |
| 27 | +Run inside MariaDB shell: |
| 28 | + |
| 29 | +```sql |
| 30 | +SELECT |
| 31 | + table_schema AS 'Database', |
| 32 | + ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS 'Size_MB' |
| 33 | +FROM information_schema.tables |
| 34 | +WHERE table_schema NOT IN ('information_schema', 'performance_schema', 'mysql', 'sys') |
| 35 | +GROUP BY table_schema |
| 36 | +ORDER BY Size_MB DESC; |
| 37 | +``` |
| 38 | + |
| 39 | +### 4. Backup all databases |
| 40 | + |
| 41 | +```bash |
| 42 | +kubectl exec -n openstack -it mariadb-0 -- mariadb-dump -u root -p"$MARIADB_ROOT_PASSWORD" \ |
| 43 | + --single-transaction \ |
| 44 | + --routines \ |
| 45 | + --triggers \ |
| 46 | + --all-databases > full-backup-$(date +%Y%m%d-%H%M).sql |
| 47 | +``` |
| 48 | + |
| 49 | +### 5. Verify storage classes |
| 50 | + |
| 51 | +- StorageClass specified for MariaDB should exists |
| 52 | + |
| 53 | +```bash |
| 54 | +kubectl get storageclass |
| 55 | +``` |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +## Upgrade MariaDB Operator |
| 60 | + |
| 61 | +### 6. Update Mariadb Operator version |
| 62 | + |
| 63 | +- Edit operator reference in: |
| 64 | + [kustomization.yaml](https://github.com/rackerlabs/understack/blob/main/operators/mariadb-operator/kustomization.yaml) |
| 65 | + |
| 66 | +### 7. Perform the release |
| 67 | + |
| 68 | + [Release Process Documentation](https://docs.undercloud.rackspace.net/technical-documentation/release_process/#creating-an-understack-release) |
| 69 | + |
| 70 | +--- |
| 71 | + |
| 72 | +## Validate Upgrade |
| 73 | + |
| 74 | +### 8. Check applications in ArgoCD |
| 75 | + |
| 76 | +- **Dev:** |
| 77 | + - [ArgoCD Dev 1](https://argocd.dev.undercloud.rackspace.net) |
| 78 | + - [ArgoCD Dev 2](https://dev-argocd.pvceng.rax.io/) |
| 79 | + |
| 80 | +- **Staging / Prod:** |
| 81 | + - [ArgoCD](https://argocd.pvceng.rax.io/) |
| 82 | + |
| 83 | +Applications: |
| 84 | + |
| 85 | +- `<deploy-cluster>-mariadb-operator` (ex: `charlie-uc-iad3-staging-mariadb-operator`) |
| 86 | +- `<deploy-cluster>-openstack` (ex: `charlie-uc-iad3-staging-openstack`) |
| 87 | + |
| 88 | +### 9. Check logs in MariaDB StatefulSet |
| 89 | + |
| 90 | +```bash |
| 91 | +kubectl logs -n openstack statefulset/mariadb -f |
| 92 | +``` |
| 93 | + |
| 94 | +### 10. Check logs in MariaDB Operator |
| 95 | + |
| 96 | +```bash |
| 97 | +kubectl logs -n mariadb-operator deployment/mariadb-operator -f |
| 98 | +``` |
| 99 | + |
| 100 | +--- |
| 101 | + |
| 102 | +## Emergency Cleanup |
| 103 | + |
| 104 | +If you encounter **volume mount issues**: |
| 105 | + |
| 106 | +```bash |
| 107 | +kubectl patch mariadb mariadb -n openstack --type='merge' -p='{"metadata":{"finalizers":[]}}' |
| 108 | +kubectl delete mariadb mariadb -n openstack |
| 109 | +kubectl delete pvc -n openstack -l app.kubernetes.io/name=mariadb --wait=false |
| 110 | +``` |
| 111 | + |
| 112 | +--- |
| 113 | + |
| 114 | +## Restore Procedure |
| 115 | + |
| 116 | +### 11. Get new root password |
| 117 | + |
| 118 | +```bash |
| 119 | +export MARIADB_ROOT_PASSWORD=$(kubectl get secret mariadb -n openstack -o jsonpath='{.data.root-password}' | base64 -d) |
| 120 | +``` |
| 121 | + |
| 122 | +### 12. Restore from backup if volumes has been deleted |
| 123 | + |
| 124 | +```bash |
| 125 | +kubectl exec -i -n openstack mariadb-0 -- mariadb -u root -p"$MARIADB_ROOT_PASSWORD" < full-backup-production-20250910-0735.sql |
| 126 | +``` |
| 127 | + |
| 128 | +### 13. Re-check database sizes |
| 129 | + |
| 130 | +```bash |
| 131 | +kubectl exec -n openstack -it mariadb-0 -- mariadb -u root -p"$MARIADB_ROOT_PASSWORD" |
| 132 | +``` |
| 133 | + |
| 134 | +Run SQL again: |
| 135 | + |
| 136 | +```sql |
| 137 | +SELECT |
| 138 | + table_schema AS 'Database', |
| 139 | + ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS 'Size_MB' |
| 140 | +FROM information_schema.tables |
| 141 | +WHERE table_schema NOT IN ('information_schema', 'performance_schema', 'mysql', 'sys') |
| 142 | +GROUP BY table_schema |
| 143 | +ORDER BY Size_MB DESC; |
| 144 | +``` |
| 145 | + |
| 146 | +--- |
| 147 | + |
| 148 | +## Post-Upgrade Connectivity Check |
| 149 | + |
| 150 | +### 14. Test Galera peer connectivity |
| 151 | + |
| 152 | +```bash |
| 153 | +kubectl exec mariadb-0 -n openstack -- timeout 5 bash -c "echo > /dev/tcp/mariadb-1.mariadb-internal.openstack.svc.cluster.local/4567" && echo "mariadb-1 reachable" || echo "mariadb-1 not reachable" |
| 154 | + |
| 155 | +kubectl exec mariadb-0 -n openstack -- timeout 5 bash -c "echo > /dev/tcp/mariadb-2.mariadb-internal.openstack.svc.cluster.local/4567" && echo "mariadb-2 reachable" || echo "mariadb-2 not reachable" |
| 156 | +``` |
| 157 | + |
| 158 | +--- |
| 159 | + |
| 160 | +## End of Runbook |
0 commit comments