hashicorp / consul-k8s

First-class support for Consul Service Mesh on Kubernetes
https://www.consul.io/docs/k8s
Mozilla Public License 2.0
670 stars 324 forks source link

How to update consul storage without lost existing data #1260

Closed diwangca closed 2 years ago

diwangca commented 2 years ago

Question

We use Consul as the Vault backend and deploy consul by Helm Chart. In consul helm chart value file, 10G is the default size for consul server storage. We already have consul deployed and have data in it, and we want to resize the storage to 200G. How can we update this storage size without losing data? Directly change it in values file and upgrade release is forbidden

CLI Commands (consul-k8s, consul-k8s-control-plane, helm)

$ helm upgrade consul live/infra2/consul-helm/ -n vault -f live/infra2/helm-values/helm-values-consul.yaml
Error: UPGRADE FAILED: cannot patch "consul-server" with kind StatefulSet: StatefulSet.apps "consul-server" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', and 'updateStrategy' are forbidden

Helm Configuration

$ git diff
diff --git a/live/infra2/helm-values/helm-values-consul.yaml b/live/infra2/helm-values/helm-values-consul.yaml
index 66b1a48..87d86cf 100644
--- a/live/infra2/helm-values/helm-values-consul.yaml
+++ b/live/infra2/helm-values/helm-values-consul.yaml
@@ -10,7 +10,7 @@ server:
   enabled: true
   replicas: 3
   bootstrapExpect: 3 # Should <= replicas count
-  storage: 10Gi
+  storage: 200Gi
   storageClass: encrypted-gp2
   connect: true
   resources:

Logs

Current understanding and Expected behavior

Environment details

Additional Context

diwangca commented 2 years ago

found solution https://kubernetes.io/blog/2022/05/05/volume-expansion-ga/