From 2dca1810bff181dc6d97c814b1351af34bec721d Mon Sep 17 00:00:00 2001 From: Guzman Date: Fri, 24 Jan 2025 17:47:59 +0100 Subject: [PATCH 1/2] sample-app: Fix port of node-server-svc (80 to 8080) Without this, following the instructions that don't require port forwarding (e.g. using "minikube tunnel") fails: the service is exposed on port 80, which is not what the frontend expects. After this commit the setup mimics that of the frontend service, which works both with and without port forwarding. Signed-off-by: Guzman --- .../solution/node-server/config/100-deployment.yaml | 2 +- .../start/node-server/config/100-deployment.yaml | 2 +- docs/versioned/bookstore/page-0.5/environment-setup.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code-samples/eventing/bookstore-sample-app/solution/node-server/config/100-deployment.yaml b/code-samples/eventing/bookstore-sample-app/solution/node-server/config/100-deployment.yaml index 9a56b883383..647320fec91 100644 --- a/code-samples/eventing/bookstore-sample-app/solution/node-server/config/100-deployment.yaml +++ b/code-samples/eventing/bookstore-sample-app/solution/node-server/config/100-deployment.yaml @@ -29,6 +29,6 @@ spec: app: node-server ports: - protocol: TCP - port: 80 + port: 8080 targetPort: 8000 type: LoadBalancer \ No newline at end of file diff --git a/code-samples/eventing/bookstore-sample-app/start/node-server/config/100-deployment.yaml b/code-samples/eventing/bookstore-sample-app/start/node-server/config/100-deployment.yaml index 9a56b883383..647320fec91 100644 --- a/code-samples/eventing/bookstore-sample-app/start/node-server/config/100-deployment.yaml +++ b/code-samples/eventing/bookstore-sample-app/start/node-server/config/100-deployment.yaml @@ -29,6 +29,6 @@ spec: app: node-server ports: - protocol: TCP - port: 80 + port: 8080 targetPort: 8000 type: LoadBalancer \ No newline at end of file diff --git a/docs/versioned/bookstore/page-0.5/environment-setup.md b/docs/versioned/bookstore/page-0.5/environment-setup.md index e43275a9b28..f337939cad7 100644 --- a/docs/versioned/bookstore/page-0.5/environment-setup.md +++ b/docs/versioned/bookstore/page-0.5/environment-setup.md @@ -278,7 +278,7 @@ node-server-svc LoadBalancer 10.101.90.35 80:31792/T If port forwarding is required, open a new terminal and run: ```shell -kubectl port-forward svc/node-server-svc 8080:80 +kubectl port-forward svc/node-server-svc 8080:8080 ``` You should see the following output: From 865ca51a332712f27b8856d10592b2eff773a0fa Mon Sep 17 00:00:00 2001 From: Guzman Date: Sat, 25 Jan 2025 18:33:25 +0100 Subject: [PATCH 2/2] sample-app: Use hardcoded URL as db-insert trigger subscriber This is needed because the node-server service listens on port 8080, and the K8s ref resolver doesn't support custom ports [1], and referring to the node-server-svc service yields: http://node-server-svc.default.svc.cluster.local/insert Instead of the correct URL: http://node-server-svc.default.svc.cluster.local:8080/insert Which results in hanging connections and eventually timeouts when adding new comments that pass the trigger's filter. [1] https://github.com/knative/pkg/blob/dcf159339de2fec9dde678a04cb7a354e912d2bf/resolver/addressable_resolver.go#L227 Signed-off-by: Guzman --- .../solution/node-server/config/200-broker.yaml | 6 +----- docs/versioned/bookstore/page-6/advanced-event-filtering.md | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/code-samples/eventing/bookstore-sample-app/solution/node-server/config/200-broker.yaml b/code-samples/eventing/bookstore-sample-app/solution/node-server/config/200-broker.yaml index 64da1d67df6..9f8f630d385 100644 --- a/code-samples/eventing/bookstore-sample-app/solution/node-server/config/200-broker.yaml +++ b/code-samples/eventing/bookstore-sample-app/solution/node-server/config/200-broker.yaml @@ -15,8 +15,4 @@ spec: type: moderated-comment # This is the filter that will be applied to the event, only events with the ce-type moderated-comment will be processed badwordfilter: good # This is the filter that will be applied to the event, only events with the ce-extension badwordfilter: good will be processed subscriber: - ref: - apiVersion: v1 - kind: Service - name: node-server-svc - uri: /insert # This is the path where the event will be sent to the subscriber, see /insert in node-server code: index.js + uri: http://node-server-svc.default.svc.cluster.local:8080/insert # This is the path where the event will be sent to the subscriber, see /insert in node-server code: index.js diff --git a/docs/versioned/bookstore/page-6/advanced-event-filtering.md b/docs/versioned/bookstore/page-6/advanced-event-filtering.md index cb8d87d1a91..6bc3da6efc1 100644 --- a/docs/versioned/bookstore/page-6/advanced-event-filtering.md +++ b/docs/versioned/bookstore/page-6/advanced-event-filtering.md @@ -43,11 +43,7 @@ Append the following Trigger configuration to the existing `node-server/config/2 type: moderated-comment # This is the filter that will be applied to the event, only events with the ce-type moderated-comment will be processed badwordfilter: good # This is the filter that will be applied to the event, only events with the ce-extension badwordfilter: good will be processed subscriber: - ref: - apiVersion: v1 - kind: Service - name: node-server-svc - uri: /insert # This is the path where the event will be sent to the subscriber, see /insert in node-server code: index.js + uri: http://node-server-svc.default.svc.cluster.local:8080/insert # This is the path where the event will be sent to the subscriber, see /insert in node-server code: index.js ``` ```shell