Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
download boutique demo app frontend project and install Telepresence …
Browse files Browse the repository at this point in the history
…script and instructions
  • Loading branch information
leoporoli committed Sep 5, 2024
1 parent 47eba9b commit 5159ab5
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 55 deletions.
35 changes: 24 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ In this demo, you will:

1. Set up a Kubernetes cluster with a demo online boutique app installed on it (3 minutes)
2. Visualize your stable, staging cluster using the Kardinal Dashboard (30 seconds)
3. Use Kardinal to set up a lightweight "dev environment" inside of your cluster so you can quickly and efficiently test changes (30 seconds)
3. Use Kardinal to set up a lightweight "dev environment" inside your cluster, so you can quickly and efficiently test changes (30 seconds)
4. Visualize your cluster in the Kardinal Dashboard again, to see how the Kardinal "dev environment" is structured (30 seconds)
5. Clean up the dev flow and return the cluster to normal state (15 seconds)

Expand Down Expand Up @@ -62,7 +62,7 @@ Follow these steps to explore the Kardinal Playground.
This command sets up a development version of the frontend alongside the main version. It will output a URL, but it's not yet accessible because it's inside the Codespace.
- To interact with the dev version, first stop your previous gateway (if it's still running). Currently you can only run one gateway at a time in this demo.
- To interact with the dev version, first stop your previous gateway (if it's still running). Currently, you can only run one gateway at a time in this demo.
- Copy the flow-id from the previous command (it should look like `dev-[a-zA-Z0-9]`)
- Run the following to forward the dev demo application port from within Codespaces to a URL you can access
```bash
Expand All @@ -72,7 +72,20 @@ Follow these steps to explore the Kardinal Playground.
- Notice how two items are already in the cart, as the dev database is configured to be seeded with some dev data
- Browse through the store and add items to your cart in the dev version

4. 🔧 Create a second and more complex dev flow:
4. 🧹 Clean up the dev flow:

```bash
kardinal flow delete <flow_id>
```

This command removes the development version of the app.

- Return to the dashboard one last time
- Observe that the environment has been cleaned up and returned to its original state, with only the main services visible.
- Return to the main online boutique URL (the first nginx URL)
- Confirm that it still works and has not been impacted by the development workflow

5. 🔧 Create a second and more complex dev flow:

Now our demo website is preparing for a big sale, we need to add a new feature to both the backend and the frontend to handle the new sale. This feature is contained into 2 images: `frontend` and `productcatalogservice`.
We can rely on support for multiple services to coordinate the deployment in a sigle flow. Using the flag `-s`, we can include multiple services and images:
Expand All @@ -83,7 +96,7 @@ Follow these steps to explore the Kardinal Playground.

This command sets up a development version of the frontend alongside the main version. It will output a URL, but it's not yet accessible because it's inside the Codespace.

- To interact with the dev version, first stop your previous gateway (if it's still running). Currently you can only run one gateway at a time in this demo.
- To interact with the dev version, first stop your previous gateway (if it's still running). Currently, you can only run one gateway at a time in this demo.
- Copy the flow-id from the previous command (it should look like `dev-[a-zA-Z0-9]`)
- Run the following to forward the dev demo application port from within Codespaces to a URL you can access
```bash
Expand All @@ -93,26 +106,26 @@ Follow these steps to explore the Kardinal Playground.
- Notice how two items are already in the cart, as the dev database is configured to be seeded with some dev data
- Browse through the store and add items to your cart in the dev version
5. 🔍 Compare the new structure on app.kardinal.dev:
6. 🔍 Compare the new structure on app.kardinal.dev:
- Go back to the Kardinal dashboard
- Notice the changes in the environment:
- A dev version of the frontend is now deployed in the same namespace
- Dev traffic is routed to the dev version of the frontend
- The main version still works independently in the same namespace
6. 🧹 Clean up the dev flow:
7. 🧹 Clean up the dev flow:
```bash
kardinal flow delete <flow_id>
```
This command removes the development version of the app.
8. 🔧 Create a third dev flow to intercept the traffic to a local port with Telepresence and test a new change in the UI without having to rebuild and deploy the container in the cluster.
- Return to the dashboard one last time
- Observe that the environment has been cleaned up and returned to its original state, with only the main services visible.
- Return to the main online boutique URL (the first nginx URL)
- Confirm that it still works and has not been impacted by the development workflow
Execute the following script to download the frontend project of the boutique demo example and install the Telepresence tool
```bash
./scripts/telepresence-flow-bootstrap.sh
```
This guide showcases the power of Kardinal by demonstrating the seamless creation and deletion of a dev environment alongside your main, stable setup. You'll experience firsthand how Kardinal enables isolated development without risking stability of a shared cluster, or disrupting the live environment. 🚀

Expand Down
48 changes: 48 additions & 0 deletions scripts/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

set -euo pipefail

VERBOSE=false

# Spinning cursor animation
spinner() {
local pid=$1
local delay=0.1
local spinstr='|/-\'
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
local temp=${spinstr#?}
printf " [%c] " "$spinstr"
local spinstr=$temp${spinstr%"$temp"}
sleep $delay
printf "\b\b\b\b\b\b"
done
printf " \b\b\b\b"
}

log() {
echo "$1"
}

log_verbose() {
if $VERBOSE; then
echo "$1"
fi
}

log_error() {
echo "❌ Error: $1" >&2
echo "Please email us at [email protected] for assistance." >&2
exit 1
}

run_command_with_spinner() {
if $VERBOSE; then
"$@"
else
"$@" >/dev/null 2>&1 &
local pid=$!
spinner $pid
wait $pid
return $?
fi
}
47 changes: 3 additions & 44 deletions scripts/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,14 @@

set -euo pipefail

VERBOSE=false

TENANT_UUID=""
KARDINAL_CLI_PATH=""
KARDINAL_DATA_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/kardinal"
UUID_FILE="$KARDINAL_DATA_DIR/fk-tenant-uuid"


# Spinning cursor animation
spinner() {
local pid=$1
local delay=0.1
local spinstr='|/-\'
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
local temp=${spinstr#?}
printf " [%c] " "$spinstr"
local spinstr=$temp${spinstr%"$temp"}
sleep $delay
printf "\b\b\b\b\b\b"
done
printf " \b\b\b\b"
}

log() {
echo "$1"
}

log_verbose() {
if $VERBOSE; then
echo "$1"
fi
}

log_error() {
echo "❌ Error: $1" >&2
echo "Please email us at [email protected] for assistance." >&2
exit 1
}

run_command_with_spinner() {
if $VERBOSE; then
"$@"
else
"$@" >/dev/null 2>&1 &
local pid=$!
spinner $pid
wait $pid
return $?
fi
}
# Source the common script
source ./common.sh

setup_docker() {
log "🐳 Setting up Docker..."
Expand Down
50 changes: 50 additions & 0 deletions scripts/telepresence-flow-bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

BOUTIQUE_DEMO_APP_REPO="https://github.com/kurtosis-tech/new-obd.git"

set -euo pipefail

# Source the common script
source ./common.sh

download_boutique_remo() {
log "⏬ Downloading the frontend project from the boutique demo app repository..."
run_command_with_spinner git clone --no-checkout $BOUTIQUE_DEMO_APP_REPO || log_error "Failed to download the frontend project"
cd ./new-obd
git sparse-checkout init --cone
git sparse-checkout set src/frontend
git checkout main
log_verbose "Frontend project successfully downloaded."
}

install_telepresence() {
log "⏬ Installing Telepresence CLI..."
run_command_with_spinner curl -fL https://app.getambassador.io/download/tel2/linux/amd64/latest/telepresence -o /usr/local/bin/telepresence

chmod a+x /usr/local/bin/telepresence
log_verbose "Telepresence CLI successfully installed."

log "⏬ Installing Telepresence traffic manager in the cluster..."
run_command_with_spinner telepresence helm install --set trafficManager.serviceMesh.type=istio
log_verbose "Telepresence traffic manager successfully installed."
}


main() {
# Check if an argument is provided
if [ $# -gt 0 ] && [ "$1" = "--verbose" ]; then
VERBOSE=true
log "Verbose mode enabled."
fi

# log "🕰️ This can take around 3 minutes! Familiarize yourself with the repository while this happens."

download_boutique_remo

# log "✅ Startup completed! Minikube, Istio, Kontrol, and Kardinal Manager are ready."
# log "🏠 Tenant UUID: $TENANT_UUID"
# log "📊 Kardinal Dashboard: https://app.kardinal.dev/$(cat ~/.local/share/kardinal/fk-tenant-uuid)/traffic-configuration"
# exec bash
}

main "$@"

0 comments on commit 5159ab5

Please sign in to comment.