Step-by-step
-
Make sure all pre-requisites are setup and available before we begin with the upgrade.
In a disconnected environment, the following flow chart depicts the flow of OpenShift Container Platform upgrade:
As mentioned in the pre-requisite section, the below should ingredients should be available before we proceed with the upgrade:
1. OCP cluster
2. Upgrade path has been selected based on the base cluster and the target version.
3. Private docker registry is available.
4. Virtual VM with internet connectivity is available. Also, the virtual machine should be able to connect to the private docker registry.
5. The pull-secret.json file with added auth for the private docker registry.
-
Set the below parameters on the virtual machine
OCP_RELEASE=4.4.17
LOCAL_REGISTRY=registry.example.com:<port>
LOCAL_REPOSITORY=ocp4/openshift
PRODUCT_REPO=openshift-release-dev
LOCAL_SECRET_JSON=<path to pull secret>/pullsecret.json
RELEASE_NAME=ocp-release
ARCHITECTURE=x86_64
REMOVABLE_MEDIA_PATH=.- OCP_RELEASE is the target version.
- LOCAL_REGISTRY=registry.example.com:<port> is the Fully qualified name of private docker registry. For IBM Cloud Pak System the docker registry port is 443)
- LOCAL_REPOSITORY is the repository to store RedHat OpenShift Container Platform images. ocps/openshift is the default value.
- PRODUCT_REPO is repo to store the images. openshift-release-dev is the default value.
- LOCAL_SECRET_JSON is the path to the pull secret on the virtual machine.
- RELEASE_NAME OCP release name. ocp-release is the default value.
- ARCHITECTURE Platform architecture. For Linux it is x86_64.
- REMOVABLE_MEDIA_PATH is the location where the mirror folder will be created and images will be mirrored to on your virtual machine.
-
Mirror the images to virtual machine --dry run
Let’s have a dry run first to confirm whether the mirroring would go successfully.
oc adm release mirror -a ${LOCAL_SECRET_JSON} --to-dir=${REMOVABLE_MEDIA_PATH}/mirror quay.io/${PRODUCT_REPO}/${RELEASE_NAME}:${OCP_RELEASE}-${ARCHITECTURE} --dry-run
-
Mirror the images to virtual machine
After the dry run is successful, mirror the images:
oc adm release mirror -a ${LOCAL_SECRET_JSON} --to-dir=${REMOVABLE_MEDIA_PATH}/mirror quay.io/${PRODUCT_REPO}/${RELEASE_NAME}:${OCP_RELEASE}-${ARCHITECTURE}
Post successful mirroring of images, a signature file is created. Note the path of the signature file.
-
Mirror the images to private docker registry
After the images are mirrored to the virtual machine, push these to the private docker registry:
oc image mirror -a ${LOCAL_SECRET_JSON} --from-dir=${REMOVABLE_MEDIA_PATH}/mirror ‘file://openshift/release:<version>*’ ${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}
-
Create the config file
Copy /mirror/config/signature-<xxx>.yaml from virtual machine to Primary helper of the cluster.
On the Primary helper node, run the below command to create the config file
oc apply -f signature-<xxx>.yaml
Note: The above is valid while upgrading from version 4.4.18. For versions below 4.4.18, refer to steps 9-10 to create the file manually.
-
Set parameters to run the upgrade
OCP_RELEASE_NUMBER=4.4.17
ARCHITECTURE=x86_64
DIGEST="$(oc adm release info quay.io/openshift-release-dev/ocp-release:${OCP_RELEASE_NUMBER}-${ARCHITECTURE} | sed -n 's/Pull From: .*@//p')"
DIGEST_ALGO="${DIGEST%%:*}"
DIGEST_ENCODED="${DIGEST#*:}"
SIGNATURE_BASE64=$(curl -s "https://mirror.openshift.com/pub/openshift-v4/signatures/openshift/release/${DIGEST_ALGO}=${DIGEST_ENCODED}/signature-1" | base64 -w0 && echo)Note: Run this step on the VM with an internet connection to get the image signature file.
-
Create the config file for checksum
cat >checksum-${OCP_RELEASE_NUMBER}.yaml <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: release-image-${OCP_RELEASE_NUMBER}
namespace: openshift-config-managed
labels:
release.openshift.io/verification-signatures: ""
binaryData:
${DIGEST_ALGO}-${DIGEST_ENCODED}: ${SIGNATURE_BASE64}
EOFAfter the file is created successfully, apply the checksum file to the cluster:
oc create -f checksum-${OCP_RELEASE_NUMBER}.yaml
-
Upgrade the cluster to the new version
Set the parameters as follows:
LOCAL_REGISTRY=registry.example.com
LOCAL_REPOSITORY=ocp4/openshift4Note: We need not provide a port for LOCAL_REGISTRY.
Upgrade Command:
Run the below command to initiate the cluster upgrade :
oc adm upgrade --allow-explicit-upgrade --to-image ${LOCAL_REGISTRY}/${LOCAL_REPOSITORY}@sha256:<shasum>
Note: Shasum value can be taken from the signature file copied in step 7.
-
Confirm the status of upgrade
While the upgrade is in progress, it is good to check on the upgrade status intermittently.
Run the below command to check the current progress of the upgrade:
oc get clusterversion
After the upgrade is done successfully, oc get clusterversion should give the latest upgraded version.
-
Troubleshooting Guide
1. Upgrade gets stuck due to any degraded cluster operator:
If the upgrade gets stuck on any of the co, delete the operator and its pods. After the co restarts,the upgrade would continue on its own.
Example
oc delete co <co name>
oc project <co name>
oc delete pods --allCheck whether the pods are restarted again in the same project. All the pods should be in Running state.
oc get pods
The co should be restarted and the Degraded state should be False
oc get co | grep <co name>
Note: If the issue does not get resolved, search for a relevant Bugzilla report or contact Red Hat support.
2. If the following error message is shown while cluster upgrade:
“The cluster operator openshift-samples has not yet successfully rolled out”
Follow the below steps to resolve the issue:
Step 1: Run the following oc command:
oc delete configs.samples cluster
Step 2: Wait for some time, and run the following command:
oc get co
The openshift-samples operator should be Degraded=False state :
NAME VERSION AVAILABLE PROGRESSING DEGRADED SINCE
openshift-samples 4.4.17 False True False 7
3. If the upgrade is halted due to api-server degraded :
Refer to the following Bugzilla report to restart api-server operators: https://bugzilla.redhat.com/show_bug.cgi?id=1817588
4. To confirm the upgrade status, run the below commands:oc get clusterversion
oc get clusterversion -o json|jq ".items[0].spec"
oc get clusterversion -o json|jq ".items[0].status.history"
-
Additional information and references
- Based on the upgrade path, the upgrade has to be done one by one for every version in the path till the target version is reached.
- Typical upgrade period is 30 – 50 minutes per version upgrade.
- RedHat reference guide: https://docs.openshift.com/container-platform/4.4/updating/updating-restricted-network-cluster.html