OLM Integration Bundle Quickstart
The Operator Lifecycle Manager (OLM) is a set of cluster resources that manage the lifecycle of an Operator. The Operator SDK supports both creating manifests for OLM deployment, and testing your Operator on an OLM-enabled Kubernetes cluster.
This document succinctly walks through getting an Operator OLM-ready with bundles, and glosses over explanations of certains steps for brevity. The following documents contain more detail on these steps:
- All operator-framework manifest commands supported by the SDK: CLI overview.
- Generating operator-framework manifests: generation overview.
If you are working with package manifests, see the package manifests quickstart once you have completed the Setup section below.
Let’s first walk through creating an Operator for
memcached, a distributed key-value store.
Follow one of the user guides to develop the memcached-operator in either Go,
Ansible, or Helm, depending on which Operator type you are interested in.
This guide assumes memcached-operator is on version
Ensure OLM is enabled on your cluster before following this guide.
has several subcommands that can install, uninstall, and check the status of particular OLM versions in a cluster.
Note: Certain cluster types may already have OLM enabled, but under a non-default (
which can be configured by setting
operator-sdk olm subcommands
operator-sdk run packagemanifests.
You can check if OLM is already installed by running the following command, which will detect the installed OLM version automatically (0.15.1 in this example):
$ operator-sdk olm status INFO Fetching CRDs for version "0.15.1" INFO Fetching resources for version "0.15.1" INFO Successfully got OLM status for version "0.15.1" NAME NAMESPACE KIND STATUS olm Namespace Installed operatorgroups.operators.coreos.com CustomResourceDefinition Installed catalogsources.operators.coreos.com CustomResourceDefinition Installed subscriptions.operators.coreos.com CustomResourceDefinition Installed ...
All resources listed should have status
If OLM is not already installed, go ahead and install the latest version:
$ operator-sdk olm install INFO Fetching CRDs for version "latest" INFO Fetching resources for version "latest" INFO Creating CRDs and resources INFO Creating CustomResourceDefinition "clusterserviceversions.operators.coreos.com" INFO Creating CustomResourceDefinition "installplans.operators.coreos.com" INFO Creating CustomResourceDefinition "subscriptions.operators.coreos.com" ... NAME NAMESPACE KIND STATUS clusterserviceversions.operators.coreos.com CustomResourceDefinition Installed installplans.operators.coreos.com CustomResourceDefinition Installed subscriptions.operators.coreos.com CustomResourceDefinition Installed catalogsources.operators.coreos.com CustomResourceDefinition Installed ...
Note: By default,
olm status and
olm uninstall auto-detect the OLM version installed in your cluster.
This can fail if the installation is broken in some way, so the version of OLM can be overridden using the
--version flag provided with these commands.
Creating a bundle
If working with package manifests, see the package manifests quickstart.
We will now create bundle manifests and metadata by running
generate bundle in the root of the memcached-operator project.
$ operator-sdk generate bundle --version 0.0.1
A bundle manifests directory
deploy/olm-catalog/memcached-operator/manifests containing a CSV and all CRDs
deploy/crds, a bundle metadata directory
and a Dockerfile
bundle.Dockerfile have been created in the Operator project.
These files can be statically validated by
bundle validate to ensure the on-disk bundle representation is correct:
$ operator-sdk bundle validate ./deploy/olm-catalog/memcached-operator INFO Found annotations file bundle-dir=deploy/olm-catalog/memcached-operator container-tool=docker INFO Could not find optional dependencies file bundle-dir=deploy/olm-catalog/memcached-operator container-tool=docker INFO All validation tests have completed successfully
Deploying an Operator with OLM
At this point in development we’ve generated all files necessary to build the memcached-operator bundle. Now we’re ready to test and deploy the Operator with OLM.
Deploying bundles in production
OLM and Operator Registry consumes Operator bundles via an index image, which are composed of one or more bundles. To build a memcached-operator bundle, run:
$ docker build -f bundle.Dockerfile -t quay.io/<username>/memcached-operator:v0.1.0 .
Although we’ve validated on-disk manifests and metadata, we also must make sure the bundle itself is valid:
$ docker push quay.io/<username>/memcached-operator:v0.1.0 $ operator-sdk bundle validate quay.io/<username>/memcached-operator:v0.1.0 INFO Unpacked image layers bundle-dir=/tmp/bundle-716785960 container-tool=docker INFO running docker pull bundle-dir=/tmp/bundle-716785960 container-tool=docker INFO running docker save bundle-dir=/tmp/bundle-716785960 container-tool=docker INFO All validation tests have completed successfully bundle-dir=/tmp/bundle-716785960 container-tool=docker
The SDK does not build index images; instead, use the Operator package manager tool
build one. Once one has been built, follow the index image usage docs
to add an index to a cluster catalog, and the catalog discovery docs to tell OLM
about your cataloged Operator.