Skip to content

Commit 1818bf3

Browse files
authored
Fix section "7-Connect Slack via Camel-K" in e2e tutorial. (#6424)
* Fix section "7-Connect Slack via Camel-K" in e2e Overhauled the Camel K operator installation and configuration. Fixed issues with the overall setup, a few typos and wrong directory paths. The Pipe CR had a typo in the Broker name "bad-word-broker". Now it is correctly "badword-broker" Issue #6423. Signed-off-by: Stanislav Jakuschevskij <[email protected]> * Fix paths for slack sink manifests. Signed-off-by: Stanislav Jakuschevskij <[email protected]> --------- Signed-off-by: Stanislav Jakuschevskij <[email protected]>
1 parent b1117ee commit 1818bf3

File tree

1 file changed

+90
-49
lines changed

1 file changed

+90
-49
lines changed

docs/versioned/bookstore/page-7/slack-sink-learning-knative-eventing-and-apache-camel-K-integration.md

Lines changed: 90 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -21,44 +21,81 @@ When a CloudEvent with the type `moderated-comment` and with `ce-bad-word-filter
2121

2222
## **Install prerequisites**
2323

24-
### **Prerequisite 1: Install Apache Camel CLI**
24+
### **Prerequisite 1: Install Apache Camel-Kamelets**
2525

26-
![image](images/image16.png)
27-
28-
Install the Apache Camel K CLI (`kamel`) on your local machine. You can find the installation instructions [here](https://camel.apache.org/camel-k/2.2.x/cli/cli.html){:target="_blank"}.
26+
![image](images/image13.png)
2927

30-
???+ bug "Troubleshooting"
31-
32-
If after installation you run `kamel version` and you get an error message, you may need to add the `kamel` binary to your system's PATH. You can do this by moving the `kamel` binary to a directory that is already in your PATH, or by adding the directory where `kamel` is located to your PATH.
28+
Install Apache Camel K operator on your cluster using any of the methods listed in [the official installation docs](https://camel.apache.org/camel-k/2.8.x/installation/installation.html). We will use the installation via Kustomize:
3329

34-
```sh
35-
$ export PATH=$PATH:<path-to-kamel-binary>
36-
```
30+
```sh
31+
kubectl create ns camel-k && \
32+
kubectl apply -k github.com/apache/camel-k/install/overlays/kubernetes/descoped?ref=v2.8.0 --server-side
33+
```
3734

38-
### **Prerequisite 2: Install Apache Camel-Kamelets**
35+
Now you need to setup an `IntegrationPlatform` with a container registry. You can read more about it in [the official installation docs](https://camel.apache.org/camel-k/2.8.x/installation/installation.html#integration-platform). For all our needs we only need to create the `IntegrationPlatform` CR with a container registry entry. For example let's say we're using a Kind cluster with a local registry named `kind-registry` on port `5000`. Then your `IntegrationPlatform` CR will look like the following:
3936

40-
![image](images/image13.png)
37+
```yaml
38+
apiVersion: camel.apache.org/v1
39+
kind: IntegrationPlatform
40+
metadata:
41+
name: camel-k
42+
namespace: camel-k # Make sure this is the namespace where your operator is running
43+
spec:
44+
build:
45+
registry:
46+
address: kind-registry:5000
47+
insecure: true
48+
```
4149
42-
Next, install Apache Camel K on your cluster using the Apache Camel K CLI:
50+
Install it with one command:
4351
4452
```sh
45-
$ kamel install --registry docker.io --organization <your-organization> --registry-auth-username <your-username> --registry-auth-password <your-password>
53+
cat <<EOF | kubectl apply -f -
54+
apiVersion: camel.apache.org/v1
55+
kind: IntegrationPlatform
56+
metadata:
57+
name: camel-k
58+
namespace: camel-k
59+
spec:
60+
build:
61+
registry:
62+
address: kind-registry:5000
63+
insecure: true
64+
EOF
4665
```
4766

48-
Replace the placeholders with your actual Docker registry information.
49-
50-
If you are using other container registries, you may need to read more [here](https://camel.apache.org/camel-k/2.2.x/installation/registry/registry.html){:target="_blank"} for the installation.
67+
If you are using other container registries, you may need to read more in the [container registry configuration docs](https://camel.apache.org/camel-k/2.8.x/installation/registry/registry.html#how-to-configure){:target="_blank"} for Apache Camel K.
5168

5269
???+ success "Verify"
5370

54-
You will see this message if the installation is successful:
71+
Check the installation status of the operator:
5572

5673
```sh
57-
📦 OLM is not available in the cluster. Fallback to regular installation.
58-
🐪 Camel K installed in namespace default
74+
kubectl get deploy -n camel-k
5975
```
6076

61-
### **Prerequisite 3: Create a Slack App and Generate an Incoming Webhook URL**
77+
You will see the output:
78+
79+
```
80+
NAME READY UP-TO-DATE AVAILABLE AGE
81+
camel-k-operator 1/1 1 1 47h
82+
```
83+
84+
And the IntegrationPlatform:
85+
86+
```sh
87+
kubectl get integrationplatforms -n camel-k
88+
```
89+
90+
You will see the output with the registry address:
91+
92+
```sh
93+
kubectl get integrationplatforms -n camel-k
94+
NAME PHASE BUILD STRATEGY PUBLISH STRATEGY REGISTRY ADDRESS DEFAULT RUNTIME CAMEL VERSION
95+
camel-k Ready routine Jib kind-registry:5000 3.15.3 4.8.5
96+
```
97+
98+
### **Prerequisite 2: Create a Slack App and Generate an Incoming Webhook URL**
6299

63100
![image](images/image21.png)
64101

@@ -74,23 +111,23 @@ Follow the instructions [here](../create-slack-workspace/README.md){:target="_bl
74111

75112
Save this URL as you will need it later.
76113

77-
### **Prerequisite 4: Create a Secret that stores your Slack Credentials**
114+
### **Prerequisite 3: Create a Secret that stores your Slack Credentials**
78115

79116
![image](images/image22.png)
80117

81118
We are storing the webhook URL as a secret. Copy and paste your webhook URL into the file `slack-sink/application.properties`
82119

83-
???+ abstract "_/slack-sink/application.properties_"
120+
???+ abstract "_slack-sink/application.properties_"
84121

85122
```
86123
slack.channel=#bookstore-owner
87124
slack.webhook.url=https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
88125
```
89126

90-
Then run the following command to create the secret in the `/slack-sink` directory:
127+
Then run the following command from the `start` directory:
91128

92129
```sh
93-
kubectl create secret generic slack-credentials --from-file=application.properties
130+
kubectl create secret generic slack-credentials --from-file=slack-sink/application.properties
94131
```
95132

96133
???+ success "Verify"
@@ -107,7 +144,7 @@ kubectl create secret generic slack-credentials --from-file=application.properti
107144

108145
![image](images/image14.png)
109146

110-
We use a feature called ["Pipe"](https://camel.apache.org/camel-k/2.3.x/apis/camel-k.html#_camel_apache_org_v1_Pipe){:target="_blank"} (a.k.a [KameletBinding](https://github.com/apache/camel-k/issues/2625){:target="_blank"}) in Apache Camel K to link event sources and destinations. Specifically, the Pipe connects events from our Broker, our source, to the Slack channel through a Slack sink [Kamelet](https://camel.apache.org/camel-k/2.3.x/kamelets/kamelets.html){:target="_blank"}, our destination.
147+
We use a feature called ["Pipe"](https://camel.apache.org/camel-k/2.8.x/apis/camel-k.html#_camel_apache_org_v1_Pipe){:target="_blank"} (a.k.a [KameletBinding](https://github.com/apache/camel-k/issues/2625){:target="_blank"}) in Apache Camel K to link event sources and destinations. Specifically, the Pipe connects events from our Broker, our source, to the Slack channel through a Slack sink [Kamelet](https://camel.apache.org/camel-k/2.8.x/apis/camel-k.html#_camel_apache_org_v1_Kamelet){:target="_blank"}, our destination.
111148

112149
![image](images/image10.png)
113150

@@ -140,11 +177,11 @@ In the current implementation using Apache Camel K, we **can only filter based o
140177

141178
![image](images/image11.png)
142179

143-
Here, we will be connecting `book-review-broker` with a new Broker called `badword-broker`. And we will be creating a Trigger that helps us perform the filtering with the extension `badwordfilter: good`.
180+
Here, we will be connecting `bookstore-broker` with a new Broker called `badword-broker`. And we will be creating a Trigger that helps us perform the filtering with the extension `badwordfilter: good`.
144181

145-
- 1: Append the following content to your `node-server/config/200-broker.yaml`:
182+
- 1: Create a new file named `slack-sink/config/100-broker.yaml` and add the following content:
146183

147-
???+ abstract "_node-server/config/200-broker.yaml_"
184+
???+ abstract "_slack-sink/config/100-broker.yaml_"
148185

149186
```yaml
150187
---
@@ -157,7 +194,7 @@ Here, we will be connecting `book-review-broker` with a new Broker called `badwo
157194
- 2: Apply the YAML file:
158195

159196
```sh
160-
kubectl apply -f 200-broker.yaml
197+
kubectl apply -f slack-sink/config/100-broker.yaml
161198
```
162199

163200
You should see this message if the Broker is created successfully:
@@ -193,7 +230,6 @@ Broker 'badword-broker' successfully created in namespace 'default'.
193230
```
194231

195232

196-
197233
???+ bug "Troubleshooting"
198234

199235
If there are issues, use the following command to diagnose:
@@ -206,15 +242,15 @@ Broker 'badword-broker' successfully created in namespace 'default'.
206242

207243
![image](images/image12.png)
208244

209-
We are creating the Trigger to process the events that have type moderated-comment, and the extension `badwordfilter: bad` and route them to badword-broker.
245+
We are creating the Trigger to process the events that have type `moderated-comment`, and the extension `badwordfilter: bad` and route them to `badword-broker`.
210246

211247
**Create a Trigger:**
212248

213249
![image](images/image17.png)
214250

215-
- 1: Create a new YAML file named `node-server/config/badword-noti-trigger.yaml` and add the following content:
251+
- 1: Append the following content to your `slack-sink/config/100-broker.yaml`:
216252

217-
???+ abstract "_node-server/config/badword-noti-trigger.yaml_"
253+
???+ abstract "_slack-sink/config/100-broker.yaml_"
218254

219255
```yaml
220256
---
@@ -238,12 +274,13 @@ We are creating the Trigger to process the events that have type moderated-comme
238274
- 2: Apply the YAML file:
239275

240276
```sh
241-
kubectl apply -f node-server/config/badword-noti-trigger.yaml
277+
kubectl apply -f slack-sink/config/100-broker.yaml
242278
```
243279

244280
You should see this message if the Trigger is created successfully:
245281

246-
```
282+
```sh
283+
broker.eventing.knative.dev/badword-broker unchanged
247284
trigger.eventing.knative.dev/badword-noti-trigger created
248285
```
249286

@@ -274,9 +311,9 @@ This setup automatically sends notifications to Slack whenever a new comment tha
274311

275312
![image](images/image15.png)
276313

277-
Create a new file named `slack-sink/config/slack-sink.yaml` and add the following content:
314+
Create a new file named `slack-sink/config/100-slack-sink.yaml` and add the following content:
278315

279-
???+ abstract "_slack-sink/config/slack-sink.yaml_"
316+
???+ abstract "_slack-sink/config/100-slack-sink.yaml_"
280317

281318
```yaml
282319
apiVersion: camel.apache.org/v1
@@ -290,7 +327,7 @@ Create a new file named `slack-sink/config/slack-sink.yaml` and add the followin
290327
ref:
291328
kind: Broker
292329
apiVersion: eventing.knative.dev/v1
293-
name: bad-word-broker
330+
name: badword-broker
294331
properties:
295332
type: moderated-comment
296333
sink:
@@ -306,25 +343,25 @@ Create a new file named `slack-sink/config/slack-sink.yaml` and add the followin
306343
3. Apply the configuration to your Kubernetes cluster:
307344

308345
```sh
309-
$ kubectl apply -f slack-sink/slack-sink.yaml
346+
kubectl apply -f slack-sink/config/100-slack-sink.yaml
310347
```
311348

312349
???+ success "Verify"
313350
You will see this message if the configuration is created successfully:
314351

315352
```sh
316-
pipe.camel.apache.org/slack-sink-pipe created
353+
pipe.camel.apache.org/pipe created
317354
```
318355

319356
But this process will take a few seconds to complete. You can check the status of the pipe by running the following command:
320357

321358
```sh
322-
$ kubectl get pipe slack-sink-pipe
359+
kubectl get pipe pipe
323360
```
324361

325362
```sh
326363
NAME PHASE REPLICAS
327-
slack-sink-pipe Ready 1
364+
pipe Ready 1
328365
```
329366

330367
### **Step 4: Modify the Knative Services to disable scale to zero**
@@ -339,7 +376,7 @@ In this step, we'll configure the notification delivery service to prevent it fr
339376
1. **Check Existing Knative Services:**
340377

341378
```sh
342-
$ kubectl get ksvc
379+
kubectl get ksvc
343380
```
344381

345382
You should see a service named `pipe` listed:
@@ -354,7 +391,13 @@ pipe http://pipe.default.svc.cluster.local pipe-00002 pipe-00002
354391
To prevent the notification service from scaling down to zero, set the minimum number of pods to keep running.
355392

356393
```sh
357-
$ kubectl edit ksvc pipe
394+
kubectl patch ksvc pipe --type merge -p '{"spec":{"template":{"metadata":{"annotations":{"autoscaling.knative.dev/min-scale":"1"}}}}}'
395+
```
396+
397+
Or use the edit command:
398+
399+
```sh
400+
kubectl edit ksvc pipe
358401
```
359402

360403
Add the following annotation:
@@ -372,7 +415,7 @@ This configuration ensures that Knative will always maintain at least one instan
372415
???+ success "Verify"
373416

374417
```sh
375-
$ kubectl get pods
418+
kubectl get pods
376419
```
377420

378421
Periodically check the status of the pipe-deployment pods, and see whether they will disappear! If they stay there, then we are good!
@@ -381,7 +424,7 @@ This configuration ensures that Knative will always maintain at least one instan
381424

382425
![image](images/image4.png)
383426

384-
Now, you have completed building the sample app. When you submit a comment, you should always receive a notification in your test Slack workspace, achieving the same result as shown in the demo video.
427+
Now, you have completed building the sample app. When you submit a "bad" comment, you should receive a notification in your test Slack workspace, achieving the same result as shown in the demo video.
385428

386429
## **Conclusion**
387430

@@ -397,6 +440,4 @@ Congratulations on successfully completing the bookstore sample app tutorial! If
397440

398441
We've prepared additional challenges that build on top of the existing bookstore app for you to tackle. Some solutions are provided, while others are left open to encourage you to explore your own solutions.
399442

400-
401-
402443
[Go to Extra Challenges :fontawesome-solid-paper-plane:](../extra-challenge/README.md){ .md-button .md-button--primary }

0 commit comments

Comments
 (0)