helm_upgrade_logs 0.3.5 â 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +74 -74
- data/.gitignore +13 -13
- data/.gitlab-ci.yml +9 -9
- data/.idea/helm_upgrade_logs.iml +32 -32
- data/.idea/misc.xml +6 -6
- data/.idea/modules.xml +7 -7
- data/.idea/vcs.xml +5 -5
- data/.rspec +3 -3
- data/.rubocop.yml +13 -13
- data/CHANGELOG.md +71 -67
- data/CODE_OF_CONDUCT.md +84 -84
- data/Gemfile +12 -12
- data/LICENSE.txt +21 -21
- data/README.md +77 -77
- data/Rakefile +12 -12
- data/bin/console +15 -15
- data/bin/helm_upgrade_logs.sh +230 -230
- data/bin/setup +8 -8
- data/bin/start_kind.sh +75 -75
- data/exe/helm_test_logs +17 -17
- data/exe/helm_upgrade_logs +97 -96
- data/helm_upgrade_logs.gemspec +35 -35
- data/lib/helm_upgrade_logs/version.rb +6 -6
- data/lib/helm_upgrade_logs.rb +81 -81
- metadata +3 -3
data/bin/helm_upgrade_logs.sh
CHANGED
@@ -1,230 +1,230 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
set -euo pipefail
|
4
|
-
|
5
|
-
if [[ -n "${DOTFILES_DEBUG:-}" ]]; then
|
6
|
-
set -x
|
7
|
-
fi
|
8
|
-
|
9
|
-
function ensure_path_entry() {
|
10
|
-
local entries=("$@")
|
11
|
-
|
12
|
-
for entry in "${entries[@]}"; do
|
13
|
-
if [[ ":${PATH}:" != *":${entry}:"* ]]; then
|
14
|
-
export PATH="${entry}:${PATH}"
|
15
|
-
fi
|
16
|
-
done
|
17
|
-
}
|
18
|
-
|
19
|
-
function log_color() {
|
20
|
-
local color_code="$1"
|
21
|
-
shift
|
22
|
-
|
23
|
-
printf "\033[${color_code}m%s\033[0m\n" "$*" >&2
|
24
|
-
}
|
25
|
-
|
26
|
-
function log_red() {
|
27
|
-
log_color "0;31" "$@"
|
28
|
-
}
|
29
|
-
|
30
|
-
function log_blue() {
|
31
|
-
log_color "0;34" "$@"
|
32
|
-
}
|
33
|
-
|
34
|
-
function log_green() {
|
35
|
-
log_color "1;32" "$@"
|
36
|
-
}
|
37
|
-
|
38
|
-
function log_yellow() {
|
39
|
-
log_color "1;33" "$@"
|
40
|
-
}
|
41
|
-
|
42
|
-
function log_task() {
|
43
|
-
log_blue "đ" "$@"
|
44
|
-
}
|
45
|
-
|
46
|
-
function log_manual_action() {
|
47
|
-
log_red "â ī¸" "$@"
|
48
|
-
}
|
49
|
-
|
50
|
-
function log_c() {
|
51
|
-
log_yellow "đ" "$@"
|
52
|
-
}
|
53
|
-
|
54
|
-
function c() {
|
55
|
-
log_c "$@"
|
56
|
-
"$@"
|
57
|
-
}
|
58
|
-
|
59
|
-
function c_exec() {
|
60
|
-
log_c "$@"
|
61
|
-
exec "$@"
|
62
|
-
}
|
63
|
-
|
64
|
-
function log_error() {
|
65
|
-
log_red "â" "$@"
|
66
|
-
}
|
67
|
-
|
68
|
-
function log_info() {
|
69
|
-
log_red "âšī¸" "$@"
|
70
|
-
}
|
71
|
-
|
72
|
-
function error() {
|
73
|
-
log_error "$@"
|
74
|
-
exit 1
|
75
|
-
}
|
76
|
-
|
77
|
-
function sudo() {
|
78
|
-
if ! command sudo --non-interactive true 2>/dev/null; then
|
79
|
-
log_manual_action "Root privileges are required, please enter your password below"
|
80
|
-
command sudo --validate
|
81
|
-
fi
|
82
|
-
command sudo "$@"
|
83
|
-
}
|
84
|
-
|
85
|
-
function is_apt_package_installed() {
|
86
|
-
local package="$1"
|
87
|
-
|
88
|
-
dpkg -l "${package}" &>/dev/null
|
89
|
-
}
|
90
|
-
|
91
|
-
function not_during_test() {
|
92
|
-
if [[ "${DOTFILES_TEST:-}" == "true" ]]; then
|
93
|
-
log_info "Skipping '${*}' because we are in test mode"
|
94
|
-
else
|
95
|
-
"${@}"
|
96
|
-
fi
|
97
|
-
}
|
98
|
-
|
99
|
-
# https://stackoverflow.com/a/53640320/12156188
|
100
|
-
function service_exists() {
|
101
|
-
local n=$1
|
102
|
-
if [[ $(systemctl list-units --all -t service --full --no-legend "$n.service" | sed 's/^\s*//g' | cut -f1 -d' ') == $n.service ]]; then
|
103
|
-
return 0
|
104
|
-
else
|
105
|
-
return 1
|
106
|
-
fi
|
107
|
-
}
|
108
|
-
|
109
|
-
################################################################
|
110
|
-
## ABOVE is script_libray
|
111
|
-
## BELOW is helm install debug
|
112
|
-
################################################################
|
113
|
-
|
114
|
-
mkdir helm_upgrade_log_tmp
|
115
|
-
watching_pods_logs_file=$(mktemp helm_upgrade_log_tmp/helm-upgrade-logs.watching-pods-logs.XXXXXX)
|
116
|
-
watching_pods_events_file=$(mktemp helm_upgrade_log_tmp/helm-upgrade-logs.watching-pods-events.XXXXXX)
|
117
|
-
|
118
|
-
function cleanup() {
|
119
|
-
rm -f "${watching_pods_logs_file}" "${watching_pods_events_file}" || true
|
120
|
-
jobs -pr | xargs -r kill
|
121
|
-
}
|
122
|
-
|
123
|
-
trap cleanup EXIT
|
124
|
-
|
125
|
-
function prefix_output() {
|
126
|
-
local prefix="$1"
|
127
|
-
local color_code="$2"
|
128
|
-
shift 2
|
129
|
-
|
130
|
-
local sed_replace
|
131
|
-
sed_replace=$(printf "\033[${color_code}m%s: &\033[0m" "${prefix}")
|
132
|
-
|
133
|
-
# shellcheck disable=SC2312
|
134
|
-
"$@" &> >(sed "s,^.*$,${sed_replace}," >&2)
|
135
|
-
}
|
136
|
-
|
137
|
-
function watch_pods() {
|
138
|
-
local release="$1"
|
139
|
-
|
140
|
-
sleep 3 # Prevent flodding the logs with the initial output
|
141
|
-
prefix_output "pods" "1;32" c kubectl get pods \
|
142
|
-
--watch \
|
143
|
-
--selector "app.kubernetes.io/managed-by=Helm,app.kubernetes.io/instance=${release}"
|
144
|
-
}
|
145
|
-
|
146
|
-
function watch_pod_logs() {
|
147
|
-
local pod="$1"
|
148
|
-
|
149
|
-
if grep -q "^${pod}$" "${watching_pods_logs_file}"; then
|
150
|
-
return
|
151
|
-
fi
|
152
|
-
|
153
|
-
echo "${pod}" >>"${watching_pods_logs_file}"
|
154
|
-
|
155
|
-
prefix_output "pod ${pod} logs" "0;34" c kubectl logs \
|
156
|
-
--all-containers \
|
157
|
-
--prefix \
|
158
|
-
--follow \
|
159
|
-
"${pod}" || true
|
160
|
-
|
161
|
-
# remove from watch list (it may be added again)
|
162
|
-
sed -i "/^${pod}$/d" "${watching_pods_logs_file}"
|
163
|
-
}
|
164
|
-
|
165
|
-
function watch_pod_events() {
|
166
|
-
local pod="$1"
|
167
|
-
|
168
|
-
if grep -q "^${pod}$" "${watching_pods_events_file}"; then
|
169
|
-
return
|
170
|
-
fi
|
171
|
-
|
172
|
-
echo "${pod}" >>"${watching_pods_events_file}"
|
173
|
-
|
174
|
-
prefix_output "pod ${pod} events" "0;35" c kubectl get events \
|
175
|
-
--watch-only \
|
176
|
-
--field-selector involvedObject.name="${pod}" || true
|
177
|
-
|
178
|
-
# remove from watch list (it may be added again)
|
179
|
-
sed -i "/^${pod}$/d" "${watching_pods_events_file}"
|
180
|
-
}
|
181
|
-
|
182
|
-
function watch_pods_logs_and_events() {
|
183
|
-
local release="$1"
|
184
|
-
|
185
|
-
sleep 5 # Prevent flodding the logs with the initial output
|
186
|
-
while true; do
|
187
|
-
local args=(
|
188
|
-
--selector "app.kubernetes.io/managed-by=Helm,app.kubernetes.io/instance=${release}"
|
189
|
-
--output jsonpath='{.items[*].metadata.name}'
|
190
|
-
)
|
191
|
-
|
192
|
-
for pod in $(
|
193
|
-
kubectl get pods "${args[@]}"
|
194
|
-
); do
|
195
|
-
watch_pod_events "${pod}" &
|
196
|
-
done
|
197
|
-
|
198
|
-
for pod in $(
|
199
|
-
kubectl get pods \
|
200
|
-
--field-selector=status.phase=Running \
|
201
|
-
"${args[@]}"
|
202
|
-
); do
|
203
|
-
watch_pod_logs "${pod}" &
|
204
|
-
done
|
205
|
-
|
206
|
-
sleep 1
|
207
|
-
done
|
208
|
-
}
|
209
|
-
|
210
|
-
function get_first_non_option() {
|
211
|
-
for arg in "$@"; do
|
212
|
-
if [[ "${arg}" != "-"* ]]; then
|
213
|
-
echo "${arg}"
|
214
|
-
return
|
215
|
-
fi
|
216
|
-
done
|
217
|
-
}
|
218
|
-
|
219
|
-
release="$(get_first_non_option "$@")"
|
220
|
-
|
221
|
-
c helm upgrade "$@" --wait &
|
222
|
-
pid="$!"
|
223
|
-
|
224
|
-
watch_pods "${release}" &
|
225
|
-
|
226
|
-
watch_pods_logs_and_events "${release}" &
|
227
|
-
|
228
|
-
wait "${pid}"
|
229
|
-
kill $(jobs -p)
|
230
|
-
rm -rf helm_upgrade_log_tmp
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -euo pipefail
|
4
|
+
|
5
|
+
if [[ -n "${DOTFILES_DEBUG:-}" ]]; then
|
6
|
+
set -x
|
7
|
+
fi
|
8
|
+
|
9
|
+
function ensure_path_entry() {
|
10
|
+
local entries=("$@")
|
11
|
+
|
12
|
+
for entry in "${entries[@]}"; do
|
13
|
+
if [[ ":${PATH}:" != *":${entry}:"* ]]; then
|
14
|
+
export PATH="${entry}:${PATH}"
|
15
|
+
fi
|
16
|
+
done
|
17
|
+
}
|
18
|
+
|
19
|
+
function log_color() {
|
20
|
+
local color_code="$1"
|
21
|
+
shift
|
22
|
+
|
23
|
+
printf "\033[${color_code}m%s\033[0m\n" "$*" >&2
|
24
|
+
}
|
25
|
+
|
26
|
+
function log_red() {
|
27
|
+
log_color "0;31" "$@"
|
28
|
+
}
|
29
|
+
|
30
|
+
function log_blue() {
|
31
|
+
log_color "0;34" "$@"
|
32
|
+
}
|
33
|
+
|
34
|
+
function log_green() {
|
35
|
+
log_color "1;32" "$@"
|
36
|
+
}
|
37
|
+
|
38
|
+
function log_yellow() {
|
39
|
+
log_color "1;33" "$@"
|
40
|
+
}
|
41
|
+
|
42
|
+
function log_task() {
|
43
|
+
log_blue "đ" "$@"
|
44
|
+
}
|
45
|
+
|
46
|
+
function log_manual_action() {
|
47
|
+
log_red "â ī¸" "$@"
|
48
|
+
}
|
49
|
+
|
50
|
+
function log_c() {
|
51
|
+
log_yellow "đ" "$@"
|
52
|
+
}
|
53
|
+
|
54
|
+
function c() {
|
55
|
+
log_c "$@"
|
56
|
+
"$@"
|
57
|
+
}
|
58
|
+
|
59
|
+
function c_exec() {
|
60
|
+
log_c "$@"
|
61
|
+
exec "$@"
|
62
|
+
}
|
63
|
+
|
64
|
+
function log_error() {
|
65
|
+
log_red "â" "$@"
|
66
|
+
}
|
67
|
+
|
68
|
+
function log_info() {
|
69
|
+
log_red "âšī¸" "$@"
|
70
|
+
}
|
71
|
+
|
72
|
+
function error() {
|
73
|
+
log_error "$@"
|
74
|
+
exit 1
|
75
|
+
}
|
76
|
+
|
77
|
+
function sudo() {
|
78
|
+
if ! command sudo --non-interactive true 2>/dev/null; then
|
79
|
+
log_manual_action "Root privileges are required, please enter your password below"
|
80
|
+
command sudo --validate
|
81
|
+
fi
|
82
|
+
command sudo "$@"
|
83
|
+
}
|
84
|
+
|
85
|
+
function is_apt_package_installed() {
|
86
|
+
local package="$1"
|
87
|
+
|
88
|
+
dpkg -l "${package}" &>/dev/null
|
89
|
+
}
|
90
|
+
|
91
|
+
function not_during_test() {
|
92
|
+
if [[ "${DOTFILES_TEST:-}" == "true" ]]; then
|
93
|
+
log_info "Skipping '${*}' because we are in test mode"
|
94
|
+
else
|
95
|
+
"${@}"
|
96
|
+
fi
|
97
|
+
}
|
98
|
+
|
99
|
+
# https://stackoverflow.com/a/53640320/12156188
|
100
|
+
function service_exists() {
|
101
|
+
local n=$1
|
102
|
+
if [[ $(systemctl list-units --all -t service --full --no-legend "$n.service" | sed 's/^\s*//g' | cut -f1 -d' ') == $n.service ]]; then
|
103
|
+
return 0
|
104
|
+
else
|
105
|
+
return 1
|
106
|
+
fi
|
107
|
+
}
|
108
|
+
|
109
|
+
################################################################
|
110
|
+
## ABOVE is script_libray
|
111
|
+
## BELOW is helm install debug
|
112
|
+
################################################################
|
113
|
+
|
114
|
+
mkdir helm_upgrade_log_tmp
|
115
|
+
watching_pods_logs_file=$(mktemp helm_upgrade_log_tmp/helm-upgrade-logs.watching-pods-logs.XXXXXX)
|
116
|
+
watching_pods_events_file=$(mktemp helm_upgrade_log_tmp/helm-upgrade-logs.watching-pods-events.XXXXXX)
|
117
|
+
|
118
|
+
function cleanup() {
|
119
|
+
rm -f "${watching_pods_logs_file}" "${watching_pods_events_file}" || true
|
120
|
+
jobs -pr | xargs -r kill
|
121
|
+
}
|
122
|
+
|
123
|
+
trap cleanup EXIT
|
124
|
+
|
125
|
+
function prefix_output() {
|
126
|
+
local prefix="$1"
|
127
|
+
local color_code="$2"
|
128
|
+
shift 2
|
129
|
+
|
130
|
+
local sed_replace
|
131
|
+
sed_replace=$(printf "\033[${color_code}m%s: &\033[0m" "${prefix}")
|
132
|
+
|
133
|
+
# shellcheck disable=SC2312
|
134
|
+
"$@" &> >(sed "s,^.*$,${sed_replace}," >&2)
|
135
|
+
}
|
136
|
+
|
137
|
+
function watch_pods() {
|
138
|
+
local release="$1"
|
139
|
+
|
140
|
+
sleep 3 # Prevent flodding the logs with the initial output
|
141
|
+
prefix_output "pods" "1;32" c kubectl get pods \
|
142
|
+
--watch \
|
143
|
+
--selector "app.kubernetes.io/managed-by=Helm,app.kubernetes.io/instance=${release}"
|
144
|
+
}
|
145
|
+
|
146
|
+
function watch_pod_logs() {
|
147
|
+
local pod="$1"
|
148
|
+
|
149
|
+
if grep -q "^${pod}$" "${watching_pods_logs_file}"; then
|
150
|
+
return
|
151
|
+
fi
|
152
|
+
|
153
|
+
echo "${pod}" >>"${watching_pods_logs_file}"
|
154
|
+
|
155
|
+
prefix_output "pod ${pod} logs" "0;34" c kubectl logs \
|
156
|
+
--all-containers \
|
157
|
+
--prefix \
|
158
|
+
--follow \
|
159
|
+
"${pod}" || true
|
160
|
+
|
161
|
+
# remove from watch list (it may be added again)
|
162
|
+
sed -i "/^${pod}$/d" "${watching_pods_logs_file}"
|
163
|
+
}
|
164
|
+
|
165
|
+
function watch_pod_events() {
|
166
|
+
local pod="$1"
|
167
|
+
|
168
|
+
if grep -q "^${pod}$" "${watching_pods_events_file}"; then
|
169
|
+
return
|
170
|
+
fi
|
171
|
+
|
172
|
+
echo "${pod}" >>"${watching_pods_events_file}"
|
173
|
+
|
174
|
+
prefix_output "pod ${pod} events" "0;35" c kubectl get events \
|
175
|
+
--watch-only \
|
176
|
+
--field-selector involvedObject.name="${pod}" || true
|
177
|
+
|
178
|
+
# remove from watch list (it may be added again)
|
179
|
+
sed -i "/^${pod}$/d" "${watching_pods_events_file}"
|
180
|
+
}
|
181
|
+
|
182
|
+
function watch_pods_logs_and_events() {
|
183
|
+
local release="$1"
|
184
|
+
|
185
|
+
sleep 5 # Prevent flodding the logs with the initial output
|
186
|
+
while true; do
|
187
|
+
local args=(
|
188
|
+
--selector "app.kubernetes.io/managed-by=Helm,app.kubernetes.io/instance=${release}"
|
189
|
+
--output jsonpath='{.items[*].metadata.name}'
|
190
|
+
)
|
191
|
+
|
192
|
+
for pod in $(
|
193
|
+
kubectl get pods "${args[@]}"
|
194
|
+
); do
|
195
|
+
watch_pod_events "${pod}" &
|
196
|
+
done
|
197
|
+
|
198
|
+
for pod in $(
|
199
|
+
kubectl get pods \
|
200
|
+
--field-selector=status.phase=Running \
|
201
|
+
"${args[@]}"
|
202
|
+
); do
|
203
|
+
watch_pod_logs "${pod}" &
|
204
|
+
done
|
205
|
+
|
206
|
+
sleep 1
|
207
|
+
done
|
208
|
+
}
|
209
|
+
|
210
|
+
function get_first_non_option() {
|
211
|
+
for arg in "$@"; do
|
212
|
+
if [[ "${arg}" != "-"* ]]; then
|
213
|
+
echo "${arg}"
|
214
|
+
return
|
215
|
+
fi
|
216
|
+
done
|
217
|
+
}
|
218
|
+
|
219
|
+
release="$(get_first_non_option "$@")"
|
220
|
+
|
221
|
+
c helm upgrade "$@" --wait &
|
222
|
+
pid="$!"
|
223
|
+
|
224
|
+
watch_pods "${release}" &
|
225
|
+
|
226
|
+
watch_pods_logs_and_events "${release}" &
|
227
|
+
|
228
|
+
wait "${pid}"
|
229
|
+
kill $(jobs -p)
|
230
|
+
rm -rf helm_upgrade_log_tmp
|
data/bin/setup
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install
|
7
|
-
|
8
|
-
# Do any other automated setup that you need to do here
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
bundle install
|
7
|
+
|
8
|
+
# Do any other automated setup that you need to do here
|
data/bin/start_kind.sh
CHANGED
@@ -1,75 +1,75 @@
|
|
1
|
-
#/bin/bash
|
2
|
-
set +x
|
3
|
-
set -e
|
4
|
-
|
5
|
-
###########################################################################
|
6
|
-
# Usage: bash -f ./start.sh
|
7
|
-
# Supported Options -
|
8
|
-
# --kind-cluster-name=<Kind Cluster Name> (default INTEGRATION_TEST_CLUSTER)
|
9
|
-
# --kind-version (default v0.7.0)
|
10
|
-
# --kubectl-version (default v1.18.0)
|
11
|
-
# --helm-version (default v3.2.0)
|
12
|
-
###########################################################################
|
13
|
-
|
14
|
-
# All Supported Arguments
|
15
|
-
ARGUMENT_LIST=(
|
16
|
-
"kind-cluster-name"
|
17
|
-
"kind-version"
|
18
|
-
"kubectl-version"
|
19
|
-
"helm-version"
|
20
|
-
)
|
21
|
-
|
22
|
-
# Read Arguments
|
23
|
-
opts=$(getopt \
|
24
|
-
--longoptions "$(printf "%s:," "${ARGUMENT_LIST[@]}")" \
|
25
|
-
--name "$(basename "$0")" \
|
26
|
-
--options "" \
|
27
|
-
-- "$@"
|
28
|
-
)
|
29
|
-
|
30
|
-
# Assign Values from Arguments
|
31
|
-
eval set --$opts
|
32
|
-
while [[ $# -gt 0 ]]; do
|
33
|
-
case "$1" in
|
34
|
-
--kind-cluster-name)
|
35
|
-
CLUSTER_NAME=$2
|
36
|
-
shift 2
|
37
|
-
;;
|
38
|
-
--kind-version)
|
39
|
-
KIND_VERSION=$2
|
40
|
-
shift 2
|
41
|
-
;;
|
42
|
-
--kubectl-version)
|
43
|
-
KUBECTL_VERSION=$2
|
44
|
-
shift 2
|
45
|
-
;;
|
46
|
-
--helm-version)
|
47
|
-
HELM_VERSION=$2
|
48
|
-
shift 2
|
49
|
-
;;
|
50
|
-
*)
|
51
|
-
break
|
52
|
-
;;
|
53
|
-
esac
|
54
|
-
done
|
55
|
-
|
56
|
-
# Assign Deafults
|
57
|
-
CLUSTER_NAME=${CLUSTER_NAME:-"testcluster"} # NOT USING THIS. Does not provide benefit for 1 cluster on kind
|
58
|
-
KIND_VERSION=${KIND_VERSION:-v0.12.0}
|
59
|
-
KUBECTL_VERSION=${KUBECTL_VERSION:-v1.20.4}
|
60
|
-
HELM_VERSION=${HELM_VERSION:-v3.8.0}
|
61
|
-
|
62
|
-
echo $(date -u) "[INFO] Downloading Kubectl ..."
|
63
|
-
curl -LO https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl
|
64
|
-
chmod +x ./kubectl
|
65
|
-
|
66
|
-
echo $(date -u) "[INFO] Downloading KIND ..."
|
67
|
-
curl -Lo ./kind https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-$(uname)-amd64
|
68
|
-
chmod +x ./kind
|
69
|
-
|
70
|
-
echo $(date -u) "[INFO] Downloading helm ..."
|
71
|
-
wget https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz
|
72
|
-
tar -zxvf helm-${HELM_VERSION}-linux-amd64.tar.gz
|
73
|
-
|
74
|
-
echo $(date -u) "[INFO] Creating a KIND cluster ..."
|
75
|
-
./kind create cluster
|
1
|
+
#/bin/bash
|
2
|
+
set +x
|
3
|
+
set -e
|
4
|
+
|
5
|
+
###########################################################################
|
6
|
+
# Usage: bash -f ./start.sh
|
7
|
+
# Supported Options -
|
8
|
+
# --kind-cluster-name=<Kind Cluster Name> (default INTEGRATION_TEST_CLUSTER)
|
9
|
+
# --kind-version (default v0.7.0)
|
10
|
+
# --kubectl-version (default v1.18.0)
|
11
|
+
# --helm-version (default v3.2.0)
|
12
|
+
###########################################################################
|
13
|
+
|
14
|
+
# All Supported Arguments
|
15
|
+
ARGUMENT_LIST=(
|
16
|
+
"kind-cluster-name"
|
17
|
+
"kind-version"
|
18
|
+
"kubectl-version"
|
19
|
+
"helm-version"
|
20
|
+
)
|
21
|
+
|
22
|
+
# Read Arguments
|
23
|
+
opts=$(getopt \
|
24
|
+
--longoptions "$(printf "%s:," "${ARGUMENT_LIST[@]}")" \
|
25
|
+
--name "$(basename "$0")" \
|
26
|
+
--options "" \
|
27
|
+
-- "$@"
|
28
|
+
)
|
29
|
+
|
30
|
+
# Assign Values from Arguments
|
31
|
+
eval set --$opts
|
32
|
+
while [[ $# -gt 0 ]]; do
|
33
|
+
case "$1" in
|
34
|
+
--kind-cluster-name)
|
35
|
+
CLUSTER_NAME=$2
|
36
|
+
shift 2
|
37
|
+
;;
|
38
|
+
--kind-version)
|
39
|
+
KIND_VERSION=$2
|
40
|
+
shift 2
|
41
|
+
;;
|
42
|
+
--kubectl-version)
|
43
|
+
KUBECTL_VERSION=$2
|
44
|
+
shift 2
|
45
|
+
;;
|
46
|
+
--helm-version)
|
47
|
+
HELM_VERSION=$2
|
48
|
+
shift 2
|
49
|
+
;;
|
50
|
+
*)
|
51
|
+
break
|
52
|
+
;;
|
53
|
+
esac
|
54
|
+
done
|
55
|
+
|
56
|
+
# Assign Deafults
|
57
|
+
CLUSTER_NAME=${CLUSTER_NAME:-"testcluster"} # NOT USING THIS. Does not provide benefit for 1 cluster on kind
|
58
|
+
KIND_VERSION=${KIND_VERSION:-v0.12.0}
|
59
|
+
KUBECTL_VERSION=${KUBECTL_VERSION:-v1.20.4}
|
60
|
+
HELM_VERSION=${HELM_VERSION:-v3.8.0}
|
61
|
+
|
62
|
+
echo $(date -u) "[INFO] Downloading Kubectl ..."
|
63
|
+
curl -LO https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl
|
64
|
+
chmod +x ./kubectl
|
65
|
+
|
66
|
+
echo $(date -u) "[INFO] Downloading KIND ..."
|
67
|
+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-$(uname)-amd64
|
68
|
+
chmod +x ./kind
|
69
|
+
|
70
|
+
echo $(date -u) "[INFO] Downloading helm ..."
|
71
|
+
wget https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz
|
72
|
+
tar -zxvf helm-${HELM_VERSION}-linux-amd64.tar.gz
|
73
|
+
|
74
|
+
echo $(date -u) "[INFO] Creating a KIND cluster ..."
|
75
|
+
./kind create cluster
|
data/exe/helm_test_logs
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
5
|
-
require "helm_upgrade_logs"
|
6
|
-
|
7
|
-
@release_name = ARGV.find { |arg| !arg.start_with?("-") }
|
8
|
-
@namespace = namespace_from_args(ARGV)
|
9
|
-
|
10
|
-
helm_pid = Process.spawn "helm test #{ARGV.join(" ")}"
|
11
|
-
|
12
|
-
log_pid = Process.spawn(add_ns("kubectl logs -lapp.kubernetes.io/instance=#{@release_name} -f --all-containers --prefix --ignore-errors=true --max-log-requests=20 --timestamps=true --since=1s"))
|
13
|
-
|
14
|
-
Process.wait helm_pid
|
15
|
-
helm_status = $CHILD_STATUS.exitstatus
|
16
|
-
`kill #{log_pid}`
|
17
|
-
exit helm_status
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
5
|
+
require "helm_upgrade_logs"
|
6
|
+
|
7
|
+
@release_name = ARGV.find { |arg| !arg.start_with?("-") }
|
8
|
+
@namespace = namespace_from_args(ARGV)
|
9
|
+
|
10
|
+
helm_pid = Process.spawn "helm test #{ARGV.join(" ")}"
|
11
|
+
|
12
|
+
log_pid = Process.spawn(add_ns("kubectl logs -lapp.kubernetes.io/instance=#{@release_name} -f --all-containers --prefix --ignore-errors=true --max-log-requests=20 --timestamps=true --since=1s"))
|
13
|
+
|
14
|
+
Process.wait helm_pid
|
15
|
+
helm_status = $CHILD_STATUS.exitstatus
|
16
|
+
`kill #{log_pid}`
|
17
|
+
exit helm_status
|