Run an operator using a bundle with an Operator Lifecycle Manager (OLM)

In the last blog post How to create a bundle for an operator? we created a bundle for the Multi Tenancy Frontend Operator.

In that blog post we focus on get the operator installed using the bundle on a Kubernetes cluster that has the Operator Lifecycle Manager (OLM) installed. Surely, the Go Lang tutorial and Getting started OLM can be useful in that context.

Here’s a simplified architectural overview of what we’ll end up with set up on our Kubernetes cluster:

  • An olm name space, which contains the Operator Lifecycle Manager which does control the installed operators
  • An operator name space, which contains the deployed operators in our case that will be the frontend operator, that does reference the bundle and controller-manager images.
  • A default name space with a frontend application ,which was deployed by the frontend operator and does reference the container image of the frontend

To follow the next steps on your own machine, you need to run the steps in How to create a bundle for an operator? to run your own bundle as a test.

The blog post is organized in following sections:

Start minikube as Kubernetes cluster

We will use in that example a minikube Kubernetes cluster.

Step 1: Start minikube

minikube start

  • Verify minikube is running
minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

kubectl get ns
NAME                   STATUS   AGE
default                Active   23d
kube-node-lease        Active   23d
kube-public            Active   23d
kube-system            Active   23d
kubernetes-dashboard   Active   23d

STEP 2: OPEN THE MINIKUBE DASHBOARD
minikube dashboard

Install the Operator Lifecycle Manager (OLM) on your cluster

Step 1: Open a new terminal and install the Operator Lifecycle Manager (OLM)

operator-sdk olm install latest
  • Example output
INFO[0018] Creating CRDs and resources                  
INFO[0018]   Creating CustomResourceDefinition "catalogsources.operators.coreos.com" 
INFO[0018]   Creating CustomResourceDefinition "clusterserviceversions.operators.coreos.com" 
INFO[0018]   Creating CustomResourceDefinition "installplans.operators.coreos.com" 
INFO[0018]   Creating CustomResourceDefinition "olmconfigs.operators.coreos.com" 
INFO[0018]   Creating CustomResourceDefinition "operatorconditions.operators.coreos.com" 
INFO[0018]   Creating CustomResourceDefinition "operatorgroups.operators.coreos.com" 
INFO[0018]   Creating CustomResourceDefinition "operators.operators.coreos.com" 
INFO[0018]   Creating CustomResourceDefinition "subscriptions.operators.coreos.com" 
INFO[0018]   Creating Namespace "olm"                   
INFO[0018]   Creating Namespace "operators"             
INFO[0018]   Creating ServiceAccount "olm/olm-operator-serviceaccount" 
INFO[0018]   Creating ClusterRole "system:controller:operator-lifecycle-manager" 
INFO[0018]   Creating ClusterRoleBinding "olm-operator-binding-olm" 
INFO[0018]   Creating OLMConfig "cluster"               
INFO[0022]   Creating Deployment "olm/olm-operator"     
INFO[0022]   Creating Deployment "olm/catalog-operator" 
INFO[0022]   Creating ClusterRole "aggregate-olm-edit"  
INFO[0022]   Creating ClusterRole "aggregate-olm-view"  
INFO[0022]   Creating OperatorGroup "operators/global-operators" 
INFO[0022]   Creating OperatorGroup "olm/olm-operators" 
INFO[0022]   Creating ClusterServiceVersion "olm/packageserver" 
INFO[0022]   Creating CatalogSource "olm/operatorhubio-catalog" 
INFO[0022] Waiting for deployment/olm-operator rollout to complete 
INFO[0022]   Waiting for Deployment "olm/olm-operator" to rollout: 0 of 1 updated replicas are available 
INFO[0026]   Deployment "olm/olm-operator" successfully rolled out 
INFO[0026] Waiting for deployment/catalog-operator rollout to complete 
INFO[0026]   Deployment "olm/catalog-operator" successfully rolled out 
INFO[0026] Waiting for deployment/packageserver rollout to complete 
INFO[0026]   Waiting for Deployment "olm/packageserver" to appear 
INFO[0027]   Waiting for Deployment "olm/packageserver" to rollout: 0 out of 2 new replicas have been updated 
INFO[0028]   Waiting for Deployment "olm/packageserver" to rollout: 0 of 2 updated replicas are available 
INFO[0040]   Deployment "olm/packageserver" successfully rolled out 
INFO[0040] Successfully installed OLM version "latest"

Step 2: Open the Kubernetes dashboard and verify the installation

You should see following entries in your dashboard.

Step 3: Verify the existing packagemanifes

kubectl get packagemanifest -n olm
  • Example output:
NAME                                       CATALOG               AGE
ripsaw                                     Community Operators   4m42s
lib-bucket-provisioner                     Community Operators   4m42s
postgresql-operator                        Community Operators   4m42s
...

Deploy the bundle using the Operator SDK and the Operator Lifecycle Manager (OLM)

Step 1: Run the bundle installation with Operator SDK

As you will notice during the execution of the run command using the Operator SDK it creates for you
a CatalogSource and Subscription, which you can also define manually as you see in the OLM Integration documentation.

  • Prepare the bundle image name
export REGISTRY="quay.io"
export ORG="tsuedbroecker"
export BUNDLEIMAGE="bundlefrontendoperator:v3"
  • Execute the command
operator-sdk run bundle "$REGISTRY/$ORG/$BUNDLEIMAGE" -n operators
  • Example output:
INFO[0043] Successfully created registry pod: quay-io-tsuedbroecker-bundlefrontendoperator-v3 
INFO[0043] Created CatalogSource: frontendoperator-catalog 
INFO[0043] Created Subscription: frontendoperator-v0-0-1-sub 
INFO[0047] Approved InstallPlan install-2267v for the Subscription: frontendoperator-v0-0-1-sub 
INFO[0047] Waiting for ClusterServiceVersion "operators/frontendoperator.v0.0.1" to reach 'Succeeded' phase 
INFO[0047]   Waiting for ClusterServiceVersion "operators/frontendoperator.v0.0.1" to appear 
INFO[0059]   Found ClusterServiceVersion "operators/frontendoperator.v0.0.1" phase: Pending 
INFO[0061]   Found ClusterServiceVersion "operators/frontendoperator.v0.0.1" phase: InstallReady 
INFO[0062]   Found ClusterServiceVersion "operators/frontendoperator.v0.0.1" phase: Installing 
INFO[0082]   Found ClusterServiceVersion "operators/frontendoperator.v0.0.1" phase: Succeeded 
INFO[0082] OLM has successfully installed "frontendoperator.v0.0.1"

Step 2: Open the Kubernetes dashboard and verify if the operator is deployed in the operators namespace

You can execute in addition following commands.

kubectl get customresourcedefinition -n operators | grep "frontend"
kubectl get deployment -n operators
kubectl get service -n operators
kubectl get pod -n operators
  • Example output:
tenancyfrontends.multitenancy.example.net     2022-02-21T12:54:19Z
NAME                                  READY   UP-TO-DATE   AVAILABLE   AGE
frontendoperator-controller-manager   1/1     1            1           6m49s
NAME                                                  TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
frontendoperator-controller-manager-metrics-service   ClusterIP   10.101.143.43   <none>        8443/TCP   6m51s
NAME                                                              READY   STATUS      RESTARTS   AGE
868d0603f1009be18f494e33c5d712e44aa115b9e7f6c93b5d48af041brcxl5   0/1     Completed   0          7m4s
frontendoperator-controller-manager-696f6f54b6-glhfg              2/2     Running     0          6m49s
quay-io-tsuedbroecker-bundlefrontendoperator-v3                   1/1     Running     0          7m17s

Verify if the installed bundle works

Step 1: Create a custom resource object

Create a custom resource object in the default namespace.

kubectl apply -f config/samples/multitenancy_v1alpha1_tenancyfrontend.yaml -n default

Step 2: Open the browser and verify the example application is deployed into the default namespace

  • Run following commands
kubectl get customresourcedefinition -n default | grep "frontend"
kubectl get tenancyfrontend -n default | grep "frontend"
kubectl get deployment -n default | grep "frontend"
kubectl get service -n default | grep "frontend"
kubectl get secret -n default | grep "appid"
kubectl get pod -n default | grep "frontend"

  • Example output:
tenancyfrontends.multitenancy.example.net     2022-02-21T12:54:19Z
tenancyfrontendsample   6m9s
tenancyfrontendsample   1/1     1            1           6m9s
tenancyfrontendsample            NodePort    10.110.237.94    <none>        8080:32314/TCP   6m9s
tenancyfrontendsampleclusterip   ClusterIP   10.101.220.187   <none>        80/TCP           6m9s
appid.client-id-frontend   Opaque                                1      6m9s
appid.discovery-endpoint   Opaque                                1      6m9s
tenancyfrontendsample-557fd697dc-9ck99   1/1     Running   0          6m9s

Summary

We were able to run the bundle for the Multi Tenancy Frontend Operator using the Operator SDK and the Operator Lifecycle Manager (OLM). In the future we need also to inspect other topics of the Operator Lifecycle Manager (OLM) such as CatalogSource and Subscription manually creation.


I hope this was useful to you and let’s see what’s next?

Greetings,

Thomas

#operator, #operatorsdk, #kubernetes, #bundle, #olm, #operatorlearningjourney

2 thoughts on “Run an operator using a bundle with an Operator Lifecycle Manager (OLM)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.