Skip to content

Commit ca9267f

Browse files
committed
update action to just apply patterns
Signed-off-by: Navendu Pottekkat <[email protected]> update action to just apply patterns Signed-off-by: Navendu Pottekkat <[email protected]> remove service mesh Signed-off-by: Navendu Pottekkat <[email protected]> loop through all service meshes Signed-off-by: Navendu Pottekkat <[email protected]> update workflow Signed-off-by: Navendu Pottekkat <[email protected]> update action script Signed-off-by: Navendu Pottekkat <[email protected]> update script Signed-off-by: Navendu Pottekkat <[email protected]> update adapters list Signed-off-by: Navendu Pottekkat <[email protected]> update script Signed-off-by: Navendu Pottekkat <[email protected]> update script Signed-off-by: Navendu Pottekkat <[email protected]> update script Signed-off-by: Navendu Pottekkat <[email protected]>
1 parent b597eca commit ca9267f

File tree

5 files changed

+57
-133
lines changed

5 files changed

+57
-133
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111
# Output of the go coverage tool, specifically when used with LiteIDE
1212
*.out
1313

14+
.vscode/*
15+
1416
# Dependency directories (remove the comment below to include it)
1517
# vendor/

action.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@ name: "Service Mesh Pattern Testing with Meshery"
22
description: "Importing Pattern to Meshery"
33
author: "Layer5"
44
inputs:
5+
# token to authenticate with Meshery
56
provider_token:
67
description: "Provider token to use. NOTE: value of the 'token' key in auth.json"
7-
service_mesh:
8-
# used for provisioning appropriate meshery-adatper
9-
description: "Service mesh to use. e.g: osm, istio etc"
10-
default: istio
11-
required: true
8+
required: false
9+
# platform to deploy Meshery to
1210
platform:
13-
description: "Platform to deploy meshery on. Possible values: docker, kubernetes"
11+
description: "Platform to deploy Meshery to. Allowed values: docker, kubernetes"
1412
default: docker
15-
url:
16-
description: "A raw Github URL for the patterns to be deployed"
17-
default: "https://raw.githubusercontent.com/service-mesh-patterns/service-mesh-patterns/master/samples/IstioFilterPattern.yaml"
18-
required: true
13+
required: false
14+
pattern_url:
15+
description: "URL of the pattern to be deployed"
16+
required: false
17+
# upload the pattern file to the .github folder and reference its path relative to the folder
18+
pattern_file:
19+
description: "Name of the pattern file relative to the .github folder"
20+
required: false
1921
runs:
2022
using: "node12"
2123
main: "main.js"
2224
branding:
23-
icon: 'check-circle'
24-
color: 'green'
25+
icon: 'settings'
26+
color: 'purple'

main.sh

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,7 @@ set -o pipefail
66

77
SCRIPT_DIR=$(dirname -- "$(readlink -f "${BASH_SOURCE[0]}" || realpath "${BASH_SOURCE[0]}")")
88

9-
# Short names
10-
declare -A meshName
11-
meshName["open_service_mesh"]=osm
12-
meshName["traefik_mesh"]=traefik-mesh
13-
meshName["network_service_mesh"]=nsm
14-
159
main() {
16-
local INPUT_SERVICE_MESH="istio"
1710
get_dependencies
1811

1912
setupArgs=()
@@ -25,30 +18,15 @@ main() {
2518
setupArgs+=(--platform ${INPUT_PLATFORM})
2619
fi
2720

28-
if [[ -n "${INPUT_SERVICE_MESH:-}" ]]; then
29-
meshNameLower=`echo $INPUT_SERVICE_MESH | tr -d '"' | tr '[:upper:]' '[:lower:]'`
30-
if [ $meshNameLower = "open_service_mesh" ] || [ $meshNameLower = "traefik_mesh" ] || [ $meshNameLower = "network_service_mesh" ]
31-
then
32-
serviceMeshAbb=${meshName["$meshNameLower"]}
33-
else
34-
serviceMeshAbb=$meshNameLower
35-
fi
36-
setupArgs+=(--service-mesh ${serviceMeshAbb})
37-
fi
38-
3921
bash "$SCRIPT_DIR/meshery.sh" "${setupArgs[@]}"
4022

4123
commandArgs=()
42-
if [[ -n "${INPUT_PATTERN_FILENAME:-}" ]]; then
43-
commandArgs=(--pattern-filename ${INPUT_PATTERN_FILENAME})
44-
fi
45-
46-
if [[ -n "${INPUT_PATTERN_NAME:-}" ]]; then
47-
commandArgs=(--pattern-name ${INPUT_PATTERN_NAME})
24+
if [[ -n "${INPUT_PATTERN_FILE:-}" ]]; then
25+
commandArgs=(--pattern-file ${INPUT_PATTERN_FILE})
4826
fi
4927

50-
if [[ -n "${INPUT_SERVICE_MESH:-}" ]]; then
51-
commandArgs+=(--service-mesh ${meshNameLower})
28+
if [[ -n "${INPUT_PATTERN_URL:-}" ]]; then
29+
commandArgs=(--pattern-url ${INPUT_PATTERN_URL})
5230
fi
5331

5432
bash "$SCRIPT_DIR/mesheryctl.sh" "${commandArgs[@]}"

meshery.sh

Lines changed: 3 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,10 @@ SCRIPT_DIR=$(dirname -- "$(readlink -f "${BASH_SOURCE[0]}" || realpath "${BASH_S
99
main() {
1010

1111
local provider_token=
12-
local PLATFORM=docker
13-
local service_mesh_adapter=
12+
local meshery_platform=
1413

1514
parse_command_line "$@"
1615

17-
echo "Checking if a k8s cluster exits..."
18-
if kubectl config current-context
19-
then
20-
echo "Cluster found"
21-
else
22-
printf "Cluster not found. \nCreating one...\n"
23-
create_k8s_cluster
24-
echo "Cluster created successfully!"
25-
fi
26-
2716
if [[ -z $provider_token ]]
2817
then
2918
printf "Token not provided.\n Using local provider..."
@@ -35,46 +24,11 @@ main() {
3524
kubectl config view --minify --flatten > ~/minified_config
3625
mv ~/minified_config ~/.kube/config
3726

38-
curl -L https://git.io/meshery | DEPLOY_MESHERY=false bash -
39-
40-
mesheryctl system context create new-context --adapters $service_mesh_adapter --platform docker --url http://localhost:9081 --set --yes
41-
42-
mesheryctl system start --yes
27+
curl -L https://git.io/meshery | PLATFORM=$meshery_platform bash -
4328

4429
sleep 30
4530
}
4631

47-
create_k8s_cluster() {
48-
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
49-
sudo install minikube-linux-amd64 /usr/local/bin/minikube
50-
sudo apt update -y
51-
sudo apt install conntrack
52-
minikube version
53-
minikube start --driver=docker --kubernetes-version=v1.20.7
54-
sleep 40
55-
}
56-
57-
wait_for_docker() {
58-
while :
59-
do
60-
if docker version -f '{{.Server.Version}} - {{.Client.Version}}'
61-
then
62-
break
63-
else
64-
sleep 5
65-
fi
66-
done
67-
}
68-
69-
meshery_config() {
70-
mkdir ~/.meshery
71-
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"}]}'
72-
73-
echo $config | yq e '."contexts"."local"."adapters"[0]="'$1'"' -P - > ~/.meshery/config.yaml
74-
75-
cat ~/.meshery/config.yaml
76-
}
77-
7832
parse_command_line() {
7933
while :
8034
do
@@ -90,22 +44,13 @@ parse_command_line() {
9044
;;
9145
-p|--platform)
9246
if [[ -n "${2:-}" ]]; then
93-
PLATFORM=$2
47+
meshery_platform=$2
9448
shift
9549
else
9650
echo "ERROR: '-p|--platform' cannot be empty." >&2
9751
exit 1
9852
fi
9953
;;
100-
--service-mesh)
101-
if [[ -n "${2:-}" ]]; then
102-
service_mesh_adapter=meshery-$2
103-
shift
104-
else
105-
echo "ERROR: '--service-mesh' cannot be empty." >&2
106-
exit 1
107-
fi
108-
;;
10954
*)
11055
break
11156
;;

mesheryctl.sh

100644100755
Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,66 +10,63 @@ declare -A adapters
1010
adapters["istio"]=meshery-istio:10000
1111
adapters["linkerd"]=meshery-linkerd:10001
1212
adapters["consul"]=meshery-consul:10002
13-
adapters["octarine"]=meshery-octarine:10003
14-
adapters["nsm"]=meshery-nsm:10004
1513
adapters["network_service_mesh"]=meshery-nsm:10004
1614
adapters["kuma"]=meshery-kuma:10007
1715
adapters["cpx"]=meshery-cpx:10008
18-
adapters["osm"]=meshery-osm:10009
1916
adapters["open_service_mesh"]=meshery-osm:10009
20-
adapters["traefik-mesh"]=meshery-traefik-mesh:10006
21-
adapters["traefik_mesh"]=meshery-traefik-mesh:10006
2217

2318
main() {
2419

25-
local pattern_filename=pat.yml
26-
local service_mesh=
27-
local service_mesh_adapter=
28-
local url=
29-
20+
local pattern_file=
21+
local pattern_url=
3022

3123
parse_command_line "$@"
3224

33-
shortName=$(echo ${adapters["$service_mesh"]} | cut -d '-' -f2 | cut -d ':' -f1)
34-
35-
docker network connect bridge meshery_meshery_1
36-
docker network connect minikube meshery_meshery_1
37-
docker network connect bridge meshery_meshery-"$shortName"_1
38-
docker network connect minikube meshery_meshery-"$shortName"_1
25+
docker network connect bridge meshery_meshery_1
26+
docker network connect minikube meshery_meshery_1
3927

40-
mesheryctl system config minikube -t ~/auth.json
41-
echo "Deploying $service_mesh..."
42-
mesheryctl mesh deploy --adapter $service_mesh_adapter -t ~/auth.json $service_mesh
43-
sleep 30
44-
docker ps
45-
mesheryctl pattern apply --file $url -t ~/auth.json
46-
sleep 30s
47-
kubectl get all --all-namespaces
28+
for mesh in "${!adapters[@]}"
29+
do
30+
shortName=$(echo ${adapters["$mesh"]} | cut -d '-' -f2 | cut -d ':' -f1)
31+
docker network connect bridge meshery_meshery-"$shortName"_1
32+
docker network connect minikube meshery_meshery-"$shortName"_1
33+
done
34+
35+
mesheryctl system config minikube -t ~/auth.json
36+
37+
if [ -z "$pattern_file" ]
38+
then
39+
mesheryctl pattern apply --file $pattern_url -t ~/auth.json
40+
else
41+
mesheryctl pattern apply --file $pattern_file -t ~/auth.json
42+
fi
43+
44+
sleep 30s
45+
kubectl get all --all-namespaces
4846
}
4947

5048
parse_command_line() {
5149
while :
5250
do
5351
case "${1:-}" in
54-
--service-mesh)
52+
--pattern-file)
53+
if [[ -n "${2:-}" ]]; then
54+
pattern_file=$2
55+
shift
56+
else
57+
echo "ERROR: '--pattern-file' cannot be empty." >&2
58+
exit 1
59+
fi
60+
;;
61+
--pattern-url)
5562
if [[ -n "${2:-}" ]]; then
56-
service_mesh=$2
57-
service_mesh_adapter=${adapters["$2"]}
63+
pattern_url=$2
5864
shift
5965
else
60-
echo "ERROR: '--service-mesh' cannot be empty." >&2
66+
echo "ERROR: '--pattern-url' cannot be empty." >&2
6167
exit 1
6268
fi
6369
;;
64-
# --pattern-filename)
65-
# if [[ -n "${2:-}" ]]; then
66-
# pattern_filename=$2
67-
# shift
68-
# else
69-
# echo "ERROR: '--pattern-filename' cannot be empty." >&2
70-
# exit 1
71-
# fi
72-
# ;;
7370
*)
7471
break
7572
;;

0 commit comments

Comments
 (0)