helm_upgrade_logs 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03d66d3fdf47a4aae5deb85be2a8cc92e1200cb3f60131fecdcbe3fb33cb43d9
4
- data.tar.gz: c31926d9fbcac2ee28fc937c2fe208fe072bb731499e4b64a01f5802200c05b3
3
+ metadata.gz: 26d93b5672aa8c76d679530a967897c2d71d2d206d879af05bf9849439b9f9ef
4
+ data.tar.gz: 2e9b541444bb863f3f6011fee0e86eef6a652341cec28c5b61516926fa3131b4
5
5
  SHA512:
6
- metadata.gz: '007387a207d2fc14adaf5880df0d8f5032a261749c10144bf01484446215d0ae870b15d8d419f441c938047a2ffbe2bcc8a47dba8814fe87f9e3e20ea0d14e4a'
7
- data.tar.gz: 34b7484eb88b14dd33ee250afc2dc5eddf1f4c5fa8c2c1762f93acd1e3a7857354e57dcb92d1c94961f6e4b3a089063f0146570729b251aa921458bcf1a42659
6
+ metadata.gz: 82e32f4f01764809cb0163ed859ac861c77ca95cb11ed42de068c13ba11b13273d0fa2e0e5242c45bc155b4408b8835213a365b4f478fb00f307661aef2e1b28
7
+ data.tar.gz: 86db283f899227b244504af33b8ea87b43dc52b35f73b86772123e0ecc06f7dda6b8c492e6816cf956af36af9057090531eb67a1c80a6bf515473f9417a025bf
@@ -0,0 +1,66 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: HelmUpgradeLogs
9
+
10
+ on:
11
+ push:
12
+ branches: [ main ]
13
+ pull_request:
14
+ branches: [ main ]
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ test:
21
+
22
+ runs-on: ubuntu-latest
23
+ strategy:
24
+ matrix:
25
+ ruby-version: ['3.0']
26
+
27
+ steps:
28
+ - uses: actions/checkout@v3
29
+ # - name: Set up Ruby
30
+ # # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
31
+ # # change this to (see https://github.com/ruby/setup-ruby#versioning):
32
+ # # uses: ruby/setup-ruby@v1
33
+ # uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
34
+ # with:
35
+ # ruby-version: ${{ matrix.ruby-version }}
36
+ # bundler-cache: true # runs 'bundle install' and caches installed gems automatically
37
+ - name: Test
38
+ run: bash -f bin/start_kind.sh
39
+ - name: Waiting for KIND cluster to get ready
40
+ run: sleep 70
41
+ - name: Add bitnami repo
42
+ run: helm repo add bitnami https://charts.bitnami.com/bitnami
43
+ - name: Install through gem exe
44
+ run: ./exe/helm_upgrade_logs --install nginx bitnami/nginx --wait --debug --set service.type=ClusterIP
45
+ # - name: Check pods
46
+ # run: kubectl get pods --all-namespaces
47
+ # - name: Check Events
48
+ # run: kubectl get events --all-namespaces
49
+ #
50
+ # - name: Check logs
51
+ # run: kubectl logs -lapp.kubernetes.io/managed-by=Helm -f
52
+ # - name: helm upgrade install
53
+ # run: helm upgrade --install nginx bitnami/nginx --wait --debug --set service.type=ClusterIP
54
+ # continue-on-error: true
55
+ # - name: Check pods
56
+ # run: sleep 15 && kubectl get pods --all-namespaces
57
+ # - name: Check Events
58
+ # run: sleep 7 && kubectl get events --all-namespaces
59
+ # - name: Run from local
60
+ # run: bash bin/helm_upgrade_logs.sh --install nginx2 bitnami/nginx --wait --debug --set service.type=ClusterIP
61
+
62
+ # - name: Helm upgrade with logs
63
+ # run: curl -s https://raw.githubusercontent.com/SamuelGarrattIqa/helm_upgrade_logs/main/exe/helm_upgrade_logs | bash -s -- --install nginx2 bitnami/nginx --wait
64
+
65
+ # - name: Run tests
66
+ # run: bundle exec rake
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
12
  Gemfile.lock
13
+ /.idea/
@@ -12,6 +12,7 @@
12
12
  <orderEntry type="jdk" jdkName="RVM: ruby-3.0.0" jdkType="RUBY_SDK" />
13
13
  <orderEntry type="sourceFolder" forTests="false" />
14
14
  <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, RVM: ruby-3.0.0) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.11, RVM: ruby-3.0.0) [gem]" level="application" />
15
16
  <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, RVM: ruby-3.0.0) [gem]" level="application" />
16
17
  <orderEntry type="library" scope="PROVIDED" name="parallel (v1.21.0, RVM: ruby-3.0.0) [gem]" level="application" />
17
18
  <orderEntry type="library" scope="PROVIDED" name="parser (v3.1.0.0, RVM: ruby-3.0.0) [gem]" level="application" />
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # HelmUpgradeLogs
1
+ # Helm Upgrade Logs
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/helm_upgrade_logs`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Idea is to show logs of pods and events while doing a kubernetes helm install or upgrade.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,11 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ Still not working in a proper sense of a gem but the following kinda works if you want to install a release called `nginx` from the chart `bitnami/nginx`.
24
+
25
+ ```
26
+ curl -s https://gitlab.com/samuel-garratt/helm_upgrade_logs/-/raw/master/bin/helm_upgrade_logs.sh | bash -s -- --install nginx bitnami/nginx
27
+ ```
26
28
 
27
29
  ## Development
28
30
 
@@ -32,7 +34,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
34
 
33
35
  ## Contributing
34
36
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/helm_upgrade_logs. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/helm_upgrade_logs/blob/master/CODE_OF_CONDUCT.md).
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/helm_upgrade_logs. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://gitlab.com/samuel-garratt/helm_upgrade_logs/blob/master/CODE_OF_CONDUCT.md).
36
38
 
37
39
  ## License
38
40
 
@@ -40,4 +42,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
40
42
 
41
43
  ## Code of Conduct
42
44
 
43
- Everyone interacting in the HelmUpgradeLogs project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/helm_upgrade_logs/blob/master/CODE_OF_CONDUCT.md).
45
+ Everyone interacting in the HelmUpgradeLogs project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/samuel-garratt/helm_upgrade_logs/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +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
data/bin/start_kind.sh ADDED
@@ -0,0 +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.11.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,229 +1,30 @@
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
- rm -rf helm_upgrade_log_tmp
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
+ helm_pid = Process.spawn "helm upgrade #{ARGV.join(' ')}"
8
+
9
+
10
+ sleep 5
11
+ log_pid = Process.spawn 'kubectl logs -lapp.kubernetes.io/managed-by=Helm -f --all-containers --prefix'
12
+ event_pid = Process.spawn 'kubectl get events --watch=true'
13
+
14
+ Process.wait helm_pid
15
+ puts `kill #{log_pid}`
16
+ puts `kill #{event_pid}`
17
+
18
+ #3.times {
19
+ # sleep 5
20
+ # text = `helm status nginx | grep STATUS`
21
+ # if text.include?('deployed')
22
+ # puts 'Contains'
23
+ # else
24
+ # puts 'Nope'
25
+ # end
26
+ #}
27
+ #
28
+ #puts 'Giving up'
29
+ #`kill #{helm_pid}`
30
+ #`kill #{lid}`
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HelmUpgradeLogs
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helm_upgrade_logs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Garratt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-14 00:00:00.000000000 Z
11
+ date: 2022-04-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Basic wrapper around helm and kubectl to allow easy debugging of a helm
14
14
  release. All arguments after a usual helm upgrade are used as normal
@@ -19,13 +19,13 @@ executables:
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
+ - ".github/workflows/test.yml"
22
23
  - ".gitignore"
23
24
  - ".gitlab-ci.yml"
24
25
  - ".idea/helm_upgrade_logs.iml"
25
26
  - ".idea/misc.xml"
26
27
  - ".idea/modules.xml"
27
28
  - ".idea/vcs.xml"
28
- - ".idea/workspace.xml"
29
29
  - ".rspec"
30
30
  - ".rubocop.yml"
31
31
  - CHANGELOG.md
@@ -35,7 +35,9 @@ files:
35
35
  - README.md
36
36
  - Rakefile
37
37
  - bin/console
38
+ - bin/helm_upgrade_logs.sh
38
39
  - bin/setup
40
+ - bin/start_kind.sh
39
41
  - exe/helm_upgrade_logs
40
42
  - helm_upgrade_logs.gemspec
41
43
  - lib/helm_upgrade_logs.rb
data/.idea/workspace.xml DELETED
@@ -1,78 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ChangeListManager">
4
- <list default="true" id="da917fa3-f5ef-4365-9d07-5ed3fa5f86fb" name="Default Changelist" comment="">
5
- <change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
6
- <change beforePath="$PROJECT_DIR$/.idea/helm_upgrade_logs.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/helm_upgrade_logs.iml" afterDir="false" />
7
- <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
8
- <change beforePath="$PROJECT_DIR$/helm_upgrade_logs.gemspec" beforeDir="false" afterPath="$PROJECT_DIR$/helm_upgrade_logs.gemspec" afterDir="false" />
9
- <change beforePath="$PROJECT_DIR$/spec/helm_upgrade_logs_spec.rb" beforeDir="false" afterPath="$PROJECT_DIR$/spec/helm_upgrade_logs_spec.rb" afterDir="false" />
10
- </list>
11
- <option name="SHOW_DIALOG" value="false" />
12
- <option name="HIGHLIGHT_CONFLICTS" value="true" />
13
- <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
14
- <option name="LAST_RESOLUTION" value="IGNORE" />
15
- </component>
16
- <component name="Git.Settings">
17
- <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
18
- </component>
19
- <component name="ProjectId" id="27mcv3bOSxXTerfL7qGu8qJxnE6" />
20
- <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
21
- <component name="ProjectViewState">
22
- <option name="hideEmptyMiddlePackages" value="true" />
23
- <option name="showExcludedFiles" value="true" />
24
- <option name="showLibraryContents" value="true" />
25
- </component>
26
- <component name="PropertiesComponent">
27
- <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
28
- <property name="WebServerToolWindowFactoryState" value="false" />
29
- </component>
30
- <component name="ServiceViewManager">
31
- <option name="viewStates">
32
- <list>
33
- <serviceView>
34
- <treeState>
35
- <expand />
36
- <select />
37
- </treeState>
38
- </serviceView>
39
- </list>
40
- </option>
41
- </component>
42
- <component name="SpringUtil" SPRING_PRE_LOADER_OPTION="true" RAKE_SPRING_PRE_LOADER_OPTION="true" RAILS_SPRING_PRE_LOADER_OPTION="true" />
43
- <component name="SvnConfiguration">
44
- <configuration />
45
- </component>
46
- <component name="TaskManager">
47
- <task active="true" id="Default" summary="Default task">
48
- <changelist id="da917fa3-f5ef-4365-9d07-5ed3fa5f86fb" name="Default Changelist" comment="" />
49
- <created>1649928928769</created>
50
- <option name="number" value="Default" />
51
- <option name="presentableId" value="Default" />
52
- <updated>1649928928769</updated>
53
- <workItem from="1649928930827" duration="666000" />
54
- </task>
55
- <servers />
56
- </component>
57
- <component name="TypeScriptGeneratedFilesManager">
58
- <option name="version" value="1" />
59
- </component>
60
- <component name="WindowStateProjectService">
61
- <state width="1398" height="318" key="GridCell.Tab.0.bottom" timestamp="1649928978709">
62
- <screen x="0" y="0" width="1440" height="900" />
63
- </state>
64
- <state width="1398" height="318" key="GridCell.Tab.0.bottom/0.0.1440.900@0.0.1440.900" timestamp="1649928978709" />
65
- <state width="1398" height="318" key="GridCell.Tab.0.center" timestamp="1649928978707">
66
- <screen x="0" y="0" width="1440" height="900" />
67
- </state>
68
- <state width="1398" height="318" key="GridCell.Tab.0.center/0.0.1440.900@0.0.1440.900" timestamp="1649928978707" />
69
- <state width="1398" height="318" key="GridCell.Tab.0.left" timestamp="1649928978706">
70
- <screen x="0" y="0" width="1440" height="900" />
71
- </state>
72
- <state width="1398" height="318" key="GridCell.Tab.0.left/0.0.1440.900@0.0.1440.900" timestamp="1649928978706" />
73
- <state width="1398" height="318" key="GridCell.Tab.0.right" timestamp="1649928978708">
74
- <screen x="0" y="0" width="1440" height="900" />
75
- </state>
76
- <state width="1398" height="318" key="GridCell.Tab.0.right/0.0.1440.900@0.0.1440.900" timestamp="1649928978708" />
77
- </component>
78
- </project>