nats-io / k8s

NATS on Kubernetes with Helm Charts
Apache License 2.0
456 stars 305 forks source link

Cannot upgrade helm release with jetstream #723

Closed boskiv closed 1 year ago

boskiv commented 1 year ago
helm install my-nats nats/nats

make a value file

nats:
  jetstream:
    enabled: true

upgrade release

helm upgrade my-nats -f values.yaml nats/nats

got an error

❯ helm upgrade my-nats -f values nats/nats
Error: UPGRADE FAILED: cannot patch "my-nats" with kind StatefulSet: StatefulSet.apps "my-nats" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordinals', 'template', 'updateStrategy', 'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds' are forbidden

P.S. If I install helm with values from scratch no error and jetstream works as expected

caleblloyd commented 1 year ago

What version are you upgrading from, and what version are you upgrading to?

If you are updating from 0.x to 1.x-beta.x there is not a clean upgrade path yet, as noted in the 1.x-beta.x README.md:

Beta Notice: This branch contains the nats 1.x Helm Chart Beta. The values.yaml format has changed significantly from 0.x, and upgrading from 0.x -> 1.x is not straightforward. At this time, we are recommending only new installations using the 1.x Beta chart. We will be developing an upgrade path from 0.x -> 1.x (captured by ) prior to launching 1.x GA.

caleblloyd commented 1 year ago

Otherwise if you are upgrading the same version and enabling jetstream or a resolver, those both add to volumeClaimTemplates in the stateful set. In k8s that field is immutable so you have to do a migration or a workaround.

boskiv commented 1 year ago

Yes, i'm doing an upgrade the same version chart.

caleblloyd commented 1 year ago

The immutable fields in a Stateful Set are a k8s limitation, there is nothing we can do about them. There are 2 options: