|
| 1 | += Setup Backstage for Eventing |
| 2 | +:compat-mode!: |
| 3 | +// Metadata: |
| 4 | +:description: Setup Backstage for Eventing in {serverlessproductname} |
| 5 | + |
| 6 | +This page describes how to set up Backstage for Eventing in {serverlessproductname}, which allows you to discover your Eventing resources in Backstage. |
| 7 | + |
| 8 | +In an event driven architecture, events are the first-class citizens. They are the building blocks of your application. {serverlessproductname} provides a way to create, manage, and consume events in a cloud-native way. {serverlessproductname} Eventing is built on top of Knative Eventing, which is a Kubernetes-based eventing system that provides composable primitives to build event-driven systems. |
| 9 | + |
| 10 | +However, as the number of events and event sources grow, it becomes difficult to manage them. You need a way to discover and manage these resources. This is where Backstage comes in. Backstage is an open-source platform for building developer portals. It provides a way to discover, share, and collaborate on your services and APIs. |
| 11 | + |
| 12 | +[IMPORTANT] |
| 13 | +==== |
| 14 | +{serverlessproductname} Backstage integration is a Developer Preview feature only. |
| 15 | +
|
| 16 | +Developer Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. |
| 17 | +Red Hat does not recommend using them in production. |
| 18 | +These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process. |
| 19 | +
|
| 20 | +For more information about the support scope of Red Hat Developer Preview features, see https://access.redhat.com/support/offerings/devpreview/. |
| 21 | +==== |
| 22 | + |
| 23 | +== Prerequisites |
| 24 | + |
| 25 | +* You have access to an {product-title} account with cluster administrator access. |
| 26 | + |
| 27 | +* Install the OpenShift CLI (`oc`). |
| 28 | + |
| 29 | +* Install the {serverlessoperatorname}. |
| 30 | + |
| 31 | +* Install the https://developers.redhat.com/rhdh/overview[Red Hat Developer Hub Operator] and create a `Backstage` instance. |
| 32 | + |
| 33 | +== Enable Backstage backend for Eventing |
| 34 | + |
| 35 | +. Configure `KnativeEventing` to create the necessary backend resources for Backstage: |
| 36 | ++ |
| 37 | +[source,yaml] |
| 38 | +---- |
| 39 | +apiVersion: operator.knative.dev/v1 |
| 40 | +kind: KnativeEventing |
| 41 | +metadata: |
| 42 | + name: knative-eventing |
| 43 | + namespace: knative-eventing |
| 44 | +spec: |
| 45 | +
|
| 46 | + # Other spec fields omitted ... |
| 47 | + # ... |
| 48 | +
|
| 49 | + config: |
| 50 | + features: |
| 51 | + backstage-backend: enabled <1> |
| 52 | +---- |
| 53 | +<1> Enables Backstage backend deployment in Eventing namespace. |
| 54 | + |
| 55 | +. Apply the `KnativeEventing` resource: |
| 56 | ++ |
| 57 | +[source,terminal] |
| 58 | +---- |
| 59 | +$ oc apply -f <filename> |
| 60 | +---- |
| 61 | + |
| 62 | +== Create necessary tokens for Backstage backend and {serverlessproductname} communication |
| 63 | + |
| 64 | +Backstage backend will communicate with the {serverlessproductname} Backstage backend using a token. That token will be passed to the {serverlessproductname} backend and the it will use it to talk to the Kubernetes API server. |
| 65 | + |
| 66 | +. Create a `ServiceAccount`: |
| 67 | ++ |
| 68 | +[source,terminal] |
| 69 | +---- |
| 70 | +$ oc -n knative-eventing create serviceaccount backstage-admin |
| 71 | +---- |
| 72 | + |
| 73 | +. Create a `ClusterRole` that allows the `ServiceAccount` to list and get the necessary resources in the cluster: |
| 74 | ++ |
| 75 | +[source,yaml] |
| 76 | +---- |
| 77 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 78 | +kind: ClusterRole |
| 79 | +metadata: |
| 80 | + name: backstage-admin |
| 81 | +rules: |
| 82 | + - apiGroups: |
| 83 | + - eventing.knative.dev |
| 84 | + resources: |
| 85 | + - brokers |
| 86 | + - eventtypes |
| 87 | + - triggers |
| 88 | + verbs: |
| 89 | + - get |
| 90 | + - list |
| 91 | +---- |
| 92 | + |
| 93 | ++ |
| 94 | +[IMPORTANT] |
| 95 | +==== |
| 96 | +The `ClusterRole` should be scoped to only allow the necessary permissions. |
| 97 | +==== |
| 98 | + |
| 99 | +. Apply the `ClusterRole` resource: |
| 100 | ++ |
| 101 | +[source,terminal] |
| 102 | +---- |
| 103 | +$ oc apply -f <filename> |
| 104 | +---- |
| 105 | + |
| 106 | +. Bind the `ServiceAccount` to the `ClusterRole`: |
| 107 | ++ |
| 108 | +[source,terminal] |
| 109 | +---- |
| 110 | +$ oc create clusterrolebinding backstage-admin --clusterrole=backstage-admin --serviceaccount=knative-eventing:backstage-admin |
| 111 | +---- |
| 112 | + |
| 113 | +. Create a secret: |
| 114 | ++ |
| 115 | +[source,yaml] |
| 116 | +---- |
| 117 | +apiVersion: v1 |
| 118 | +kind: Secret |
| 119 | +metadata: |
| 120 | + name: backstage-admin |
| 121 | + namespace: knative-eventing |
| 122 | + annotations: |
| 123 | + kubernetes.io/service-account.name: backstage-admin |
| 124 | +type: kubernetes.io/service-account-token |
| 125 | +---- |
| 126 | +. Apply the `Secret` resource: |
| 127 | ++ |
| 128 | +[source,terminal] |
| 129 | +---- |
| 130 | +$ oc apply -f <filename> |
| 131 | +---- |
| 132 | + |
| 133 | +. Get the token from the secret: |
| 134 | ++ |
| 135 | +[source,terminal] |
| 136 | +---- |
| 137 | +$ oc get secret backstage-admin -n knative-eventing -o jsonpath='{.data.token}' | base64 --decode |
| 138 | +---- |
| 139 | +We are going to give this token to Red Hat Developer Hub. |
| 140 | + |
| 141 | + |
| 142 | +== Install the Backstage plugin on Red Hat Developer Hub |
| 143 | + |
| 144 | +. Add the `BACKSTAGE_KNATIVE_BACKEND_TOKEN` environment variable to the Red Hat Developer Hub deployment by modifying the Red Hat Developer Hub secret such as `secrets-rhdh`: |
| 145 | ++ |
| 146 | +[source,yaml] |
| 147 | +---- |
| 148 | +kind: Secret |
| 149 | +apiVersion: v1 |
| 150 | +metadata: |
| 151 | + name: secrets-rhdh |
| 152 | + namespace: rhdh-operator |
| 153 | + # more metadata ... |
| 154 | +data: |
| 155 | + BACKSTAGE_KNATIVE_BACKEND_TOKEN: SECRET-TOKEN <1> |
| 156 | + # more data ... |
| 157 | +# more fields ... |
| 158 | +---- |
| 159 | +<1> The token we got from the `backstage-admin` secret. |
| 160 | + |
| 161 | +. Modify the https://docs.redhat.com/en/documentation/red_hat_developer_hub/1.3/html-single/installing_and_viewing_dynamic_plugins/index[dynamic plugins configmap] such as `dynamic-plugins-rhdh` and add an entry for the Backstage plugin: |
| 162 | ++ |
| 163 | +[source,yaml] |
| 164 | +---- |
| 165 | +kind: ConfigMap |
| 166 | +apiVersion: v1 |
| 167 | +metadata: |
| 168 | + name: dynamic-plugins-rhdh |
| 169 | + namespace: rhdh-operator |
| 170 | + # more metadata ... |
| 171 | +data: |
| 172 | + dynamic-plugins.yaml: |- |
| 173 | + includes: |
| 174 | + - dynamic-plugins.default.yaml |
| 175 | + plugins: |
| 176 | + # - Other plugins omitted |
| 177 | + # - ... |
| 178 | + - package: "@knative-extensions/plugin-knative-event-mesh-backend-dynamic@1.16.0" <1> |
| 179 | + integrity: "sha512-Rnw7o2UyS8X7YklwhHYEtr/yHLnDHJizIACpKaDuqddW/2+WBWrdg8geAYGAeW8u/RnXwgpkcFW27DmoQ460gQ==" <2> |
| 180 | + disabled: false |
| 181 | + pluginConfig: |
| 182 | + catalog: |
| 183 | + providers: |
| 184 | + knativeEventMesh: |
| 185 | + dev: |
| 186 | + token: "${BACKSTAGE_KNATIVE_BACKEND_TOKEN}" <3> |
| 187 | + baseUrl: "http://eventmesh-backend.knative-eventing.svc.cluster.local:8080" <4> |
| 188 | + schedule: |
| 189 | + frequency: { minutes: 1 } <5> |
| 190 | + timeout: { minutes: 1 } <6> |
| 191 | +---- |
| 192 | +<1> The full package name of the plugin. You can find the list of available versions in https://www.npmjs.com/package/@knative-extensions/plugin-knative-event-mesh-backend-dynamic?activeTab=versions[NPM]. |
| 193 | +<2> The integrity of the plugin package. You can find the integrity of the package by running `npm view @knative-extensions/plugin-knative-event-mesh-backend-dynamic@1.16.0 dist.integrity`. |
| 194 | +<3> This will be replaced by an environment variable we have created in the previous step. |
| 195 | +<4> This is the URL of the Backstage backend. |
| 196 | +<5> The frequency at which the plugin will poll the backend for new data. |
| 197 | +<6> The timeout for the polling. |
| 198 | + |
| 199 | +. Apply the `ConfigMap` resource: |
| 200 | ++ |
| 201 | +[source,terminal] |
| 202 | +---- |
| 203 | +$ oc apply -f <filename> |
| 204 | +---- |
| 205 | + |
| 206 | + |
| 207 | +[NOTE] |
| 208 | +==== |
| 209 | +The changes will not be applied to the Red Hat Developer Hub deployment automatically. |
| 210 | +You need to restart the Red Hat Developer Hub deployment to apply the changes. |
| 211 | +==== |
| 212 | + |
| 213 | +[NOTE] |
| 214 | +==== |
| 215 | +The default installation of Red Hat Developer Hub might not have the https://docs.redhat.com/en/documentation/red_hat_developer_hub/1.3/html-single/installing_and_viewing_dynamic_plugins/index[dynamic plugins configmap] such as `dynamic-plugins-rhdh` and the https://docs.redhat.com/en/documentation/red_hat_developer_hub/1.3/html-single/administration_guide_for_red_hat_developer_hub/index#proc-add-custom-app-config-file-ocp-operator_admin-rhdh[secret such as `secrets-rhdh`] created. See the Red Hat Developer Hub documentation for more information on how to create these resources and to reference them in the Red Hat Developer Hub instance. |
| 216 | +==== |
0 commit comments