/
mode_gcloud_docker.sh
71 lines (68 loc) · 3 KB
/
mode_gcloud_docker.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
#!/bin/sh
function gcloudDockerExecutor(){
log "Command $command"
if [ $command == "cluster" ]; then
printf '%s\n' "Mode cluster"
execution="$(gcloudInit) $(gcloudCreateCluster) $(gcloudClusterCredentials) $(helmInstaller) $(infraPods) $(createSecretDockerContainer) $(dockerBagan)"
elif [ $command == "infrastructure" ]; then
printf '%s\n' "Mode infrastrucure"
execution="$(gcloudClusterCredentials) $(helmInstaller) $(infraPods) $(createSecretDockerContainer) $(dockerBagan) "
elif [ $command == "experiment" ]; then
printf '%s\n' "Mode experiment"
execution="$(gcloudClusterCredentials) $(dockerBagan)"
elif [[ $command == "create_cluster" ]]; then
execution="$(gcloudInit) $(gcloudCreateCluster)"
elif [[ $command == "credentials" ]]; then
execution="$(gcloudClusterCredentials)"
elif [[ $command == "secret" ]]; then
execution="$(gcloudClusterCredentials) $(createSecretDockerContainer)"
elif [[ $command == "helm" ]]; then
execution="$(gcloudClusterCredentials) $(helmInstaller)"
elif [[ $command == "helm_init" ]]; then
execution="$(gcloudClusterCredentials) $(helmInit)"
elif [[ $command == "helm_clusterrolebinding" ]]; then
execution="$(gcloudClusterCredentials) $(helmClusterRoleBinding)"
elif [[ $command == "infra_pods" ]]; then
execution="$(gcloudClusterCredentials) $(infraPods)"
elif [[ $command == "grafana" ]]; then
execution="$(gcloudClusterCredentials) $(grafana)"
elif [[ $command == "influxdb" ]]; then
execution="$(gcloudClusterCredentials) $(influxdb)"
elif [[ $command == "services" ]]; then
execution="$(gcloudClusterCredentials) $(services)"
elif [[ $command == "remove_experiments" ]]; then
execution="$(gcloudClusterCredentials) $(removeExperiments)"
elif [[ $command == "grafana_dashboard" ]]; then
execution="$(gcloudClusterCredentials) $(infoDashboard)"
else
color '31;1' "Error no command parsed properly for gcloud_docker: $command"
exit 1
fi
end="$(endMessageDocker)"
log "Executing Docker"
if [ "$private" == "true" ]; then
docker run -ti -v $HOME/.config/gcloud:/root/.config/gcloud \
-v $PWD/tmp:/usr/local/tmp \
-v $PWD/bagan_conf.json:/usr/local/tmp/generator/bagan_conf.json \
-v $ssh:/root/.ssh/id_rsa \
-v $known_hosts:/root/.ssh/known_hosts \
cdsap/bagan-init:$dockerBaganInitVersion /bin/bash -c "
set -e;
export PATH=$PATH:/usr/local/gcloud/google-cloud-sdk/bin/;
cd /usr/local;
$execution
echo 1;
$end"
else
docker run -ti -v $HOME/.config/gcloud:/root/.config/gcloud \
-v $PWD/tmp:/usr/local/tmp \
-v $PWD/bagan_conf.json:/usr/local/tmp/generator/bagan_conf.json \
cdsap/bagan-init:$dockerBaganInitVersion /bin/bash -c "
set -e;
export PATH=$PATH:/usr/local/gcloud/google-cloud-sdk/bin/;
cd /usr/local;
$execution
echo 1;
$end"
fi
}