@knative-extensions/plugin-knative-event-mesh-backend 1.15.0 → 1.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,255 +2,19 @@
2
2
 
3
3
  The Event Mesh plugin is a Backstage plugin that allows you to view and manage Knative Eventing resources.
4
4
 
5
- The Backstage plugin talks to a special backend that runs in the Kubernetes cluster and communicates with the Kubernetes
6
- API server.
7
-
8
5
  A demo setup for this plugin is available at https://github.com/aliok/knative-backstage-demo.
9
6
 
10
7
  ## Dynamic vs static plugin
11
8
 
12
9
  This plugin has 2 distributions: static and dynamic.
13
10
 
14
- The static distribution is a regular Backstage plugin that requires
15
- the source code of Backstage to be changed.
16
-
17
- The dynamic distribution is a plugin that can be installed without changing
18
- the source code of Backstage. If you would like to use the dynamic plugin, please see the instructions in the
19
- [Dynamic Plugin README file](./dist-dynamic/README.md).
20
-
21
- Rest of this documentation is for the static plugin.
22
-
23
- ## Installation
24
-
25
- Install the backend and the relevant configuration in the Kubernetes cluster
26
-
27
- ```bash
28
- VERSION="latest" # or a specific version like 0.1.2
29
- kubectl apply -f https://github.com/knative-extensions/backstage-plugins/releases/${VERSION}/download/eventmesh.yaml
30
- ```
31
-
32
- In your Backstage directory, run the following command to install the plugin:
33
-
34
- ```bash
35
- VERSION="latest" # or a specific version like 0.1.2
36
- yarn workspace backend add @knative-extensions/plugin-knative-event-mesh-backend@${VERSION}
37
- ```
38
-
39
- ## Configuration
40
-
41
- > **NOTE**: The backend needs to be accessible from the Backstage instance. If you are running the backend without
42
- > exposing it, you can use `kubectl port-forward` to forward the port of the backend service to your local machine.
43
- > ```bash
44
- > kubectl port-forward -n knative-eventing svc/eventmesh-backend 8080:8080
45
- > ```
46
-
47
-
48
- The plugin needs to be configured to talk to the backend. It can be configured in the `app-config.yaml` file of the
49
- Backstage instance and allows configuration of one or multiple providers.
50
-
51
- Use a `knativeEventMesh` marker to start configuring the `app-config.yaml` file of Backstage:
52
-
53
- ```yaml
54
- catalog:
55
- providers:
56
- knativeEventMesh:
57
- dev:
58
- token: '${KNATIVE_EVENT_MESH_TOKEN}' # SA token to authenticate to the backend
59
- baseUrl: '${KNATIVE_EVENT_MESH_BACKEND}' # URL of the backend installed in the cluster
60
- schedule: # optional; same options as in TaskScheduleDefinition
61
- # supports cron, ISO duration, "human duration" as used in code
62
- frequency: { minutes: 1 }
63
- # supports ISO duration, "human duration" as used in code
64
- timeout: { minutes: 1 }
65
- ```
66
-
67
- You can either manually change the placeholders in the `app-config.yaml` file or use environment variables to set the
68
- values. The environment variables can be set as following before starting the Backstage instance:
69
-
70
- ```bash
71
- export KNATIVE_EVENT_MESH_TOKEN=your-token
72
- export KNATIVE_EVENT_MESH_BACKEND=http://localhost:8080
73
- ```
74
-
75
- The value of `KNATIVE_EVENT_MESH_BACKEND` should be the URL of the backend service. If you are running the backend
76
- service in the same cluster as the Backstage instance, you can use the service name as the URL. Or, if you are running
77
- the backend without exposing it, you can use `kubectl port-forward` as mentioned above.
78
-
79
- The value of `KNATIVE_EVENT_MESH_TOKEN` should be a service account token that has the necessary permissions to list
80
- the Knative Eventing resources in the cluster. The backend will use this token to authenticate to the Kubernetes API
81
- server. This is required for security reasons as otherwise (if the backend is running with a SA token directly) the
82
- backend would have full access to the cluster will be returning all resources to anyone who can access the backend.
83
-
84
- The token will require the following permissions to work properly:
85
-
86
- - `get`, `list` and `watch` permissions for `eventing.knative.dev/brokers`, `eventing.knative.dev/eventtypes` and
87
- `eventing.knative.dev/triggers` resources
88
- - `get` permission for all resources to fetch subscribers for triggers
89
-
90
- You can create a ClusterRole with the necessary permissions and bind it to the service account token.
91
-
92
- An example configuration is as follows:
93
-
94
- ```yaml
95
- apiVersion: v1
96
- kind: ServiceAccount
97
- metadata:
98
- name: my-eventmesh-backend-service-account
99
- namespace: default
100
- ---
101
- apiVersion: rbac.authorization.k8s.io/v1
102
- kind: ClusterRole
103
- metadata:
104
- name: my-eventmesh-backend-cluster-role
105
- rules:
106
- # permissions for eventtypes, brokers and triggers
107
- - apiGroups:
108
- - "eventing.knative.dev"
109
- resources:
110
- - brokers
111
- - eventtypes
112
- - triggers
113
- verbs:
114
- - get
115
- - list
116
- - watch
117
- # permissions to get subscribers for triggers
118
- # as subscribers can be any resource, we need to give access to all resources
119
- # we fetch subscribers one by one, we only need `get` verb
120
- - apiGroups:
121
- - "*"
122
- resources:
123
- - "*"
124
- verbs:
125
- - get
126
- ---
127
- apiVersion: rbac.authorization.k8s.io/v1
128
- kind: ClusterRoleBinding
129
- metadata:
130
- name: my-eventmesh-backend-cluster-role-binding
131
- subjects:
132
- - kind: ServiceAccount
133
- name: my-eventmesh-backend-service-account
134
- namespace: default
135
- roleRef:
136
- kind: ClusterRole
137
- name: my-eventmesh-backend-cluster-role
138
- apiGroup: rbac.authorization.k8s.io
139
- ---
140
- apiVersion: v1
141
- kind: Secret
142
- metadata:
143
- name: my-eventmesh-backend-secret
144
- namespace: default
145
- annotations:
146
- kubernetes.io/service-account.name: my-eventmesh-backend-service-account
147
- type: kubernetes.io/service-account-token
148
- ```
149
-
150
- To get the token, you can run the following command:
151
-
152
- ```bash
153
- kubectl get secret my-eventmesh-backend-secret -o jsonpath='{.data.token}' | base64 --decode
154
- ```
155
-
156
- Run a quick check to see if the token works:
157
-
158
- ```bash
159
- export KUBE_API_SERVER_URL=$(kubectl config view --minify --output jsonpath="{.clusters[*].cluster.server}") # e.g. "https://192.168.2.151:16443"
160
- export KUBE_SA_TOKEN=$(kubectl get secret my-eventmesh-backend-secret -o jsonpath='{.data.token}' | base64 --decode)
161
- curl -k -H "Authorization: Bearer $KUBE_SA_TOKEN" -X GET "${KUBE_API_SERVER_URL}/apis/eventing.knative.dev/v1/namespaces/default/brokers" | json_pp
162
- # Should see the brokers, or nothing if there are no brokers
163
- # But, should not see an error
164
- ```
165
-
166
- Run a second quick check to see if the token works with the backend
167
-
168
- ```bash
169
- export KNATIVE_EVENT_MESH_BACKEND=http://localhost:8080 # or the URL of the backend
170
- export KUBE_SA_TOKEN=$(kubectl get secret my-eventmesh-backend-secret -o jsonpath='{.data.token}' | base64 --decode)
171
- curl -k -H "Authorization: Bearer $KUBE_SA_TOKEN" -X GET "${KNATIVE_EVENT_MESH_BACKEND}" | json_pp
172
- # Should see the response from the backend such as
173
- # {
174
- # "brokers" : [...],
175
- # "eventTypes" : [...]
176
- #}
177
- ```
178
-
179
- If these quick checks work, you can use the token in the `app-config.yaml` file as the value
180
- of `KNATIVE_EVENT_MESH_TOKEN`.
181
-
182
- ### Legacy Backend Installation
183
-
184
- Configure the scheduler for the entity provider and enable the processor. Add the following code
185
- to `packages/backend/src/plugins/catalog.ts` file:
186
-
187
- ```ts
188
- import {CatalogClient} from "@backstage/catalog-client";
189
- import {
190
- KnativeEventMeshProcessor,
191
- KnativeEventMeshProvider
192
- } from '@knative-extensions/plugin-knative-event-mesh-backend';
193
-
194
- export default async function createPlugin(
195
- env:PluginEnvironment,
196
- ):Promise<Router> {
197
- const builder = await CatalogBuilder.create(env);
198
-
199
- /* ... other processors and/or providers ... */
200
-
201
- // ADD THESE
202
- builder.addEntityProvider(
203
- KnativeEventMeshProvider.fromConfig(env.config, {
204
- logger: env.logger,
205
- scheduler: env.scheduler,
206
- }),
207
- );
208
- const catalogApi = new CatalogClient({
209
- discoveryApi: env.discovery,
210
- });
211
- const knativeEventMeshProcessor = new KnativeEventMeshProcessor(catalogApi, env.logger);
212
- builder.addProcessor(knativeEventMeshProcessor);
213
-
214
- /* ... other processors and/or providers ... */
215
-
216
- const {processingEngine, router} = await builder.build();
217
- await processingEngine.start();
218
- return router;
219
- }
220
- ```
221
-
222
- ### New Backend Installation
223
-
224
- To install on the new backend system, add the following into the `packages/backend/index.ts` file:
225
-
226
- ```ts title=packages/backend/index.ts
227
- import { createBackend } from '@backstage/backend-defaults';
228
-
229
- const backend = createBackend();
230
-
231
- // Other plugins/modules
232
-
233
- backend.add(import('@knative-extensions/plugin-knative-event-mesh-backend/alpha'));
234
-
235
- ```
236
-
237
- > **NOTE**: If you have made any changes to the schedule in the `app-config.yaml` file, then restart to apply the
238
- > changes.
239
-
240
- ## Troubleshooting
241
-
242
- When you start your Backstage application, you can see some log lines as follows:
243
-
244
- ```text
245
- [1] 2024-01-04T09:38:08.707Z knative-event-mesh-backend info Found 1 knative event mesh provider configs with ids: dev type=plugin
246
- ```
247
-
248
- ## Usage
249
-
250
- The plugin will register a few entities in the Backstage catalog.
11
+ The static distribution is a regular Backstage plugin that requires the source code of Backstage to be changed.
251
12
 
252
- Screenshots:
13
+ The dynamic distribution is a plugin that can be installed without changing the source code of Backstage.
253
14
 
254
- - ![Event Mesh plugin](./event-mesh-plugin-components-view.png)
15
+ If you would like to use the dynamic plugin, please see the instructions in the
16
+ [Dynamic Plugin README file](https://github.com/knative-extensions/backstage-plugins/blob/main/backstage/plugins/knative-event-mesh-backend/README-dynamic.md).
255
17
 
256
- - ![Event Mesh plugin](./event-mesh-plugin-apis-view.png)
18
+ If you would like to use the static distribution, please see the documentation on Knative website for
19
+ [installing](https://knative.dev/docs/install/installing-backstage-plugins/)
20
+ and [using](https://knative.dev/docs/eventing/event-registry/eventmesh-backstage-plugin/) the plugin.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knative-extensions/plugin-knative-event-mesh-backend",
3
- "version": "1.15.0",
3
+ "version": "1.16.1",
4
4
  "main": "../dist/alpha.cjs.js",
5
5
  "types": "../dist/alpha.d.ts"
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knative-extensions/plugin-knative-event-mesh-backend",
3
- "version": "1.15.0",
3
+ "version": "1.16.1",
4
4
  "main": "dist/index.cjs.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "Apache-2.0",