Resizing PVC(MySQL)

mysql用PVCを拡張する。

chartファイルのprimary:persistence:sizeを変更して、helm upgradeするだけだとエラーになる。

helm upgrade mysql bitnami/mysql --version "8.8.18" --namespace mysql -f ./mysql-values.yml
Error: UPGRADE FAILED: cannot patch "mysql" with kind StatefulSet: StatefulSet.apps "mysql" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', and 'updateStrategy' are forbidden

調べたところ、statefulset削除・kubectl edit pvc…が必要みたい。

拡張手順

statefulsetの削除

kubectl -n mysql delete sts --cascade=orphan mysql

kubectl editでPVCサイズ拡張

kubectl -n mysql edit pvc data-mysql-0

spec:resources:storageを変更

spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 4Gi
  storageClassName: do-block-storage
  volumeMode: Filesystem
  volumeName: pvc-c04e1f94-4dc7-4e91-b144-a6ab8b78b5fe

helm chart(primary:persistence:size)変更

primary:
  persistence:
    enabled: true
    size: 4Gi

helm upgrade

 helm upgrade mysql bitnami/mysql --reuse-values --namespace mysql -f ./mysql-values.yml

pvcステータス確認、CAPACITYが4Giになっている。

kubectl -n mysql get pvc
NAME           STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS       AGE
data-mysql-0   Bound    pvc-c04e1f94-4dc7-4e91-b144-a6ab8b78b5fe   4Gi        RWO            do-block-storage   10d

DigtitalOcean Volumeステータス確認、Sizeが4GiBになっている。

doctl compute volume ls pvc-c04e1f94-4dc7-4e91-b144-a6ab8b78b5fe
ID                                      Name                                        Size     Region    Filesystem Type    Filesystem Label    Droplet IDs    Tags
3a9db381-630b-11ec-913e-0a58ac14a2d7    pvc-c04e1f94-4dc7-4e91-b144-a6ab8b78b5fe    4 GiB    sgp1      ext4                                   [278908628]    k8s:38b25270-16ca-4cea-b545-886b87cb9bc9

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です