|
| 1 | +# OLM installation files |
| 2 | + |
| 3 | +The following steps describe how to install a Stackable operator - in this, the operator for Apache Zookeeper - using the [Operator Lifecycle Manager](https://olm.operatorframework.io/) (OLM). |
| 4 | + |
| 5 | +It specifically installs the version 23.1.0 of the operator. Installing additional versions in the future requires generating new bundle images and updating the catalog as described below. |
| 6 | + |
| 7 | +## Usage |
| 8 | + |
| 9 | +Prerequisite is of course a running OpenShift cluster. |
| 10 | + |
| 11 | +First, install the operator using OLM: |
| 12 | + |
| 13 | + kubectl apply -f catalog-source.yaml \ |
| 14 | + -f operator-group.yaml \ |
| 15 | + -f subscription.yaml |
| 16 | + |
| 17 | +Then, install the operator dependencies with Helm: |
| 18 | + |
| 19 | + helm install secret-operator stackable/secret-operator |
| 20 | + helm install commons-operator stackable/commons-operator |
| 21 | + |
| 22 | +And finally, create an Apache Zookeeper cluster: |
| 23 | + |
| 24 | + kubectl create -f examples/simple-zookeeper-cluster.yaml |
| 25 | + |
| 26 | +NOTE: The `kuttl` tests don't work because they themselves require SCCs which are not available. |
| 27 | + |
| 28 | +## OLM packaging requirements |
| 29 | + |
| 30 | +- An [OpenShift](https://developers.redhat.com/products/openshift-local/overview) cluster. |
| 31 | +- [opm](https://github.com/operator-framework/operator-registry/) |
| 32 | +- docker and kubectl |
| 33 | +- `kubeadmin` access |
| 34 | + |
| 35 | +It was tested with: |
| 36 | + |
| 37 | + $ crc version |
| 38 | + WARN A new version (2.5.1) has been published on https://developers.redhat.com/content-gateway/file/pub/openshift-v4/clients/crc/2.5.1/crc-linux-amd64.tar.xz |
| 39 | + CRC version: 2.4.1+b877358 |
| 40 | + OpenShift version: 4.10.14 |
| 41 | + Podman version: 4.0.2 |
| 42 | + |
| 43 | + $ oc version |
| 44 | + Client Version: 4.10.14 |
| 45 | + Server Version: 4.10.14 |
| 46 | + Kubernetes Version: v1.23.5+b463d71 |
| 47 | + |
| 48 | + $ opm version |
| 49 | + Version: version.Version{OpmVersion:"v1.23.2", GitCommit:"82505333", BuildDate:"2022-07-04T13:45:39Z", GoOs:"linux", GoArch:"amd64"} |
| 50 | + |
| 51 | +## Open questions |
| 52 | + |
| 53 | +- OLM [doesn't support DaemonSet(s)](https://github.com/operator-framework/operator-lifecycle-manager/issues/1022) and we need them for the secret-operator. Currently we can deploy the secret-operator using Helm but this means we cannot configure the [required](https://olm.operatorframework.io/docs/tasks/creating-operator-manifests/#required-apis) apis of the Zookeeper bundle. What are the consequences for publishing and certification ? |
| 54 | +- Here we create a catalog for a single operator. We probably want a catalog for all Stackable operators in the future but this will get large very quickly. Figure out how to handle this. Especially figure out what happens with new versions of the same operator. |
| 55 | +- OLM cannot create SecurityContextConstraints objects. The Zookeeper cluster (not the operator) cannot run with the default `restricted` SCC. The current solution is to use the `hostmount-anyuid` SCC for the `zookeeper-clusterrole`. Will this pass the certification process ? |
| 56 | +- Everything (catalog, subscription, etc) is installed in the `stackable-operators` namespace. Is this a good idea ? |
| 57 | +- The Subscription object uses `installPlanApproval: Automatic` which means the operator is updated automatically for every new version. Is this a good idea? |
| 58 | + |
| 59 | +See the [OLM documentation](https://olm.operatorframework.io/docs/tasks/) for details. |
| 60 | + |
| 61 | +## Build and publish operator bundle image |
| 62 | + |
| 63 | +Each catalog can contain several operator packages, and each operator package can contain multiple channels, each with its own bundles of different versions of the operator. |
| 64 | + |
| 65 | +### Generate operator bundle (this is operator-specific) |
| 66 | + |
| 67 | + opm alpha bundle generate --directory manifests --package zookeeper-operator-package --output-dir bundle --channels stable --default stable |
| 68 | + |
| 69 | +### Build bundle image |
| 70 | + |
| 71 | + docker build -t docker.stackable.tech/stackable/zookeeper-operator-bundle:23.1.0 -f bundle.Dockerfile . |
| 72 | + docker push docker.stackable.tech/stackable/zookeeper-operator-bundle:23.1.0 |
| 73 | + |
| 74 | +### Validate bundle image |
| 75 | + |
| 76 | + opm alpha bundle validate --tag docker.stackable.tech/stackable/zookeeper-operator-bundle:23.1.0 --image-builder docker |
| 77 | + |
| 78 | +## Create catalog |
| 79 | + |
| 80 | + mkdir catalog |
| 81 | + opm generate dockerfile catalog |
| 82 | + |
| 83 | +## Create a package for each operator |
| 84 | + |
| 85 | + opm init zookeeper-operator-package \ |
| 86 | + --default-channel=stable \ |
| 87 | + --description=./README.md \ |
| 88 | + --output yaml > catalog/zookeeper-operator-package.yaml |
| 89 | + |
| 90 | + { |
| 91 | + echo "---" |
| 92 | + echo "schema: olm.channel" |
| 93 | + echo "package: zookeeper-operator-package" |
| 94 | + echo "name: stable" |
| 95 | + echo "entries:" |
| 96 | + echo "- name: zookeeper-operator.v23.1.0" |
| 97 | + } >> catalog/zookeeper-operator-package.yaml |
| 98 | + |
| 99 | +NOTE: with the command below we can add the Stackable logo as icon. |
| 100 | + |
| 101 | + # add for each operator... |
| 102 | + opm render docker.stackable.tech/stackable/zookeeper-operator-bundle:23.1.0 --output=yaml >> catalog/zookeeper-operator-package.yaml |
| 103 | + |
| 104 | + # ...and then validate the entire catalog |
| 105 | + opm validate catalog |
| 106 | + |
| 107 | +The catalog is correct if the command above returns successfully without any message. If the catalog doesn't validate, the operator will not install. Now build a catalog image and push it to the repository: |
| 108 | + |
| 109 | + docker build . -f catalog.Dockerfile -t docker.stackable.tech/stackable/zookeeper-operator-catalog:latest |
| 110 | + docker push docker.stackable.tech/stackable/zookeeper-operator-catalog:latest |
| 111 | + |
| 112 | +## Install catalog and the operator group |
| 113 | + |
| 114 | + kubectl apply -f catalog-source.yaml |
| 115 | + kubectl apply -f operator-group.yaml |
| 116 | + |
| 117 | +## List available operators |
| 118 | + |
| 119 | + kubectl get packagemanifest -n stackable-operators |
| 120 | + |
| 121 | +## Install operator |
| 122 | + |
| 123 | + kubectl apply -f subscription.yaml |
0 commit comments