forked from layer5io/meshery-smi-conformance-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meshery.sh
executable file
·99 lines (84 loc) · 2.06 KB
/
meshery.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/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() {
local provider_token=
local service_mesh_adapter=
#local PLATFORM=docker
parse_command_line "$@"
echo "Checking if a k8s cluster exits..."
if kubectl config current-context
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.\n Using local provider..."
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
kubectl config view --minify --flatten > ~/minified_config
mv ~/minified_config ~/.kube/config
curl -L https://git.io/meshery | DEPLOY_MESHERY=false bash -
#mesheryctl system context create new-context --adapters $service_mesh_adapter --platform docker --url http://localhost:9081 --set --yes
mesheryctl system start --yes
sleep 30
}
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
wait_for_docker
minikube start --driver=docker --kubernetes-version=v1.20.7
sleep 40
}
wait_for_docker() {
while :
do
if docker version -f '{{.Server.Version}} - {{.Client.Version}}'
then
break
else
sleep 5
fi
done
}
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
;;
--service-mesh)
if [[ -n "${2:-}" ]]; then
service_mesh_adapter=meshery-$2
shift
else
echo "ERROR: '--service-mesh' cannot be empty." >&2
exit 1
fi
;;
*)
break
;;
esac
shift
done
}
main "$@"