From 67a31eeb667f48fe5be0d312b96dead863b3c93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Fri, 24 Apr 2020 16:23:11 +0200 Subject: [PATCH] new article about operators --- .../blog/install-operator-openshift-cli.md | 235 ++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 content/blog/install-operator-openshift-cli.md diff --git a/content/blog/install-operator-openshift-cli.md b/content/blog/install-operator-openshift-cli.md new file mode 100644 index 0000000..f98bf38 --- /dev/null +++ b/content/blog/install-operator-openshift-cli.md @@ -0,0 +1,235 @@ +--- +title: "Install Kubernetes operators in OpenShift using only the CLI" +date: 2020-04-24T00:00:00+02:00 +opensource: +- OpenShift +--- + +OpenShift 4 went all-in on Kubernetes operators: they are used for installation of the platform itself but also to install databases, middlewares, etc. +There are more and more operators available on the [Operator Hub](https://operatorhub.io/). +Most software now provide an operator and describe how to use it. + +Nevertheless, almost every software documentation I read so far, includes the steps to install the operator using the nice GUI of OpenShift 4. +But since my OpenShift environments are provisioned by a playbook, I want to be able to install operators using the CLI only! + +The [OpenShift official documentation](https://docs.openshift.com/container-platform/4.3/operators/olm-adding-operators-to-cluster.html#olm-installing-operator-from-operatorhub-using-cli_olm-adding-operators-to-a-cluster) covers this part but I did not find it very clear. +So, this article tries to make it clearer: **how to install Kubernetes operators in OpenShift using only the CLI**. + +## Discover the available operators from the CLI + +Discover the operators available on your platform. + +```sh +oc get packagemanifests -n openshift-marketplace --sort-by=.metadata.name +``` + +This should give you a very long list of operators. +You can filter it to retain only the ones you need. + +For instance, to discover the operators required to install Red Hat Service Mesh / Istio: + +``` +$ oc get packagemanifests -n openshift-marketplace |egrep -i '(elastic|jaeger|kiali|service.*mesh)' +elasticsearch-operator Red Hat Operators 47h +jaeger-product Red Hat Operators 47h +jaeger Community Operators 47h +kiali Community Operators 47h +kiali-ossm Red Hat Operators 47h +servicemeshoperator Red Hat Operators 47h +``` + +The second column is the display name of the operator source. +Later in the procedure, we will need the identifier of the operator source. + +Query it programmatically for a specific operator using the following command. + +```sh +oc get packagemanifests -n openshift-marketplace -o jsonpath='{.status.catalogSource}{"\n"}' elasticsearch-operator +``` + +In the rest of this article, we will install Elastic Search using the **elasticsearch-operator** coming from the **redhat-operators** source using the CLI. + +Query the available channels for this operator using the follwing command. + +```sh +oc get packagemanifest -o jsonpath='{range .status.channels[*]}{.name}{"\n"}{end}{"\n"}' -n openshift-marketplace elasticsearch-operator +``` + +When this article was written, the Elastic Search operator had four channels: + +``` +4.2 +4.2-s390x +4.3 +preview +``` + +In the rest of this article we will install version 4.3 using the CLI. + +Finally discover whether the operator can be installed cluster-wide or in a single namespace. + +```sh +oc get packagemanifest -o jsonpath='{range .status.channels[*]}{.name}{" => cluster-wide: "}{.currentCSVDesc.installModes[?(@.type=="AllNamespaces")].supported}{"\n"}{end}{"\n"}' -n openshift-marketplace elasticsearch-operator +``` + +You will discover that the Elastic Search operator can be installed cluster-wide for all of its four channels. + +``` +4.2 => cluster-wide: true +4.2-s390x => cluster-wide: true +4.3 => cluster-wide: true +preview => cluster-wide: true +``` + +The rest of the procedure varies slightly depending if the operator supports cluster-wide installation or not. + +## Install an operator cluster-wide using the CLI + +To install an operator cluster-wide using the CLI, create a Subscription object in the **openshift-operators** namespace. + +```sh +oc apply -f - <