helm_upgrade_logs 0.1.1 → 0.1.4

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: 26d93b5672aa8c76d679530a967897c2d71d2d206d879af05bf9849439b9f9ef
4
- data.tar.gz: 2e9b541444bb863f3f6011fee0e86eef6a652341cec28c5b61516926fa3131b4
3
+ metadata.gz: 864a01e8bcbdeac4562c86337446da6a9f95915ced886c546f3914eccaca9bf9
4
+ data.tar.gz: 806925901b5506f6294c5c211bd8c2df91294118441273b02af469f70938f792
5
5
  SHA512:
6
- metadata.gz: 82e32f4f01764809cb0163ed859ac861c77ca95cb11ed42de068c13ba11b13273d0fa2e0e5242c45bc155b4408b8835213a365b4f478fb00f307661aef2e1b28
7
- data.tar.gz: 86db283f899227b244504af33b8ea87b43dc52b35f73b86772123e0ecc06f7dda6b8c492e6816cf956af36af9057090531eb67a1c80a6bf515473f9417a025bf
6
+ metadata.gz: 3bb83e455d0a989793547053ffbd46ad6be6fca3354405acf0d6f71c2a3ebafd9ef3a63e50efc6c8df079e163d1d7ed29757d9620459ea2798fe69deb4b2caa0
7
+ data.tar.gz: a2750e80477d1024c8b05a277f3ed34541c1f7860d61640ec6873f66a37e11bf652864d3c1df1603e2b6a96de227c9de31c852b70ba2593dc410cdead1c3dc3f
@@ -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:
@@ -26,41 +47,11 @@ jobs:
26
47
 
27
48
  steps:
28
49
  - 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
50
+ - name: Start KIND cluster
38
51
  run: bash -f bin/start_kind.sh
39
- - name: Waiting for KIND cluster to get ready
40
- run: sleep 70
52
+ # - name: Waiting for KIND cluster to get ready
53
+ # run: sleep 70
41
54
  - name: Add bitnami repo
42
55
  run: helm repo add bitnami https://charts.bitnami.com/bitnami
43
56
  - 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
57
+ run: ./exe/helm_upgrade_logs --install nginx bitnami/nginx --wait --debug --set service.type=ClusterIP --set replicaCount=2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2022-04-14
3
+ ## [0.1.4] - 2022-04-16
4
4
 
5
- - Initial release
5
+ - Wait for pods with logs to start before watching
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
 
@@ -1,30 +1,40 @@
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
+ # Approach not ideal as it will for all containers to be ready and want to stream logs before that
9
+ def wait_for_container_ready
10
+ wait_pid = Process.spawn 'kubectl wait --for=condition=ContainersReady pod --selector "app.kubernetes.io/managed-by=Helm" --timeout=30s'
11
+ Process.wait wait_pid
12
+ end
13
+
14
+ # Wait for pods with logs to be present
15
+ # Not ideal due to https://github.com/kubernetes/kubernetes/issues/28746
16
+ def wait_for_pod
17
+ 90.times {
18
+ sleep 1
19
+ stdout, stderr, _ = Open3.capture3 "kubectl logs -lapp.kubernetes.io/managed-by=Helm"
20
+ if stderr.empty? && !stdout.strip.empty?
21
+ puts 'Pods with logs found'
22
+ break
23
+ else
24
+ puts "Waiting for pod logs: #{stderr}"
25
+ end
26
+ }
27
+ end
28
+
7
29
  helm_pid = Process.spawn "helm upgrade #{ARGV.join(' ')}"
8
30
 
31
+ event_pid = Process.spawn 'kubectl get events --watch-only=true'
32
+ service_pid = Process.spawn 'kubectl get services --watch-only=true'
9
33
 
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'
34
+ wait_for_pod
35
+ 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 --timestamps=true'
13
36
 
14
37
  Process.wait helm_pid
15
38
  puts `kill #{log_pid}`
16
39
  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}`
40
+ puts `kill #{service_pid}`
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HelmUpgradeLogs
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.4"
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.1
4
+ version: 0.1.4
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-16 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