Upgrading Longhorn Manager

Upgrading from v1.3.x (< v1.3.1) or v1.2.x

We only support upgrading to v1.3.1 from v1.3.x or v1.2.x. For other versions, please upgrade to v1.3.x or v1.2.x first.

Engine live upgrade is supported from v1.3.x or v1.2.x to v1.3.1.

For airgap upgrades when Longhorn is installed as a Rancher app, you will need to modify the image names and remove the registry URL part.

For example, the image registry.example.com/longhorn/longhorn-manager:v1.3.1 is changed to longhorn/longhorn-manager:v1.3.1 in Longhorn images section. For more information, see the air gap installation steps here.

Preparing for the Upgrade

If Longhorn was installed using a Helm Chart, or if it was installed as Rancher catalog app, check to make sure the parameters in the default StorageClass weren’t changed. Changing the default StorageClass’s parameter might result in a chart upgrade failure. if you want to reconfigure the parameters in the StorageClass, you can copy the default StorageClass’s configuration to create another StorageClass.

  1. The current default StorageClass has the following parameters:
  2. parameters:
  3. numberOfReplicas: <user specified replica count, 3 by default>
  4. staleReplicaTimeout: "30"
  5. fromBackup: ""
  6. baseImage: ""

Upgrade

Prerequisite: Always back up volumes before upgrading. If anything goes wrong, you can restore the volume using the backup.

Upgrade as a Rancher Catalog App

To upgrade the Longhorn App, make sure which Rancher UI the existing Longhorn App was installed with. There are two Rancher UIs, one is the Cluster Manager (old UI), and the other one is the Cluster Explorer (new UI). The Longhorn App in different UIs considered as two different applications by Rancher. They cannot upgrade to each other. If you installed Longhorn in the Cluster Manager, you need to use the Cluster Manager to upgrade Longhorn to a newer version, and vice versa for the Cluster Explorer.

Different Rancher UIs screenshots.

  • The Cluster Manager (old UI)

    Upgrading Longhorn Manager - 图1

  • The Cluster Explorer (new UI)

    Upgrading Longhorn Manager - 图2

Upgrade with Kubectl

To upgrade with kubectl, run this command:

  1. kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.3.1/deploy/longhorn.yaml

Upgrade with Helm

To upgrade with Helm, run this command:

  1. helm upgrade longhorn longhorn/longhorn --namespace longhorn-system --version 1.3.1

On Kubernetes clusters managed by Rancher 2.1 or newer, the steps to upgrade the catalog app longhorn-system are the similar to the installation steps.

Then wait for all the pods to become running and Longhorn UI working. e.g.:

  1. $ kubectl -n longhorn-system get pod
  2. NAME READY STATUS RESTARTS AGE
  3. csi-attacher-78bf9b9898-mb7jt 1/1 Running 1 3m11s
  4. csi-attacher-78bf9b9898-n2224 1/1 Running 1 3m11s
  5. csi-attacher-78bf9b9898-rhv6m 1/1 Running 1 3m11s
  6. csi-provisioner-8599d5bf97-dr5n4 1/1 Running 1 2m58s
  7. csi-provisioner-8599d5bf97-drzn9 1/1 Running 1 2m58s
  8. csi-provisioner-8599d5bf97-rz5fj 1/1 Running 1 2m58s
  9. csi-resizer-586665f745-5bkcm 1/1 Running 0 2m49s
  10. csi-resizer-586665f745-vgqx8 1/1 Running 0 2m49s
  11. csi-resizer-586665f745-wdvdg 1/1 Running 0 2m49s
  12. engine-image-ei-62c02f63-bjfkp 1/1 Running 0 14m
  13. engine-image-ei-62c02f63-nk2jr 1/1 Running 0 14m
  14. engine-image-ei-62c02f63-pjtgg 1/1 Running 0 14m
  15. engine-image-ei-ac045a0d-9bbb8 1/1 Running 0 3m46s
  16. engine-image-ei-ac045a0d-cqvv2 1/1 Running 0 3m46s
  17. engine-image-ei-ac045a0d-wzmhv 1/1 Running 0 3m46s
  18. instance-manager-e-4deb2a16 1/1 Running 0 3m23s
  19. instance-manager-e-5526b121 1/1 Running 0 3m28s
  20. instance-manager-e-eff765b6 1/1 Running 0 2m59s
  21. instance-manager-r-3b70b0db 1/1 Running 0 3m27s
  22. instance-manager-r-4f7d629a 1/1 Running 0 3m22s
  23. instance-manager-r-bbcf4f17 1/1 Running 0 2m58s
  24. longhorn-csi-plugin-bkgjj 2/2 Running 0 2m39s
  25. longhorn-csi-plugin-tjhhq 2/2 Running 0 2m39s
  26. longhorn-csi-plugin-zslp6 2/2 Running 0 2m39s
  27. longhorn-driver-deployer-75b6bf4d6d-d4hcv 1/1 Running 0 3m57s
  28. longhorn-manager-4j77v 1/1 Running 0 3m53s
  29. longhorn-manager-cwm5z 1/1 Running 0 3m50s
  30. longhorn-manager-w7scb 1/1 Running 0 3m50s
  31. longhorn-ui-8fcd9fdd-qpknp 1/1 Running 0 3m56s

Next, upgrade Longhorn engine.

Post upgrade

To avoid crashing existing volumes, as well as switch from the deprecated setting Guaranteed Engine CPU to the new instance manager CPU reservation mechanism, Longhorn will automatically set Engine Manager CPU Request and Replica Manager CPU Request from each node based on the deprecated setting value during upgrade. Then, the new global instance manager CPU settings Guaranteed Engine Manager CPU and Guaranteed Replica Manager CPU won’t take effect. You may need to check the new mechanism and the setting descriptions to see if you need any adjustments.

TroubleShooting

Error: "longhorn" is invalid: provisioner: Forbidden: updates to provisioner are forbidden.

  • This means there are some modifications applied to the default storageClass and you need to clean up the old one before upgrade.

  • To clean up the deprecated StorageClass, run this command:

    1. kubectl delete -f https://raw.githubusercontent.com/longhorn/longhorn/v1.3.1/examples/storageclass.yaml