Intro
Longhorn can be upgraded with modified Storage Class.
Related Issue
https://github.com/longhorn/longhorn/issues/1527
Test steps:
Kubectl apply -f
- Install Longhorn v1.0.2
kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.0.2/deploy/longhorn.yaml
- Create a statefulset using
longhorn
storageclass for PVCs. Set the scale to 1. - Observe that there is a workload pod (
pod-1
) is using 1 volume (vol-1
) with 3 replicas. - In Longhorn repo, on
master
branch. ModifynumberOfReplicas: "1"
inhttps://raw.githubusercontent.com/longhorn/longhorn/master/deploy/longhorn.yaml
. Upgrade Longhorn to master by runningkubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/longhorn.yaml
- Verify that
longhorn
storage class now has the fieldnumberOfReplicas: 1
. - Scale up the deployment to 2. Verify that:
pod-1
is using volumevol-1
with 3 replicas.pod-2
is using volumevol-2
with 1 replica.
- Scale up the deployment to 0 then back to 2. Verify that:
pod-1
is using volumevol-1
with 3 replicas.pod-2
is using volumevol-2
with 1 replica.
Helm
-
Follow this instruction to install Longhorn v1.0.2 using Helm https://longhorn.io/docs/1.0.2/deploy/install/install-with-helm/#installing-longhorn
-
Create a statefulSet using
longhorn
storage class for PVCs. Set the scale to 1. -
Observe that there is a workload pod (
pod-1
) is using 1 volume (vol-1
) with 3 replicas. -
Clone the longhorn chart in local system and checkout to Longhorn repo, upgrade Longhorn to the master version by running:
helm upgrade longhorn chart/ -n longhorn-system --set persistence.defaultClassReplicaCount=1,image.longhorn.manager.tag=master
-
Verify that no error occurs.
-
Verify that
longhorn
storage class now has the fieldnumberOfReplicas: 1
. -
Scale up the deployment to 2. Verify that:
pod-1
is using volumevol-1
with 3 replicas.pod-2
is using volumevol-2
with 1 replica.
-
Scale up the deployment to 0 then back to 2. Verify that:
pod-1
is using volumevol-1
with 3 replicas.pod-2
is using volumevol-2
with 1 replica.
-
Upgrade Longhorn again by running:
helm upgrade longhorn chart/ -n longhorn-system --set persistence.defaultClassReplicaCount=2,image.longhorn.manager.tag=master
-
Verify that no error occurs.
-
Verify that
longhorn
storage class now has the fieldnumberOfReplicas: 2
. -
Scale up the deployment to 3. Verify that:
pod-1
is using volumevol-1
with 3 replicas.pod-2
is using volumevol-2
with 1 replica.pod-3
is using volumevol-3
with 2 replicas.
-
See the current Longhorn release’s
revision
:helm list -n longhorn-system
-
Rollback to the previous version by:
helm rollback longhorn <REVISION - 1> -n longhorn-system
-
Verify that no error occurs.
-
Verify that
longhorn
storage class now has the fieldnumberOfReplicas: 1
. -
Scale up the deployment to 4. Verify that:
pod-1
is using volumevol-1
with 3 replicas.pod-2
is using volumevol-2
with 1 replica.pod-3
is using volumevol-3
with 2 replicas.pod-4
is using volumevol-4
with 1 replicas.
-
Rollback to the very first version by:
helm rollback longhorn 1 -n longhorn-system
-
See the error:
Error: no StorageClass with the name "longhorn" found
This is because the Longhorn master version already replaced the initial
longhorn
storage class by a different version. Users have to manually deletelonghorn
storage class before they can rollback. In the future (e.g. when upgrade/rollback between v.1.1 +) this issue will not happen because the versions after v1.1+ we don’t use Helm template forlonghorn
storage class
Rancher UI
- Install Longhorn v1.0.2 using the rancher app catalog.
- Create a statefulSet using
longhorn
storage class for PVCs. Set the scale to 1. - Observe that there is a workload pod (
pod-1
) is using 1 volume (vol-1
) with 3 replicas. - From Rancher UI, upgrade the chart to v1.1.0. In the upgrading UI, change parameter
Default Storage Class Replica Count: 1
before clicking Save - Verify that no error occurs.
- Verify that
longhorn
storage class now has the fieldnumberOfReplicas: 1
. - Scale up the deployment to 2. Verify that:
pod-1
is using volumevol-1
with 3 replicas.pod-2
is using volumevol-2
with 1 replica.