-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcxdeploy
More file actions
executable file
·66 lines (53 loc) · 1.67 KB
/
cxdeploy
File metadata and controls
executable file
·66 lines (53 loc) · 1.67 KB
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
#!/usr/bin/env bash
set -euo pipefail
# Deploy components (push image + restart pods + verify)
#
# Must be run from within a project directory (walks up to find pom.xml).
# App is auto-detected from the project root directory name.
#
# Usage: cxdeploy [options] <component...>
# cxdeploy all
# cxdeploy app graphql
#
# Options:
# -r, --remote HOST Target host (default: from kubectl context)
# -n, --namespace NS Kubernetes namespace (default: auto from app)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly SCRIPT_DIR
source "$SCRIPT_DIR/cx.lib"
timer_start
usage() {
cat <<'EOF'
Deploy components (push image + restart pods + verify)
Usage: cxdeploy [options] <component...>
cxdeploy all
cxdeploy app graphql
Options:
-r, --remote HOST Target host (default: from kubectl context)
-n, --namespace NS Kubernetes namespace (default: auto from app)
EOF
echo -e "\nComponents: $(list_components)"
exit 0
}
remote_host=""
namespace=""
declare -a components=()
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help) usage ;;
-r|--remote) require_optarg "$1" "${2:-}"; remote_host="$2"; shift 2 ;;
-n|--namespace) require_optarg "$1" "${2:-}"; namespace="$2"; shift 2 ;;
-*) echo "Unknown option: $1" >&2; exit 1 ;;
*) components+=("$1"); shift ;;
esac
done
[[ -z "$remote_host" ]] && remote_host=$(resolve_host)
require_project_root
acquire_lock "deploy"
load_and_expand_components components
[[ -z "$namespace" ]] && namespace=$("$SCRIPT_DIR/cxconfig" namespace)
_deploy_one() {
deploy_component "$1" "$remote_host" "$namespace"
}
run_parallel _deploy_one components
report_parallel_result "Deployed" components