helm_upgrade_logs 0.1.3 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e1693edf80c97ce84e886a2dda47c1207768e259d2b805ad48a005aebf162c3
4
- data.tar.gz: a22c8c807b6fc7142d105f17c3481d8c166519e223cc02cb3663f28ac27c2708
3
+ metadata.gz: 4122417ed0106e7a563e3a52950a20ad697c0f945ee7a5160754698d1f5edcbc
4
+ data.tar.gz: c55b4efa13bba39dbe37ee50c5d443f147dc305060334953c6b1bae505ec14b1
5
5
  SHA512:
6
- metadata.gz: f3a5490f5fe25c03051980d54b750cb8ba23402cf0a8c168e2230d8b7be5235c74f9d2160860de1270c0641b1465020a7ce9a3d61b4ec0758fbd0e88ed01c9f2
7
- data.tar.gz: 9fc06039f972617e254b788ae850fe36d386176cac5ceceb585b113e9cc76e842558ee2460d0ac5f349469eaef2615d350958aec0aca72e603ef6b4cac5e2fb6
6
+ metadata.gz: bc569a6d7f5c2888e3150d552d1c46b35f29260944c661a6ace0a0f82e0bf299ef3e2f40401a18af2401747af6ee617175e2a6a2f5eae184245e480768f6252c
7
+ data.tar.gz: 45f62ed6b1f1abb463bf169800e3f12d0337a7fd61e73c78a7b329f8ea743967bbe9e30fbb89078f6ee5bd6c9bbbd85a4fd9ff79c82101b61d17a3f2a276dc10
@@ -17,8 +17,29 @@ permissions:
17
17
  contents: read
18
18
 
19
19
  jobs:
20
- test:
21
-
20
+ demo_install_run_gem:
21
+ runs-on: ubuntu-latest
22
+ strategy:
23
+ matrix:
24
+ ruby-version: ['3.0']
25
+ steps:
26
+ - uses: actions/checkout@v3
27
+ - name: Set up Ruby
28
+ uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: ${{ matrix.ruby-version }}
31
+ - name: Start KIND cluster
32
+ run: bash -f bin/start_kind.sh
33
+ - name: Waiting for KIND cluster to get ready
34
+ run: sleep 70
35
+ - name: Install gem
36
+ run: gem install helm_upgrade_logs
37
+ - name: Add bitnami repo
38
+ run: helm repo add bitnami https://charts.bitnami.com/bitnami
39
+ - name: Helm install debugging logs
40
+ run: helm_upgrade_logs --install nginx bitnami/nginx --wait --debug --set service.type=ClusterIP
41
+
42
+ test_exe:
22
43
  runs-on: ubuntu-latest
23
44
  strategy:
24
45
  matrix:
@@ -28,31 +49,11 @@ jobs:
28
49
  - uses: actions/checkout@v3
29
50
  - name: Start KIND cluster
30
51
  run: bash -f bin/start_kind.sh
31
- - name: Waiting for KIND cluster to get ready
32
- run: sleep 70
52
+ # - name: Waiting for KIND cluster to get ready
53
+ # run: sleep 70
33
54
  - name: Add bitnami repo
34
55
  run: helm repo add bitnami https://charts.bitnami.com/bitnami
35
- - name: Install through gem exe
36
- run: ./exe/helm_upgrade_logs --install nginx bitnami/nginx --wait --debug --set service.type=ClusterIP --replicaCount=2
37
- # - name: Check pods
38
- # run: kubectl get pods --all-namespaces
39
- # - name: Check Events
40
- # run: kubectl get events --all-namespaces
41
- #
42
- # - name: Check logs
43
- # run: kubectl logs -lapp.kubernetes.io/managed-by=Helm -f
44
- # - name: helm upgrade install
45
- # run: helm upgrade --install nginx bitnami/nginx --wait --debug --set service.type=ClusterIP
46
- # continue-on-error: true
47
- # - name: Check pods
48
- # run: sleep 15 && kubectl get pods --all-namespaces
49
- # - name: Check Events
50
- # run: sleep 7 && kubectl get events --all-namespaces
51
- # - name: Run from local
52
- # run: bash bin/helm_upgrade_logs.sh --install nginx2 bitnami/nginx --wait --debug --set service.type=ClusterIP
53
-
54
- # - name: Helm upgrade with logs
55
- # run: curl -s https://raw.githubusercontent.com/SamuelGarrattIqa/helm_upgrade_logs/main/exe/helm_upgrade_logs | bash -s -- --install nginx2 bitnami/nginx --wait
56
-
57
- # - name: Run tests
58
- # run: bundle exec rake
56
+ - name: Install bitnami
57
+ run: ./exe/helm_upgrade_logs --install nginx bitnami/nginx --wait --debug --set service.type=ClusterIP --set replicaCount=2
58
+ - name: Install Redis
59
+ run: ./exe/helm_upgrade_logs --install redis bitnami/redis --set auth.enabled=false --version 14.0.2 --wait
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
- ## [Unreleased]
1
+ ## [0.1.6] - 2022-04-17
2
2
 
3
- ## [0.1.0] - 2022-04-14
3
+ - Add `helm_test_logs` exe to check logs during `helm test`
4
+ - Add `pod-running-timeout` of 300s to try and pick up logs that might take a while to appear
4
5
 
5
- - Initial release
6
+ ## [0.1.5] - 2022-04-16
7
+
8
+ - Only look at logs for release name
9
+
10
+ ## [0.1.4] - 2022-04-16
11
+
12
+ - Wait for pods with logs to start before watching
data/README.md CHANGED
@@ -20,10 +20,24 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
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`.
23
+ This gem is purely about an `exe` to wrap around `helm` commands and to log helpful commands.
24
+ Once installed, install/upgrade a helm chart with
24
25
 
26
+ ```bash
27
+ helm_upgrade_logs --install redis bitnami/redis --set auth.enabled=false --version 14.0.2 --wait
25
28
  ```
26
- curl -s https://gitlab.com/samuel-garratt/helm_upgrade_logs/-/raw/master/bin/helm_upgrade_logs.sh | bash -s -- --install nginx bitnami/nginx
29
+
30
+ After the `helm_upgrade_logs` command put any options that would normally add after `helm upgrade`.
31
+
32
+ To test a chart showing it logs, in a similar way run
33
+ ```bash
34
+ helm_test_logs redis
35
+ ```
36
+
37
+ This also has a bash script which can be used directly. E.g., to install `nginx` from the chart `bitnami/nginx`.
38
+
39
+ ```
40
+ curl -s https://raw.githubusercontent.com/SamuelGarrattIqa/helm_upgrade_logs/main/bin/helm_upgrade_logs.sh | bash -s -- --install nginx bitnami/nginx
27
41
  ```
28
42
 
29
43
  ## Development
@@ -34,7 +48,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
34
48
 
35
49
  ## Contributing
36
50
 
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).
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/SamuelGarrattIqa/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/SamuelGarrattIqa/helm_upgrade_logs/blob/main/CODE_OF_CONDUCT.md).
38
52
 
39
53
  ## License
40
54
 
@@ -42,4 +56,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
42
56
 
43
57
  ## Code of Conduct
44
58
 
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).
59
+ 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/SamuelGarrattIqa/helm_upgrade_logs/blob/main/CODE_OF_CONDUCT.md).
data/bin/start_kind.sh CHANGED
@@ -55,7 +55,7 @@ done
55
55
 
56
56
  # Assign Deafults
57
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}
58
+ KIND_VERSION=${KIND_VERSION:-v0.12.0}
59
59
  KUBECTL_VERSION=${KUBECTL_VERSION:-v1.20.4}
60
60
  HELM_VERSION=${HELM_VERSION:-v3.8.0}
61
61
 
@@ -0,0 +1,14 @@
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
+
9
+ helm_pid = Process.spawn "helm test #{ARGV.join(' ')}"
10
+
11
+ log_pid = Process.spawn "kubectl logs -lapp.kubernetes.io/managed-by=Helm,app.kubernetes.io/instance=#{$release_name} -f --all-containers --prefix --ignore-errors=true --max-log-requests=20 --timestamps=true"
12
+
13
+ Process.wait helm_pid
14
+ puts `kill #{log_pid}`
@@ -1,15 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
+ require 'open3'
4
5
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..", "lib")
5
6
  require 'helm_upgrade_logs'
6
7
 
8
+ $release_name = ARGV.find { |arg| !arg.start_with?('-') }
9
+
7
10
  helm_pid = Process.spawn "helm upgrade #{ARGV.join(' ')}"
8
11
 
9
12
  event_pid = Process.spawn 'kubectl get events --watch-only=true'
10
13
  service_pid = Process.spawn 'kubectl get services --watch-only=true'
11
- sleep 5
12
- log_pid = Process.spawn 'kubectl logs -lapp.kubernetes.io/managed-by=Helm -f --all-containers --prefix --pod-running-timeout=20s --ignore-errors=true --max-log-requests=20'
14
+
15
+ wait_for_pod_to_log
16
+ log_pid = Process.spawn "kubectl logs -lapp.kubernetes.io/managed-by=Helm,app.kubernetes.io/instance=#{$release_name} -f --all-containers --prefix --ignore-errors=true --max-log-requests=20 --timestamps=true --pod-running-timeout=300s"
13
17
 
14
18
  Process.wait helm_pid
15
19
  puts `kill #{log_pid}`
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HelmUpgradeLogs
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.6"
5
5
  end
@@ -1,7 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'open3'
3
4
  require_relative "helm_upgrade_logs/version"
4
5
 
6
+ # Approach not ideal as it will for all containers to be ready and want to stream logs before that
7
+ def wait_for_container_ready
8
+ wait_pid = Process.spawn 'kubectl wait --for=condition=ContainersReady pod --selector "app.kubernetes.io/managed-by=Helm" --timeout=30s'
9
+ Process.wait wait_pid
10
+ end
11
+
12
+ # Wait for pods with logs to be present
13
+ # Not ideal due to https://github.com/kubernetes/kubernetes/issues/28746
14
+ def wait_for_pod_to_log
15
+ 90.times {
16
+ sleep 1
17
+ stdout, stderr, _ = Open3.capture3 "kubectl logs -lapp.kubernetes.io/managed-by=Helm,app.kubernetes.io/instance=#{$release_name}"
18
+ if stderr.empty? && !stdout.strip.empty?
19
+ puts 'Pods with logs found'
20
+ break
21
+ else
22
+ puts "Waiting for pod logs: #{stderr}"
23
+ end
24
+ }
25
+ end
26
+
5
27
  module HelmUpgradeLogs
6
28
  class Error < StandardError; end
7
29
  # Your code goes here...
metadata CHANGED
@@ -1,20 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helm_upgrade_logs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.6
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-15 00:00:00.000000000 Z
11
+ date: 2022-04-19 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
15
15
  email:
16
16
  - samuel.garratt@sentify.co
17
17
  executables:
18
+ - helm_test_logs
18
19
  - helm_upgrade_logs
19
20
  extensions: []
20
21
  extra_rdoc_files: []
@@ -38,6 +39,7 @@ files:
38
39
  - bin/helm_upgrade_logs.sh
39
40
  - bin/setup
40
41
  - bin/start_kind.sh
42
+ - exe/helm_test_logs
41
43
  - exe/helm_upgrade_logs
42
44
  - helm_upgrade_logs.gemspec
43
45
  - lib/helm_upgrade_logs.rb