Introduction
Operators framework is the new way to manage complex applications on top of Kubernetes. They embed operational knowledge about applications and manage all the lifecycle from installation, upgrade, monitoring, and even autopilot according to a capability model.
OpenShift 4 is making use of operators, and it offers a way to install operators from a hub called OperatorHub in the web console:
Today, we are going to build a customized operator registry to handle pre-existing operators, configure OpenShift to show these operators, and allow them to install them from the web console catalog.
Perquisites
To accomplish this lab, you will need: OpenShift 4.5+ cluster, operator-sdk, oc CLI, and a Docker v2_2 schema registry (in our case, we will be using quay.io).
Some commands evolve regarding the CLI versions; please keep in mind to use the following versions, or to update the commands:
$ operator-sdk version operator-sdk version: "v0.18.2", commit: "f059b5e17447b0bbcef50846859519340c17ffad", kubernetes version: "v1.18.2", go version: "go1.14.4 darwin/amd64" |
Procedure
Build opm CLI:
$ git clone https://github.com/operator-framework/operator-registry.git |
Create quay.io repos:
On quay.io, create one repository for the operator memcached-operator, the bundle memcached-bundle, and another for the operator registry operator-registry.
Get an existing operator, build it, and push it:
To build a custom operator, you can use operator-sdk and follow the official documentation. In our case, we will be using an existing one:
$ git clone https://github.com/operator-framework/operator-sdk-samples.git |
Replace image in operator deployment:
$ sed -i'.original' -e 's/REPLACE_IMAGE/quay\.io\/saberkan\/memcached-operator\:latest/g' deploy/operator.yaml |
Generate custom service version:
$ operator-sdk generate csv --csv-version 1.0.0 --interactive=true |
Build and publish the operator bundle:
$ operator-sdk bundle create --generate-only |
Check bundle is valid:
$ ./operator-registry/bin/opm alpha bundle validate --tag quay.io/saberkan/memcached-bundle:1.0.0 --image-builder docker |
Add the bundle into the registry image and publish it:
$ ./operator-registry/bin/opm index add --bundles quay.io/saberkan/memcached-bundle:1.0.0 --tag quay.io/saberkan/operator-registry:0.1-RC --build-tool docker |
Configure Catalog Source on OpenShift:
$ cat << EOF | oc create -f - |
Check catalog source is ready:
$ oc describe CatalogSource saberkan-catalog-source -n openshift-marketplace | grep 'Last Observed State' |
Create namespace where to install the operator:
$ oc new-project saberkan |
Install the operator from web console into the created namespace:
The installation can be also triggered with a subscription manifest. But we are doing it from the web console for a demo purpose:
Check operator installed (after few moments):
$ oc get csv memcached-operator.v1.0.0 NAME DISPLAY VERSION REPLACES PHASE memcached-operator.v1.0.0 memcached-operator 1.0.0 Succeeded |
About the author
More like this
Browse by channel
Automation
The latest on IT automation that spans tech, teams, and environments
Artificial intelligence
Explore the platforms and partners building a faster path for AI
Open hybrid cloud
Explore how we build a more flexible future with hybrid cloud
Security
Explore how we reduce risks across environments and technologies
Edge computing
Updates on the solutions that simplify infrastructure at the edge
Infrastructure
Stay up to date on the world’s leading enterprise Linux platform
Applications
The latest on our solutions to the toughest application challenges
Original shows
Entertaining stories from the makers and leaders in enterprise tech
Products
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Cloud services
- See all products
Tools
- Training and certification
- My account
- Developer resources
- Customer support
- Red Hat value calculator
- Red Hat Ecosystem Catalog
- Find a partner
Try, buy, & sell
Communicate
About Red Hat
We’re the world’s leading provider of enterprise open source solutions—including Linux, cloud, container, and Kubernetes. We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.
Select a language
Red Hat legal and privacy links
- About Red Hat
- Jobs
- Events
- Locations
- Contact Red Hat
- Red Hat Blog
- Diversity, equity, and inclusion
- Cool Stuff Store
- Red Hat Summit