0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Tanzu PackagesでデプロイされたAppのStatefulSetのPVを拡張する

Posted at

Tanzu PackagesでHarborのようなStatefulSetを持つAppをデプロイ後、StatefulSetのPVのサイズを変更しようとすると以下のようなエラーになる。

$ kubectl describe app -n my-packages harbor
:(省略)
    API server says:
      StatefulSet.apps "harbor-database" is invalid: spec:
        Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', 'updateStrategy', 'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds' are forbidden (reason: Invalid)

これはStatefulSetがPVCのサイズの変更を許可していないためである。
このエラーが発生した際は、以下のように対処する。

1.PVCのサイズをvalues.yamlの値と合わせる

values.yamlで例えば2Giに変更した場合、以下のようにPVCも2Giに変更する。

$ kubectl edit pvc database-data-harbor-database-0 -n tanzu-system-registry
:(省略)
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi

2.StatefulSetをOrphanで削除する。

kubectl deleteを実行する際、通常親リソースを削除すると子リソースも削除されるが、--cascade=orphanをつけると親リソースのみ削除できる。
これを使って稼働中のPodを止めずにStatefulSetのみ更新する。

$ kubectl delete sts --cascade=orphan -n tanzu-system-registry harbor-database

3.Appリソースのリコンサイルを待つ(もしくはspec.paused=trueを設定する)

リコンサイルが完了すれば、エラー状態が解消されてPVが正常に拡張出来る。

$ kubectl exec -it harbor-database-0 -c database -- df -h |grep postgres
/dev/sdc        2.0G   65M  1.8G   4% /var/lib/postgresql/data
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?