-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathjuju.bash
99 lines (85 loc) · 2.07 KB
/
juju.bash
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
#!/bin/bash
#
# Juju helpers
function juju::bootstrap::before
{
echo "> skipping before tasks"
}
function juju::bootstrap::after
{
echo "> skipping after tasks"
}
function juju::bootstrap
{
extra_args=''
if [ "$JUJU_CLOUD" = "vsphere/Boston" ]; then
extra_args="--model-default datastore=vsanDatastore --model-default primary-network=VLAN_2763 --config caas-image-repo=rocks.canonical.com/cdk/jujusolutions"
fi
juju bootstrap "$JUJU_CLOUD" "$JUJU_CONTROLLER" \
-d "$JUJU_MODEL" \
--force --bootstrap-series "$SERIES" \
--bootstrap-constraints arch="amd64" \
--model-default test-mode=true \
--model-default resource-tags=owner=k8sci \
--model-default image-stream=daily \
--model-default automatically-retry-hooks=true \
--model-default logging-config="<root>=DEBUG" \
$extra_args
ret=$?
if (( ret > 0 )); then
exit "$ret"
fi
}
function juju::deploy::before
{
echo "> skipping before tasks"
}
function juju::deploy::after
{
echo "> skipping after tasks"
}
function juju::deploy::overlay
{
cat <<EOF > overlay.yaml
series: $SERIES
applications:
kubernetes-control-plane:
options:
channel: $SNAP_VERSION
kubernetes-worker:
options:
channel: $SNAP_VERSION
EOF
}
function juju::deploy
{
juju deploy -m "$JUJU_CONTROLLER:$JUJU_MODEL" \
--overlay overlay.yaml \
--force \
--channel "$JUJU_DEPLOY_CHANNEL" "$JUJU_DEPLOY_BUNDLE"
ret=$?
if (( ret > 0 )); then
exit "$ret"
fi
}
function juju::wait
{
echo "Waiting for deployment to settle..."
timeout 45m juju-wait -e "$JUJU_CONTROLLER:$JUJU_MODEL" -w
ret=$?
if (( ret > 0 )); then
exit "$ret"
fi
}
function juju::unitAddress
{
py_script="
import sys
import yaml
status_yaml=yaml.safe_load(sys.stdin)
unit = status_yaml['applications']['$1']['units']
units = list(unit.keys())
print(unit[units[0]]['public-address'])
"
juju status -m "$JUJU_CONTROLLER:$JUJU_MODEL" "$1" --format yaml | env python3 -c "$py_script"
}