Use Operator Lifecycle Manager to Deploy a Kubernetes Operator on Oracle Cloud Native Environment
Introduction
This tutorial assumes you have an existing Kubernetes cluster running on Oracle Cloud Native Environment. This tutorial builds upon the tutorials to deploy Oracle Cloud Native Environment.
Objectives
This tutorial shows you how install the Operator Lifecycle Manager module for Oracle Cloud Native Environment into a Kubernetes cluster, then deploy a Kubernetes operator.
The Operator Lifecycle Manager module installs Operator Lifecycle Manager into a Kubernetes cluster. Operator Lifecycle Manager manages the installation and lifecycle management of Kubernetes operators in a Kubernetes cluster.
This tutorial assumes you have an existing Kubernetes cluster running in Oracle Cloud Native Environment.
Prerequisites
Oracle Cloud Native Environment Release 1.4 deployed which includes a Kubernetes cluster. See the tutorials at
Installing the Operator Lifecycle Manager Module
The Operator Lifecycle Manager is installed into a Kubernetes cluster as an Oracle Cloud Native Environment module.
Edit the deployment configuration file to include the Helm module and the Operator Lifecycle Manager module.
environments:
- environment-name: myenvironment
...
modules:
- module: kubernetes
name: mycluster
...
- module: helm
name: myhelm
args:
helm-kubernetes-module: mycluster
- module: operator-lifecycle-manager
name: myolm
args:
olm-helm-module: myhelm
The configuration file is abbreviated to show the important information required to install the Operator Lifecycle module. As this module also requires the Helm module, you must supply the information for both.
For the Helm module, set the name of the Kubernetes module with the helm-kubernetes-module
option (mycluster
in this example).
For the Operator Lifecycle module, set the name of the Helm module with the olm-helm-module
option (myhelm
in this example).
The filename for this configuration file in this tutorial is myenvironment.yaml
.
More information on how to create a configuration file is at Using a Configuration File.
Add the Modules
On the operator node, run the olcnectl module create
command with the --config-file
option to specify the location of the configuration file.
The Platform API Server compares the configuration file with the state of the environment and recognises there are additional modules that should be added to the environment.
olcnectl module create --config-file myenvironment.yaml
Validate the Modules
On the operator node, use the olcnectl module validate
command to validate the nodes
are configured correctly to deploy the modules. If there are any errors, the
commands required to fix the nodes are provided as output of this
command.
olcnectl module validate --config-file myenvironment.yaml
Install the Modules
On the operator node, use the olcnectl module install
command to deploy the modules to the environment.
olcnectl module install --config-file myenvironment.yaml
The Helm and Operator Lifecycle Manager modules are deployed and the required containers are running in
the operator-lifecycle-manager
namespace.
Installing the etcd Operator
This example shows you how to create an etcd
operator which is pulled
from the OperatorHub. This is a very small and basic operator that you can use to validate your installation.
To create an etcd
operator:
-
On a control plane node, download the
etcd
operator manifest YAML file from the OperatorHub:curl --remote-name https://operatorhub.io/install/etcd.yaml
-
The
etcd.yaml
operator manifest file contains the information required to create aNamespace
,OperatorGroup
andSubscription
for theetcd
operator. At the time of writing, this file contained:apiVersion: v1 kind: Namespace metadata: name: my-etcd --- apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: operatorgroup. namespace: my-etcd spec: targetNamespaces: - my-etcd --- apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: my-etcd namespace: my-etcd spec: channel: singlenamespace-alpha name: etcd source: operatorhubio-catalog sourceNamespace: olm
Edit the
etcd.yaml
file to change thesourceNamespace
fromolm
tooperator-lifecycle-manager
in theSubscription
section so that it works properly with Operator Lifecycle Manager. Operator Lifecycle Manager runs in theoperator-lifecycle-manager
namespace, which is different to the upstream namespace.--- apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: my-etcd namespace: my-etcd spec: channel: singlenamespace-alpha name: etcd source: operatorhubio-catalog sourceNamespace: operator-lifecycle-manager
-
Use the
kubectl apply
command to deploy theetcd
operator.kubectl apply -f etcd.yaml
The output should look similar to:
namespace/my-etcd created operatorgroup.operators.coreos.com/operatorgroup created subscription.operators.coreos.com/my-etcd created
The operator is deployed into the namespace set in the operator manifest file, which in this example is
my-etcd
. -
You can see the operator pods are running using:
kubectl get pods -n my-etcd
The output should look similar to:
NAME READY STATUS RESTARTS AGE etcd-operator-75fb7df8b5-42k7b 3/3 Running 0 5m45s
-
To remove the operator, use the
kubectl delete
command:kubectl delete -f etcd.yaml
For More Information
- Oracle Cloud Native Environment Documentation
- Oracle Cloud Native Environment Training
- Oracle Linux Curriculum
- Oracle Linux Learning Subscription
More Learning Resources
Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.
For product documentation, visit Oracle Help Center.
Use Operator Lifecycle Manager to Deploy a Kubernetes Operator on Oracle Cloud Native Environment
F40921-04
February 2022
Copyright © 2020, Oracle and/or its affiliates.