Upgrade StorageOS

Procedure to upgrade a StorageOS v2 Cluster

This document details a step-by-step procedure to upgrade a StorageOS v2 cluster.

Keep in mind that upgrading a cluster will require minor downtime of applications using StorageOS volumes. However we will take steps to minimize the required downtime as much as possible.

Upgrade StorageOS

Ensure that you have read the PIDs prerequisite introduced in StorageOS v2.3 and that you check the init container logs to ensure your environments PID limits are set correctly.

Warning: To reduce downtime, it is recommended to docker pull the new StorageOS container image storageos/node:v2.4.4 on the nodes beforehand so that the cluster spins up faster!

  1. First make sure you keep a backup of all the StorageOS yaml files. You can reuse the StorageOSCluster configuration file to easily upgrade your cluster. You can also backup the Statefulset yaml files to keep track of the replicas.

    kubectl get pod -n storageos-operator -o yaml > storageos_operator.yaml
    kubectl get storageoscluster -n storageos-operator -o yaml > storageos_cr.yaml
    kubectl get statefulset --all-namespaces > statefulset-sizes.yaml

    Note: If the storageos-api secret was created in the storageos-operator namespace then it will be deleted when the operator is deleted. In this case it will be necessary to recreate the StorageOS API Secret.

    # Back up the StorageOS API Secret
    SECRET_NAME=$(kubectl get storageoscluster -A -o=jsonpath='{.items[0].spec.secretRefName}')
    SECRET_NAMESPACE=$(kubectl get storageoscluster -A -o=jsonpath='{.items[0].spec.secretRefNamespace}')
    kubectl get secret -n $SECRET_NAMESPACE $SECRET_NAME -oyaml > /tmp/storageos-api-secret.yaml
  2. Scale all stateful applications that use StorageOS volumes to 0.

  3. Delete the StorageOSCluster CR.

    CLUSTER_NAME=$(kubectl get storageoscluster -A -o=jsonpath='{.items[0].metadata.name}')
    CLUSTER_NAMESPACE=$(kubectl get storageoscluster -A -o=jsonpath='{.items[0].metadata.namespace}')
    kubectl delete storageoscluster $CLUSTER_NAME -n $CLUSTER_NAMESPACE

    If you have renamed the StorageOSCluster resource you can find it by using the command below.

    kubectl get storageoscluster --all-namespaces
  4. Deploy the new operator.

    # Do not apply the yaml resources. It requires a deletion and posterior creation
    CURRENT_VERSION=$(kubectl -n storageos-operator get pod -o=jsonpath='{.items[0].spec.containers[0].image}' | cut -d':' -f2)
    kubectl delete -f https://github.com/storageos/cluster-operator/releases/download/${CURRENT_VERSION}/storageos-operator.yaml
    # Wait until the resources are deleted
    kubectl create -f https://github.com/storageos/cluster-operator/releases/download/v2.4.4/storageos-operator.yaml

    Do not run a kubectl apply. A delete and create are needed

    Warning: If you have made changes to the CRDs, Service Account or Cluster Role, make sure you migrate those changes in the StorageOS operator yaml.

  5. Recreate the storageos-api secret (optional - only applies if the namespace was deleted per the above).

    kubectl create -f /tmp/storageos-api-secret.yaml
  6. Edit the StorageOSCluster Custom Resource (storageos_cr.yaml) with the new node image version.

        nodeContainer: "storageos/node:v2.4.4"

    If you’re not using any of the hardcoded container image versions make sure to delete them as well and only leave the nodeContainer image as shown above.

    Make sure to also delete all metadata that you’re not using. The final metadata stanza should be something similar to that:

        name: "cluster-storageos"
        namespace: "storageos-operator"
  7. Re-create the StorageOSCluster

    kubectl create -f storageos_cr.yaml
  8. Wait for all the StorageOS pods to enter the RUNNING state

    kubectl get pods -l app=storageos -A -w
  9. Scale your stateful applications back up.

Congratulations, you now have the latest version StorageOS!