helm_upgrade_logs 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +16 -2
- data/lib/helm_upgrade_logs/version.rb +1 -1
- data/lib/helm_upgrade_logs.rb +12 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5195e2b08d8a4c6838d8cbf16fa070551bed1953008f46873d6f41ac07c829d
|
4
|
+
data.tar.gz: 338bab0411ebc7e0a059b66392a30342187a6a9fb1ba623a3796baee331a5119
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d7b9c585181eef228e5bdaebacbc3d5d1764e6d0bbcb6aeb62db8389482f2011bba423d4d836dae44c8c16d0e2c94cab8352ef60b5376cb884b46ed2e858c75
|
7
|
+
data.tar.gz: 1417cbbe9bcbcc02501d62c30eac1b6d13b9ee8bbe060f577e2342d188539e215ea73c32d25a072bb3f401a29fd3436a5a8de524ebdd73fce829d820eed459a3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -20,7 +20,9 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
This gem is purely about an `exe` to wrap around `helm` commands and to log
|
23
|
+
This gem is purely about an `exe` to wrap around `helm` commands and to log events and pod logs that happen as
|
24
|
+
part of that release while it is being released.
|
25
|
+
|
24
26
|
Once installed, install/upgrade a helm chart with
|
25
27
|
|
26
28
|
```bash
|
@@ -29,17 +31,29 @@ helm_upgrade_logs --install redis bitnami/redis --set auth.enabled=false --versi
|
|
29
31
|
|
30
32
|
After the `helm_upgrade_logs` command put any options that would normally add after `helm upgrade`.
|
31
33
|
|
34
|
+
This library waits for logs to start in pods for 90 seconds or controlled by environment variable `helm_upgrade_logs_log_start`.
|
35
|
+
After that it waits 35 seconds for logs to start in pods after the first one.
|
36
|
+
This is controlled by environment variable `helm_upgrade_logs_pod_start`
|
37
|
+
|
32
38
|
To test a chart showing it logs, in a similar way run
|
33
39
|
```bash
|
34
40
|
helm_test_logs redis
|
35
41
|
```
|
36
42
|
|
37
|
-
|
43
|
+
### Aside bash script
|
44
|
+
|
45
|
+
This also has a bash script which can be used directly although it will probably not work on CI
|
46
|
+
and also does not close background processes so not ideal.
|
47
|
+
|
48
|
+
However if you do want to try it, to install `nginx` from the chart `bitnami/nginx` run
|
38
49
|
|
39
50
|
```
|
40
51
|
curl -s https://raw.githubusercontent.com/SamuelGarrattIqa/helm_upgrade_logs/main/bin/helm_upgrade_logs.sh | bash -s -- --install nginx bitnami/nginx
|
41
52
|
```
|
42
53
|
|
54
|
+
## TODO
|
55
|
+
* Make library handle `n`, `--namespace` from helm command
|
56
|
+
|
43
57
|
## Development
|
44
58
|
|
45
59
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/helm_upgrade_logs.rb
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
require 'open3'
|
4
4
|
require_relative "helm_upgrade_logs/version"
|
5
5
|
|
6
|
+
ENV['helm_upgrade_logs_log_start'] ||= '90'
|
7
|
+
ENV['helm_upgrade_logs_pod_start'] ||= '35'
|
8
|
+
|
6
9
|
# Approach not ideal as it will for all containers to be ready and want to stream logs before that
|
7
10
|
def wait_for_container_ready
|
8
11
|
wait_pid = Process.spawn 'kubectl wait --for=condition=ContainersReady pod --selector "app.kubernetes.io/managed-by=Helm" --timeout=30s'
|
@@ -12,29 +15,29 @@ end
|
|
12
15
|
# Wait for pods with logs to be present
|
13
16
|
# Not ideal due to https://github.com/kubernetes/kubernetes/issues/28746
|
14
17
|
def wait_for_pod_to_log
|
15
|
-
|
18
|
+
ENV['helm_upgrade_logs_log_start'].to_i.times do |i|
|
16
19
|
sleep 1
|
17
|
-
stdout, stderr, _ = Open3.capture3 "kubectl logs -lapp.kubernetes.io/
|
20
|
+
stdout, stderr, _ = Open3.capture3 "kubectl logs -lapp.kubernetes.io/instance=#{$release_name}"
|
18
21
|
if stderr.empty? && !stdout.strip.empty?
|
19
|
-
puts 'Pods with logs found'
|
22
|
+
puts '[INFO] Pods with logs found'
|
20
23
|
break
|
21
24
|
else
|
22
|
-
puts "Waiting for pod logs: #{stderr}"
|
25
|
+
puts "[INFO] Waiting for pod logs: #{stderr}" if i % 3 == 0
|
23
26
|
end
|
24
|
-
|
27
|
+
end
|
25
28
|
end
|
26
29
|
|
27
30
|
def wait_for_specific_pod_to_log(pod_name)
|
28
|
-
|
31
|
+
ENV['helm_upgrade_logs_pod_start'].to_i.times do |i|
|
29
32
|
sleep 1
|
30
33
|
stdout, stderr, _ = Open3.capture3 "kubectl logs #{pod_name}"
|
31
34
|
if stderr.empty? && !stdout.strip.empty?
|
32
|
-
puts "Pod #{pod_name} with logs found"
|
35
|
+
puts "[INFO] Pod #{pod_name} with logs found"
|
33
36
|
break
|
34
37
|
else
|
35
|
-
puts "Waiting for pod #{pod_name} logs: #{stderr}"
|
38
|
+
puts "[INFO] Waiting for pod #{pod_name} logs: #{stderr}" if i % 2 == 0
|
36
39
|
end
|
37
|
-
|
40
|
+
end
|
38
41
|
end
|
39
42
|
|
40
43
|
def get_pods
|