In Order to support seamless upgrades of the operator with new versions, need to create a catalog source of bundles containing list of bundles , and at least one channel, and a sequenced upgrade graph.
- Create directory for morpheus catalog:
mkdir -p morpheus-catalog
- Create the catalog yaml using opm:
opm init morpheus-operator --default-channel=alpha --description=../README.md --output yaml >morpheus-catalog/operator.yaml
- Render first bundle into the catalog:
opm render quay.io/zgrinber/morpheus-operator-bundle:v0.0.2 --output=yaml >> morpheus-catalog/operator.yam
- Add
alpha
channel definition into the catalog yaml file, containing the bundle we just rendered into the catalog:
cat << EOF >> morpheus-catalog/operator.yaml
---
schema: olm.channel
package: example-operator
name: alpha
entries:
- name: morpheus-operator-bundle.v0.0.2
EOF
- Validate the catalog ( should return nothing, verbose response means there is an error):
opm validate morpheus-catalog
# should print 0.
echo $?
- Build the catalog index image and push it to a container registry ( make sure the image is public in the container registry' server side)
podman build . -f morpheus-catalog.Dockerfile -t quay.io/zgrinber/morpheus-catalog:latest
podman push quay.io/zgrinber/morpheus-catalog:latest
- Create new project
oc new-project morpheus-operator
- Create new operator group to target all namespaces for operator's permissions
oc apply -f morpheus-og.yaml
Note: This operator depends on Nvidia GPU drivers installed by NVIDIA GPU Operator, If you don't have it already installed on your Openshift Cluster,
Kindly install on cluster manually, or deploy the Morpheus operator in OwnNamespace
installMode
As this is the only installMode that the NVIDIA GPU Operator supports - this will automatically deploy the GPU Operator ( Starts looking from Version 3.9.1) before the Morpheus Operator will be deployed
To Achieve that, you need to edit the operatorgroup file before applying it to the cluster that way:
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: morpheus-og
# Comment Out to disable ownNamespace installMode ( required to enable automatic installation of Nvidia GPU Operator
spec:
targetNamespaces:
- morpheus-operator
- Create a new catalog source and waits for a registry pod to come up in order to serve the budnles from the catalog
oc apply -f morpheus-catalog-source.yaml
oc get pods
Expected outputs:
NAME READY STATUS RESTARTS AGE
morpheus-catalog-9kn5k 1/1 Running 0 24s
- Create a subscription to install the operator via subscribing to morpheus catalog'
alpha
channel
oc apply -f morpheus-subscription.yaml
- Wait for the operator to get installed
oc get csv morpheus-operator.v0.0.2 -w
Expected output
morpheus-operator.v0.0.2 morpheus-operator 0.0.2 Pending
morpheus-operator.v0.0.2 morpheus-operator 0.0.2 InstallReady
morpheus-operator.v0.0.2 morpheus-operator 0.0.2 Installing
morpheus-operator.v0.0.2 morpheus-operator 0.0.2 Installing
morpheus-operator.v0.0.2 morpheus-operator 0.0.2 Installing
morpheus-operator.v0.0.2 morpheus-operator 0.0.2 Succeeded
- check that the operator is running
oc get pods
Expected output:
NAME READY STATUS RESTARTS AGE
b0d4d492ec89774cd2f5981897b8c08ea938452f139888541102b7b4989r7g2 0/1 Completed 0 113s
morpheus-catalog-9kn5k 1/1 Running 0 3m13s
morpheus-operator-controller-manager-58dc8dc97f-plg6p 2/2 Running 0 88s
Before performing this process, you should first create a new image version of the operator + new operator bundle image, please follow These Section Steps 1-4
- Render the new Morpheus Operator bundle version ( for example, v0.0.5)
opm render quay.io/zgrinber/morpheus-operator-bundle:v0.0.5 --output=yaml > new-operator.yaml
- Add this bundle to the catalog
export LINE_NUMBER=$(grep -n -E "schema: olm.bundle[[:blank:]]*" morpheus-catalog/operator.yaml | tail -n 1 | awk -F ':' '{print $1}')
let "targetLine = $LINE_NUMBER + 1"
sed "${targetLine}i: &&&/" morpheus-catalog/operator.yaml | sed '/&&&/ r new-operator.yaml' | sed '/&&&/d' | tee temp.yaml
- Add new Update graph from last version to new version
echo '[{"name": "morpheus-operator.v0.0.5","replaces": "morpheus-operator.v0.0.4" }]' | yq -P | awk '{print" " $0}' >> temp.yaml
mv temp.yaml morpheus-catalog/operator.yaml
rm new-operator.yaml
- Build the updated catalog index image and push it to a container registry and override latest ( make sure the image is public in the container registry' server side)
podman build . -f morpheus-catalog.Dockerfile -t quay.io/zgrinber/morpheus-catalog:latest
podman push quay.io/zgrinber/morpheus-catalog:latest