-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sample App code finalization (#6011)
* fix: update the code according to pierdipi's suggestions * feat: improve the user experience for the setup script * feat: improve the user experience for the solution script * fix: remove unnecessary images * fix: remove the image registry information in the ML services * fix: remove the sample webhook URL * feat: modify the config map to manually disable the scale-to-zero feature * fix: adding the waiting in the solution setup script * fix: adding the waiting in the solution setup script for pipe
- Loading branch information
Showing
17 changed files
with
277 additions
and
180 deletions.
There are no files selected for viewing
3 changes: 0 additions & 3 deletions
3
code-samples/eventing/bookstore-sample-app/solution/ML-bad-word-filter/func.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
code-samples/eventing/bookstore-sample-app/solution/ML-sentiment-analysis/func.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
.../eventing/bookstore-sample-app/solution/node-server/config/100-scale-to-zero-disable.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This is a ConfigMap that disables the scale-to-zero feature in Knative Serving. | ||
# The scale-to-zero feature scales down the number of pods to zero when there are no requests. | ||
# You can learn more about the scale-to-zero feature at https://knative.dev/docs/serving/autoscaling/scale-to-zero/#enable-scale-to-zero | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: config-autoscaler | ||
namespace: knative-serving | ||
data: | ||
enable-scale-to-zero: "false" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
code-samples/eventing/bookstore-sample-app/solution/node-server/config/200-log-trigger.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This Trigger subscribes to the Broker and will forward all the events that it received to event-display. | ||
apiVersion: eventing.knative.dev/v1 | ||
kind: Trigger | ||
metadata: | ||
name: log-trigger | ||
spec: | ||
broker: bookstore-broker | ||
subscriber: | ||
ref: | ||
apiVersion: v1 | ||
kind: Service | ||
name: event-display |
Binary file removed
BIN
-165 KB
code-samples/eventing/bookstore-sample-app/solution/screenshots/Postman.png
Binary file not shown.
Binary file removed
BIN
-488 KB
code-samples/eventing/bookstore-sample-app/solution/screenshots/result.png
Binary file not shown.
Binary file removed
BIN
-222 KB
code-samples/eventing/bookstore-sample-app/solution/screenshots/select-channel.png
Binary file not shown.
Binary file removed
BIN
-187 KB
code-samples/eventing/bookstore-sample-app/solution/screenshots/webhooklink.png
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 0 additions & 104 deletions
104
code-samples/eventing/bookstore-sample-app/solution/setup.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +0,0 @@ | ||
#!/bin/bash | ||
|
||
# Prompt the user to start the installation process | ||
echo "This script will install Knative Serving, Knative Eventing, and install the sample app bookstore on your cluster" | ||
read -p "Press ENTER to continue or Ctrl+C to abort..." | ||
|
||
# Install Knative Serving | ||
echo "Installing Knative Serving..." | ||
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.14.0/serving-crds.yaml | ||
kubectl apply -f https://github.com/knative/serving/releases/download/knative-v1.14.0/serving-core.yaml | ||
kubectl apply -f https://github.com/knative/net-kourier/releases/download/knative-v1.14.0/kourier.yaml | ||
|
||
# Configure Kourier as the default ingress | ||
kubectl patch configmap/config-network --namespace knative-serving --type merge --patch '{"data":{"ingress-class":"kourier.ingress.networking.knative.dev"}}' | ||
|
||
echo "Knative Serving installed successfully." | ||
|
||
# Install Knative Eventing | ||
echo "Installing Knative Eventing..." | ||
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.14.0/eventing-crds.yaml | ||
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.14.0/eventing-core.yaml | ||
echo "Knative Eventing installed successfully." | ||
|
||
# Install Knative imc Broker | ||
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.14.0/in-memory-channel.yaml | ||
kubectl apply -f https://github.com/knative/eventing/releases/download/knative-v1.14.0/mt-channel-broker.yaml | ||
echo "Knative in-memory Channel and Broker installed successfully." | ||
|
||
# Detect whether the user has knative function "func" installed | ||
if ! command -v func &> /dev/null | ||
then | ||
echo "Knative CLI 'func' not found. Please install the Knative CLI by following the instructions at https://knative.dev/docs/admin/install/kn-cli/." | ||
exit | ||
fi | ||
|
||
# Detect whether the user has kamel CLI installed | ||
if ! command -v kamel &> /dev/null | ||
then | ||
echo "Kamel CLI not found. Please install the Kamel CLI by following the instructions at https://camel.apache.org/camel-k/latest/installation/installation.html." | ||
exit | ||
fi | ||
|
||
|
||
|
||
# Prompt for the Docker registry details | ||
echo "Please provide the details of your Container registry to install the Camel-K." | ||
read -p "Enter the registry hostname (e.g., docker.io or quay.io): " REGISTRY_HOST | ||
read -p "Enter the registry username: " REGISTRY_USER | ||
read -s -p "Enter the registry password: " REGISTRY_PASSWORD | ||
echo "All the required details have been captured and saved locally." | ||
|
||
# Set the registry details as environment variables | ||
export REGISTRY_HOST=$REGISTRY_HOST | ||
export REGISTRY_USER=$REGISTRY_USER | ||
export REGISTRY_PASSWORD=$REGISTRY_PASSWORD | ||
|
||
# Set the KO_DOCKER_REPO environment variable | ||
export KO_DOCKER_REPO=$REGISTRY_HOST/$REGISTRY_USER | ||
|
||
# Install the camel-K | ||
kamel install --registry $REGISTRY_HOST--organization $REGISTRY_USER --registry-auth-username $REGISTRY_USER --registry-auth-password $REGISTRY_PASSWORD | ||
|
||
|
||
# Install the Sample Bookstore App | ||
echo "Installing the Sample Bookstore App..., but please follow the instruction below to tell us your registry details" | ||
read -p "Press ENTER to continue..." | ||
|
||
# Install the front end first | ||
cd frontend | ||
kubectl apply -f config | ||
|
||
# Install the node-server | ||
cd ../node-server | ||
kubectl apply -f config | ||
|
||
# Deploy the ML services | ||
cd ../ML-bad-word-filter | ||
func deploy -b=s2i -v | ||
|
||
cd ../ML-sentiment-analysis | ||
func deploy -b=s2i -v | ||
|
||
# Install the db | ||
cd .. | ||
kubectl apply -f db-service | ||
|
||
# Install the sequence | ||
kubectl apply -f sequence/config | ||
|
||
# Ask the user to edit the properties file | ||
echo "Please edit slack-sink/application.properties to provide the webhook URL for Slack." | ||
read -p "Press ENTER to continue..." | ||
|
||
# Create the secret | ||
kubectl create secret generic slack-credentials --from-file=slack-sink/application.properties | ||
|
||
# Install the slack-sink | ||
kubectl apply -f slack-sink/config | ||
|
||
# Ask user to open a new terminal to set the minikube tunnel | ||
echo "If you are using minikube: Please open a new terminal and run 'sudo minikube tunnel' to expose the services to the outside world." | ||
read -p "Press ENTER to continue..." | ||
# FIXME: @pierDipi something wrong here. If run minikube tunnel before bookstore is installed, the localhost:80 will not be accessible | ||
# End of script | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
code-samples/eventing/bookstore-sample-app/solution/slack-sink/config/100-broker.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: eventing.knative.dev/v1 | ||
kind: Broker | ||
metadata: | ||
name: badword-broker | ||
|
||
--- | ||
apiVersion: eventing.knative.dev/v1 | ||
kind: Trigger | ||
metadata: | ||
name: badword-noti-trigger | ||
spec: | ||
broker: bookstore-broker | ||
filter: | ||
attributes: # Trigger will filter events based on BOTH the type and badwordfilter attribute | ||
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: bad # This is the filter that will be applied to the event, only events with the ce-extension badwordfilter: bad will be processed | ||
subscriber: | ||
ref: | ||
apiVersion: eventing.knative.dev/v1 | ||
kind: Broker | ||
name: badword-broker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.