3 Using Operator Lifecycle Manager
This section contains basic tests to verify you can use Operator Lifecycle Manager.
Listing Operator Registries
You can show the available operator registries using the
kubectl command on a control plane node:
kubectl get catalogsource --namespace operator-lifecycle-managerThe output looks similar to:
NAME DISPLAY TYPE PUBLISHER AGE
operatorhubio-catalog Community Operators grpc OperatorHub.io 3m35sThe OperatorHub registry is shown in the output. This is the default operator registry.
Installing Operators
To see all the operators that can be installed, use the
kubectl command on a control plane node:
kubectl get packagemanifestA list of the operators available on OperatorHub is displayed. These are all available to be installed by the Operator Lifecycle Manager. The following example shows you how to create an operator which is pulled from the OperatorHub.
To create an operator:
-
In a web browser, go to the OperatorHub and find the name of the operator you want to install. The OperatorHub is at:
This example uses the
cert-manageroperator at:https://operatorhub.io/operator/cert-manager
Click Install.
A dialog is displayed that shows the
kubectl createcommand to deploy the operator. For example:kubectl create -f https://operatorhub.io/install/cert-manager.yamlCopy the URL in this command that contains the operator manifest YAML file.
-
On a control plane node, download the
cert-manageroperator manifest YAML file from the OperatorHub:curl --remote-name https://operatorhub.io/install/cert-manager.yaml -
Edit this manifest YAML file as needed.
Important:
If an operator includes the following line in the
Subscriptionsection:sourceNamespace: olmChange this to:
sourceNamespace: operator-lifecycle-managerOperator Lifecycle Manager runs in the
operator-lifecycle-managernamespace, which is different to the upstream namespace.Edit the file to change
sourceNamespacetooperator-lifecycle-manager.apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: my-cert-manager namespace: operators spec: channel: stable name: cert-manager source: operatorhubio-catalog sourceNamespace: operator-lifecycle-manager -
Use the
kubectl applycommand to deploy thecert-manageroperator.kubectl apply -f cert-manager.yamlThe output looks similar to:
subscription.operators.coreos.com/my-cert-manager createdThe operator is deployed into the namespace set in the operator manifest file, which in this example is
operators. -
You can see the operator's
ClusterServiceVersioninformation using:kubectl get csv --namespace operatorsThe output looks similar to:
NAME DISPLAY VERSION REPLACES PHASE cert-manager.v1.12.2 cert-manager 1.12.2 cert-manager.v1.11.4 Succeeded -
You can see the operator deployments using:
kubectl get deployments --namespace operatorsThe output looks similar to:
NAME READY UP-TO-DATE AVAILABLE AGE cert-manager 1/1 1 1 6m cert-manager-cainjector 1/1 1 1 6m cert-manager-webhook 1/1 1 1 6m
Removing Operators
To remove an operator and uninstall it, you need to remove the Subscription
and ClusterServiceVersion resources.
The example in this document doesn't include a Subscription resource, but if
the operator you want to delete includes one, delete it using:
kubectl delete subscription subscription-name --namespace namespaceYou also need to delete the Kubernetes ClusterServiceVersion resource
using:
kubectl delete csv csv-name --namespace namespace To delete the ClusterServiceVersion for the cert-manager
operator, on a control plane node, run:
kubectl delete csv --namespace operators cert-manager.v1.12.2 The output looks similar to:
clusterserviceversion.operators.coreos.com "cert-manager.v1.12.2" deleted