Bookmark this page

Chapter 7.  Manage Kubernetes Operators

Abstract

Goal

Install and update operators that the Operator Lifecycle Manager and the Cluster Version Operator manage.

Objectives
  • Explain the operator pattern and different approaches for installing and updating Kubernetes operators.

  • Install and update operators by using the web console and the Operator Lifecycle Manager.

  • Install and update operators by using the Operator Lifecycle Manager APIs.

Sections
  • Kubernetes Operators and the Operator Lifecycle Manager (and Matching Quiz)

  • Install Operators with the Web Console (and Guided Exercise)

  • Install Operators with the CLI (and Guided Exercise)

Lab
  • Manage Kubernetes Operators

Kubernetes Operators and the Operator Lifecycle Manager

Objectives

  • Describe the operator pattern and different approaches for installing and updating Kubernetes operators.

The Operator Pattern

You can deploy workloads to Kubernetes with resources such as deployments, replica sets, stateful sets, daemon sets, jobs, and cron jobs. All of these resources create a workload that runs software that is packaged as a container image, in different modalities. For example, jobs execute a one-off task; cron jobs execute tasks periodically; and the other resources create persistent workloads. Resources such as deployments, stateful sets, or daemon sets differ on how the workload is distributed in a cluster.

These resources are sufficient to deploy many workloads. However, more complex workloads might require significant work to deploy with only these resources. For example, a workload can involve different component workloads, such as a database server, a back-end service, and a front-end service.

A workload might have maintenance tasks that can be automated, such as backing up data or updating the workload.

The operator pattern is a way to implement reusable software to manage such complex workloads.

An operator typically defines custom resources (CRs). The operator CRs contain the needed information to deploy and manage the workload. For example, an operator that deploys database servers defines a database resource where you can specify the database name, sizing requirements, and other parameters.

The operator watches the cluster for instances of the CRs, and then creates the Kubernetes resources to deploy the custom workload. For example, when you create a database resource, the database operator creates a stateful set and a persistent volume that provide the database that is described in the database resource. If the database resource describes a backup schedule and target, then the operator creates a cron job that backs up the database to the target according to the schedule.

By using operators, cluster administrators create CRs that describe a complex workload, and the operator creates and manages the workload.

Deploying Operators

Many pieces of software implement the operator pattern, in different ways.

Cluster operators

Cluster operators provide the platform services of OpenShift, such as the web console and the OAuth server.

Add-on operators

OpenShift includes the Operator Lifecycle Manager (OLM). The OLM helps users to install and update operators in a cluster. Operators that the OLM manages are also known as add-on operators, in contrast with cluster operators that implement platform services.

Other operators

Software providers can create software that follows the operator pattern, and then distribute the software as manifests, Helm charts, or any other software distribution mechanism.

Cluster Operators

The Cluster Version Operator (CVO) installs and updates cluster operators as part of the OpenShift installation and update processes.

The CVO provides cluster operator status information as resources of the ClusterOperator type. Inspect the cluster operator resources to examine cluster health.

[user@host ~]$ oc get clusteroperator
NAME                      VERSION  AVAILABLE  PROGRESSING  DEGRADED  ...  MESSAGE
authentication            4.14.0   True       False        False     ...
baremetal                 4.14.0   True       False        False     ...
cloud-controller-manager  4.14.0   True       False        False     ...
...output omitted...

The status of cluster operator resources includes conditions to help with identifying cluster issues. The oc command shows the message that is associated with the latest condition. This message can provide further information about cluster issues.

To view cluster operator resources in the web console, navigate to AdministrationCluster Settings, and then click the ClusterOperators tab.

The Operator Lifecycle Manager and the OperatorHub

Administrators can use the OLM to install, update, and remove operators.

You can use the web console to interact with the OLM. The OLM also follows the operator pattern, and so the OLM provides CRs to manage operators with the Kubernetes API.

The OLM uses operator catalogs to find available operators to install. Operator catalogs are container images that provide information about available operators, such as descriptions and available versions.

OpenShift includes several default catalogs:

Red Hat

Red Hat packages, ships, and supports operators in this catalog.

Certified

Independent software vendors support operators in this catalog.

Community

Operators without official support.

Marketplace

Commercial operators that you can buy from Red Hat Marketplace.

You can also create your own catalogs, or mirror catalogs for offline clusters.

Note

The lab environment includes a single catalog with the operators you use in the course. The lab environment hosts the contents of this catalog, so that the course can be completed without internet access.

The OLM creates a resource of the PackageManifest type for each available operator. The web console also displays available operators and provides a wizard to install operators. You can also install operators by using the Subscription CR and other CRs.

Note

Operators that are installed with the OLM have a different lifecycle from cluster operators. The CVO installs and updates cluster operators in lockstep with the cluster. Administrators use the OLM to install, update, and remove operators independently from cluster updates.

Some operators might require additional steps to install, update, or remove.

Implementing Operators

An operator is composed of a set of custom resource definitions and a Kubernetes workload. The operator workload uses the Kubernetes API to watch instances of the CRs and to create matching workloads.

Note

A cluster contains two workload sets for each operator.

  • The operator workload, which the OLM manages

  • The workloads that are associated with the custom resources, and which the operator manages

You can implement operators to automate any manual Kubernetes task that fits the operator pattern. You can use most software development platforms to create operators. The following SDKs provide components and frameworks to help with developing operators:

The Operator SDK

The Operator SDK contains tools to develop operators with the Go programming language, and Ansible. The Operator SDK also contains tools to package Helm charts as operators.

The Java Operator SDK

The Java Operator SDK contains tools to develop operators with the Java programming language. The Java Operator SDK has a Quarkus extension to develop operators with the Quarkus framework.

References

For more information, refer to the Operators guide in the Red Hat OpenShift Container Platform 4.14 documentation at https://access.redhat.com/documentation/en-us/openshift_container_platform/4.14/html-single/operators/index

Operator SDK

Java Operator SDK

Quarkus Operator SDK

Revision: do280-4.14-08d11e1