generated from layer5io/layer5-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from DelusionalOptimist/mvp
initial meshery-smp-action
- Loading branch information
Showing
5 changed files
with
233 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: "Service Mesh Performance Testing with Meshery" | ||
description: "Validate SMP specification using Meshery" | ||
author: "Layer5" | ||
|
||
inputs: | ||
provider_token: | ||
description: "Provider token to use. NOTE: value of the 'token' key in auth.json" | ||
platform: | ||
description: "Platform to deploy meshery on. Possible values: docker, kubernetes" | ||
default: docker | ||
profile_filename: | ||
description: "Name of the file containing SMP profile" | ||
required: true | ||
|
||
runs: | ||
using: "node12" | ||
main: "main.js" | ||
|
||
branding: | ||
icon: 'check-circle' | ||
color: 'green' |
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,5 @@ | ||
const spawnSync = require('child_process').spawnSync; | ||
const path = require("path"); | ||
|
||
const proc = spawnSync('bash', [path.join(__dirname, 'main.sh')], {stdio: 'inherit'}); | ||
process.exit(proc.status) |
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,44 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
SCRIPT_DIR=$(dirname -- "$(readlink -f "${BASH_SOURCE[0]}" || realpath "${BASH_SOURCE[0]}")") | ||
|
||
main() { | ||
get_dependencies | ||
|
||
setupArgs=() | ||
if [[ -n "${INPUT_PROVIDER_TOKEN:-}" ]]; then | ||
setupArgs+=(--provider-token ${INPUT_PROVIDER_TOKEN}) | ||
fi | ||
|
||
if [[ -n "${INPUT_PLATFORM:-}" ]]; then | ||
setupArgs+=(--platform ${INPUT_PLATFORM}) | ||
fi | ||
|
||
#if [[ -n "${INPUT_SERVICE_MESH:-}" ]]; then | ||
# setupArgs+=(--service-mesh ${INPUT_SERVICE_MESH}) | ||
#fi | ||
|
||
"$SCRIPT_DIR/meshery.sh" "${setupArgs[@]}" | ||
|
||
commandArgs=() | ||
#if [[ -n "${INPUT_SERVICE_MESH:-}" ]]; then | ||
# commandArgs+=(--service-mesh ${INPUT_SERVICE_MESH}) | ||
#fi | ||
|
||
if [[ -n "${INPUT_PROFILE_FILENAME:-}" ]]; then | ||
commandArgs+=(--profile-name ${INPUT_PROFILE_FILENAME}) | ||
fi | ||
|
||
"$SCRIPT_DIR/mesheryctl.sh" "${commandArgs[@]}" | ||
} | ||
|
||
get_dependencies() { | ||
sudo wget https://github.com/mikefarah/yq/releases/download/v4.10.0/yq_linux_amd64 -O /usr/bin/yq --quiet | ||
sudo chmod +x /usr/bin/yq | ||
} | ||
|
||
main |
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,98 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPT_DIR=$(dirname -- "$(readlink -f "${BASH_SOURCE[0]}" || realpath "${BASH_SOURCE[0]}")") | ||
|
||
main() { | ||
|
||
local provider_token= | ||
local PLATFORM=docker | ||
|
||
parse_command_line "$@" | ||
|
||
echo "Checking if a k8s cluster exits..." | ||
kubectl config current-context | ||
if [[ $? -eq 0 ]] | ||
then | ||
echo "Cluster found" | ||
else | ||
printf "Cluster not found. \nCreating one...\n" | ||
create_k8s_cluster | ||
echo "Cluster created successfully!" | ||
fi | ||
|
||
if [[ -z $provider_token ]] | ||
then | ||
printf "Token not provided.\nUsing local provider...\n" | ||
echo '{ "meshery-provider": "None", "token": null }' | jq -c '.token = ""'> ~/auth.json | ||
else | ||
echo '{ "meshery-provider": "Meshery", "token": null }' | jq -c '.token = "'$provider_token'"' > ~/auth.json | ||
fi | ||
cat ~/auth.json | ||
|
||
kubectl config view --minify --flatten > ~/minified_config | ||
mv ~/minified_config ~/.kube/config | ||
|
||
curl -L https://git.io/meshery | PLATFORM=$PLATFORM bash - | ||
|
||
sleep 60 | ||
} | ||
|
||
create_k8s_cluster() { | ||
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 | ||
sudo install minikube-linux-amd64 /usr/local/bin/minikube | ||
sudo apt update -y | ||
sudo apt install conntrack | ||
minikube version | ||
minikube start --driver=none --kubernetes-version=v1.20.7 | ||
sleep 40 | ||
} | ||
|
||
meshery_config() { | ||
mkdir ~/.meshery | ||
config='{"contexts":{"local":{"endpoint":"http://localhost:9081","token":"Default","platform":"docker","adapters":[],"channel":"stable","version":"latest"}},"current-context":"local","tokens":[{"location":"auth.json","name":"Default"}]}' | ||
|
||
echo $config | yq e '."contexts"."local"."adapters"[0]="'$1'"' -P - > ~/.meshery/config.yaml | ||
|
||
cat ~/.meshery/config.yaml | ||
} | ||
|
||
parse_command_line() { | ||
while : | ||
do | ||
case "${1:-}" in | ||
-t|--provider-token) | ||
if [[ -n "${2:-}" ]]; then | ||
provider_token=$2 | ||
shift | ||
else | ||
echo "ERROR: '-t|--provider_token' cannot be empty." >&2 | ||
exit 1 | ||
fi | ||
;; | ||
-p|--platform) | ||
if [[ -n "${2:-}" ]]; then | ||
PLATFORM=$2 | ||
shift | ||
else | ||
echo "ERROR: '-p|--platform' cannot be empty." >&2 | ||
exit 1 | ||
fi | ||
;; | ||
#--service-mesh) | ||
# if [[ -n "${2:-}" ]]; then | ||
# meshery_config "meshery-$2" | ||
# shift | ||
# else | ||
# echo "ERROR: '--service-mesh' cannot be empty." >&2 | ||
# exit 1 | ||
# fi | ||
# ;; | ||
*) | ||
break | ||
;; | ||
esac | ||
shift | ||
done | ||
} | ||
|
||
main "$@" |
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,65 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPT_DIR=$(dirname -- "$(readlink -f "${BASH_SOURCE[0]}" || realpath "${BASH_SOURCE[0]}")") | ||
|
||
declare -A adapters | ||
adapters["istio"]=meshery-istio:10000 | ||
adapters["linkerd"]=meshery-linkerd:10001 | ||
adapters["consul"]=meshery-consul:10002 | ||
adapters["octarine"]=meshery-octarine:10003 | ||
adapters["nsm"]=meshery-nsm:10004 | ||
adapters["kuma"]=meshery-kuma:10007 | ||
adapters["cpx"]=meshery-cpx:10008 | ||
adapters["osm"]=meshery-osm:10009 | ||
adapters["traefik-mesh"]=meshery-traefik-mesh:10006 | ||
|
||
main() { | ||
#local service_mesh_adapter= | ||
#local service_mesh= | ||
local perf_profile_name= | ||
|
||
parse_command_line "$@" | ||
#docker network connect bridge meshery_meshery_1 | ||
#docker network connect minikube meshery_meshery_1 | ||
#docker network connect minikube meshery_meshery-"$service_mesh"_1 | ||
#docker network connect bridge meshery_meshery-"$service_mesh"_1 | ||
|
||
mesheryctl system config minikube -t ~/auth.json | ||
#echo $spec $service_mesh_adapter | ||
|
||
mesheryctl perf apply --file $GITHUB_WORKSPACE/.github/$perf_profile_name -t ~/auth.json | ||
} | ||
|
||
parse_command_line() { | ||
while : | ||
do | ||
case "${1:-}" in | ||
#--service-mesh) | ||
# if [[ -n "${2:-}" ]]; then | ||
# # figure out assigning port numbers and adapter names | ||
# service_mesh=$2 | ||
# service_mesh_adapter=${adapters["$2"]} | ||
# shift | ||
# else | ||
# echo "ERROR: '--service-mesh' cannot be empty." >&2 | ||
# exit 1 | ||
# fi | ||
# ;; | ||
--profile-name) | ||
if [[ -n "${2:-}" ]]; then | ||
perf_profile_name=$2 | ||
shift | ||
else | ||
echo "ERROR: '--profile-name' cannot be empty." >&2 | ||
exit 1 | ||
fi | ||
;; | ||
*) | ||
break | ||
;; | ||
esac | ||
shift | ||
done | ||
} | ||
|
||
main "$@" |