-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPD-6446] adding k8s example for node app (#11)
- Loading branch information
Showing
30 changed files
with
403 additions
and
35 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -26,3 +26,4 @@ jobs: | |
run: | | ||
gcloud auth configure-docker | ||
cd java && make docker-multi | ||
cd ../node && make docker-multi |
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,4 +1,4 @@ | ||
VERSION?=1.0.3 | ||
VERSION?=1.0.4 | ||
REGISTRY?=gcr.io/speedscale-demos/java-server:${VERSION} | ||
NAMESPACE?=default | ||
|
||
|
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
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
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,8 @@ | ||
VERSION?=1.0.4 | ||
REGISTRY?=gcr.io/speedscale-demos/node-server:${VERSION} | ||
NAMESPACE?=default | ||
|
||
.PHONY: docker-multi | ||
docker-multi: | ||
@echo "Building and pushing multi-arch Docker image" | ||
@docker buildx build --push --platform linux/amd64,linux/arm64 --tag ${REGISTRY} . |
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
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,62 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eou pipefail | ||
|
||
SERVER_URL=${SERVER_URL:-"localhost:3000"} | ||
loginToken="" | ||
rsaToken="" | ||
|
||
echo $SERVER_URL | ||
|
||
RED='\033[0;31m' | ||
BLUE='\033[0;34m' | ||
NC='\033[0m' | ||
|
||
login() { | ||
echo -e "${RED}Getting login token ${NC}" | ||
loginToken=$(curl -s -X POST -H "Content-Type: application/json" -d '{"username": "admin", "password": "pass" }' "${SERVER_URL}/login" | jq -r .access_token) | ||
echo -e "${RED}Login token is ${loginToken}${NC}" | ||
echo | ||
} | ||
|
||
home() { | ||
echo -e "${BLUE}Getting unauthenticated home ${NC}" | ||
curl -s -X GET "${SERVER_URL}/" | ||
echo | ||
echo | ||
} | ||
|
||
space() { | ||
echo -e "${BLUE}Getting SpaceX ${NC}" | ||
curl -s -X GET -H "Authorization: Bearer ${loginToken}" "${SERVER_URL}/space" | ||
echo | ||
echo | ||
} | ||
|
||
events() { | ||
echo -e "${BLUE}Getting GitHub Events ${NC}" | ||
curl -s -X GET -H "Authorization: Bearer ${loginToken}" "${SERVER_URL}/events" | ||
echo | ||
echo | ||
} | ||
|
||
random-sleep () { | ||
sleep $(( RANDOM % 3 )) | ||
} | ||
|
||
i=0 | ||
while true; do | ||
if [[ $((i % 5)) == 0 ]]; then | ||
login | ||
fi | ||
|
||
home | ||
random-sleep | ||
|
||
space | ||
random-sleep | ||
|
||
events | ||
random-sleep | ||
i=$((i+1)) | ||
done |
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
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
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,5 +1,5 @@ | ||
services: | ||
demo-node: | ||
image: demo-node:latest | ||
node-server: | ||
image: node-server:latest | ||
ports: | ||
- 3000:3000 |
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
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,58 @@ | ||
# Kubernetes Workflow | ||
|
||
Pre-requisites: | ||
* You need to install the [Speedscale helm chart](https://github.com/speedscale/operator-helm) first. | ||
|
||
## Install and Run the App | ||
|
||
First you need to deploy the manifests: | ||
|
||
``` | ||
kubectl apply -k . | ||
``` | ||
|
||
It should spin up 2 deployments (each with 1 pod), 1 service and 1 configmap. You can check the status of the pods with this: | ||
|
||
``` | ||
kubectl get pods | ||
``` | ||
|
||
If the output looks like this then it's working: | ||
|
||
``` | ||
NAME READY STATUS RESTARTS AGE | ||
node-client-68f7c4fdcf-w5spx 1/1 Running 0 16s | ||
node-server-b8997bcdf-gn772 1/1 Running 0 16s | ||
``` | ||
|
||
## Capture | ||
|
||
You can add your service through the [Add a new service wizard](https://app.speedscale.com/?popupId=addNewKubernetes). | ||
|
||
![add-new-service-1](img/spd-add-new-service-1.png) | ||
|
||
After you select your cluster and click next, you can see your namespaces. This demo is installed in the `default` namespace, you should see the workloads: | ||
|
||
![add-new-service-2](img/spd-add-new-service-2.png) | ||
|
||
For the TLS settings, select the very first radio button `Attempt to decode TLS outbound` and this will work automatically for this NodeJS app! | ||
|
||
![add-new-service-3](img/spd-add-new-service-3.png) | ||
|
||
The operator will automatically install the sidecar on your workload and you should get all green checkmarks: | ||
|
||
![add-new-service-4](img/spd-add-new-service-4.png) | ||
|
||
Now you should be able to see the data in Speedscale traffic viewer. | ||
|
||
## Replay | ||
|
||
The first step to replay is to [create a snapshot](https://docs.speedscale.com/guides/creating-a-snapshot/). After a few minutes you should see the data like this in your traffic viewer: | ||
|
||
![traffic-viewer-k8s](img/spd-traffic-viewer-k8s.png) | ||
|
||
The next step is to click the `Replay` and follow the workflow using all the default values. Select your cluster and the `default` namespace. For the test report select the `Regression (1x traffic, with service mocks)` option and `Replay exactly as recorded`. This will kick off service mocks to mock out the SpaceX and GitHub API calls, and then replay the inbound traffic as a regression test case. After the test completes you should see a report. | ||
|
||
![report-k8s](img/spd-report-summary-k8s.png) | ||
|
||
Now try to run with some different test configs to try out performance testing, chaos, or other types of tests! |
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.