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-manager
The output looks similar to:
NAME DISPLAY TYPE PUBLISHER AGE
operatorhubio-catalog Community Operators grpc OperatorHub.io 3m35s
The 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 packagemanifest
A 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-manager
operator at:https://operatorhub.io/operator/cert-manager
Click Install.
A dialog is displayed that shows the
kubectl create
command to deploy the operator. For example:kubectl create -f https://operatorhub.io/install/cert-manager.yaml
Copy the URL in this command that contains the operator manifest YAML file.
-
On a control plane node, download the
cert-manager
operator 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
Subscription
section:sourceNamespace: olm
Change this to:
sourceNamespace: operator-lifecycle-manager
Operator Lifecycle Manager runs in the
operator-lifecycle-manager
namespace, which is different to the upstream namespace.Edit the file to change
sourceNamespace
tooperator-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 apply
command to deploy thecert-manager
operator.kubectl apply -f cert-manager.yaml
The output looks similar to:
subscription.operators.coreos.com/my-cert-manager created
The operator is deployed into the namespace set in the operator manifest file, which in this example is
operators
. -
You can see the operator's
ClusterServiceVersion
information using:kubectl get csv --namespace operators
The 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 operators
The 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 namespace
You 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