forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelloargo.sh
executable file
·137 lines (106 loc) · 3.7 KB
/
helloargo.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/env bash
#
# Copyright 2015-2017 Applatix, Inc. All rights reserved.
#
# User can specify one of the following actions:
# - up (Install an Argo cluster using the configurations)
# - down (Uninstall an Argo cluster using the configurations)
# - pause (Pause an Argo cluster)
# - resume (Restart an Argo cluster)
# - upgrade (Upgrade an Argo cluster)
# - help (Print help message)
# If it is kept blank, we will bring you into an Argo shell
ACTION=$1
# Command and cluster manager container related
CMD=""
DOCKER_ENV=""
DOCKER_VOL=""
####################################################################
# The following variables are configurations for software version
# They are for install and upgrade.
# Currently we don't support changing registry information during
# upgrade
####################################################################
# Specify where Argo software images should be pulled.
ARGO_DIST_REGISTRY=${ARGO_CLUSTER_DIST_REGISTRY:-"docker.io"}
# Base 64 encoded docker registry secret config. You don't need to specify
# it if the docker registry your image comes from is public
# For example, your docker config look like the follows:
#
# $ cat ~/.docker/config
# {
# "auths": {
# "docker.example.com": {
# "auth": "EXAMPLE_AUTH_SECRET"
# }
# }
# }
#
# Encode this file with base 64 and set the environment variable:
#
# $ export ARGO_CLUSTER_DIST_REGISTRY_SECRETS=$(base64 -i ~/.docker/config)
ARGO_DIST_REGISTRY_SECRETS=${ARGO_CLUSTER_DIST_REGISTRY_SECRETS:-}
# Argo project software would following the following naming format:
# <registry>/<namespace>/image:<version>
AX_NAMESPACE=${ARGO_CLUSTER_IMAGE_NAMESPACE:-"argoproj"}
AX_VERSION=${ARGO_CLUSTER_IMAGE_VERSION:-"latest"}
############################### END OF CONFIGURATIONS #####################################
# Some useful colors
COLOR_RED="\033[0;31m"
COLOR_GREEN="\033[0;32m"
COLOR_YELLOW="\033[0;33m"
COLOR_NORM="\033[0m"
print-usage () {
echo "Usage: $./helloargo.sh [up|down|pause|resume|upgrade|help]" >&2
}
validate-docker () {
echo "Validating docker ..."
if ! docker ps -a > /dev/null; then
echo -e "${COLOR_RED}" >&2
echo " ERROR: Unable to connect to docker daemon. Is Docker running?" >&2
echo -e "${COLOR_NORM}" >&2
exit 1
fi
}
ensure-dirs () {
echo "Ensuring critical directories ..."
mkdir -p ${HOME}/.kube
mkdir -p ${HOME}/.argo
mkdir -p ${HOME}/.ssh
}
set-docker-env () {
DOCKER_ENV="-e AX_NAMESPACE=${AX_NAMESPACE} -e AX_VERSION=${AX_VERSION}"
DOCKER_ENV="${DOCKER_ENV} -e AX_TARGET_CLOUD=${CLOUD_PROVIDER}"
DOCKER_ENV="${DOCKER_ENV} -e ARGO_DIST_REGISTRY=${ARGO_DIST_REGISTRY}"
DOCKER_ENV="${DOCKER_ENV} -e ARGO_DIST_REGISTRY_SECRETS=${ARGO_DIST_REGISTRY_SECRETS}"
}
set-docker-volumes () {
DOCKER_VOL="-v ${HOME}/.aws:/root/.aws -v ${HOME}/.kube:/tmp/ax_kube -v ${HOME}/.ssh:/root/.ssh -v ${HOME}/.argo:/root/.argo"
}
if [[ "${ACTION}" == "help" ]]; then
print-usage
return 0
fi
validate-docker
ensure-dirs
if [[ -z "${ACTION}" ]]; then
CMD="bash"
else
CMD="argocluster ${ACTION}"
fi
echo "Running command:"
echo -e "${COLOR_GREEN}"
echo " $ ${CMD}"
echo -e "${COLOR_NORM}"
set-docker-env
set-docker-volumes
echo -e "${COLOR_GREEN}"
if [[ -n "${ACTION}" ]]; then
echo "Performing interactive operation \"${ACTION}\" on Argo Cluster ..."
else
echo "Starting a shell to perform manual operations on Argo Cluster ..."
fi
echo -e "${COLOR_NORM}"
echo
docker pull ${ARGO_DIST_REGISTRY}/${AX_NAMESPACE}/axclustermanager:${AX_VERSION}
docker run -ti ${DOCKER_VOL} ${DOCKER_ENV} --net host ${ARGO_DIST_REGISTRY}/${AX_NAMESPACE}/axclustermanager:${AX_VERSION} ${CMD}