stax-helm 0.0.3 → 0.0.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: 915820e964fa23b1d20b876f7e89d22ee55a97e4aa60fec75e508e47f36daf54
4
- data.tar.gz: 6da2869fac93946398ec4c0c83df102f4cb2a883b0b5dd72ce6486d5a804ea63
3
+ metadata.gz: 4c41b28fe1fde84c9dc771a618e0bfbeccd1718854aea285f41a4e115c73252f
4
+ data.tar.gz: '09525e2ae890c6b35306b578ac7099488f734920ac5f8aea250413652f7eebf7'
5
5
  SHA512:
6
- metadata.gz: 80d9424da2501a5b209af37868fd4b615d53acb125517effb7c3a759019cf3de9ef8c025f0e10b3473b48823b986ec11c4e9cf7a010b36e2f829ca2b878c939e
7
- data.tar.gz: 4bef3ab94b44a3fec3c20d3df75b353bd89a823f2c5ad0959985130a8797cbe694388f4649bd1152cf53b3265e4d5e49ce897a0e1a6da8b90847632e34e25020
6
+ metadata.gz: f2a5c1f4c00e3211799a516e6645af725c537a7ad96bb4ae4f60dd48be1df90be961a78108fa0a11057f7ba9832a842561d9a47cd3d341b9aacaa83da87b7906
7
+ data.tar.gz: 7260772678070aa147160ec8e072fe912a1bd79d772917b9a347fd65565c8ab5b2724f1fddc6d02e6c5e400a4748f9ec0523e01777686a980472c9215ca8d2e1
@@ -1,4 +1,7 @@
1
1
  require 'stax/helm/cmd'
2
2
  require 'stax/helm/kubectl'
3
+ require 'stax/helm/ingress'
4
+ require 'stax/helm/pod'
5
+ require 'stax/helm/deployment'
3
6
  require 'stax/helm/stern'
4
7
  Stax.add_command(:helm, Stax::Helm::Cmd)
@@ -0,0 +1,13 @@
1
+ ## tasks to work on deployments
2
+ module Stax
3
+ module Helm
4
+ class Cmd < Base
5
+
6
+ desc 'deployments', 'list deployments'
7
+ def deployments
8
+ kubectl_run(:get, :deployments, '-l', helm_selector)
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ ## tasks to get ingress details
2
+ module Stax
3
+ module Helm
4
+ class Cmd < Base
5
+
6
+ desc 'ingresses', 'list ingresses'
7
+ def ingresses
8
+ kubectl_run(:get, :ingresses, '-l', helm_selector)
9
+ end
10
+
11
+ desc 'dns', 'list external-dns hostnames'
12
+ def dns
13
+ jsonpath = '{.items[].metadata.annotations.external-dns\.alpha\.kubernetes\.io/hostname}' + "\n"
14
+ kubectl_run(:get, :ingresses, "-o=jsonpath='#{jsonpath}'", '-l', helm_selector)
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -9,54 +9,18 @@ module Stax
9
9
 
10
10
  def kubectl_run(*args)
11
11
  cmd = [kubectl_bin, *args].join(' ')
12
- options[:dry_run] ? puts(cmd) : system(cmd)
12
+ options[:recon] ? puts(cmd) : system(cmd)
13
13
  end
14
14
 
15
- ## build a selector argument from a hash of label and value pairs
16
- def selector(hash)
17
- '-l ' + hash.compact.map { |k,v| "#{k}=#{v}" }.join(',')
15
+ ## override this to match all objects in your helm release
16
+ def helm_selector
17
+ "app.kubernetes.io/instance=#{helm_release_name}"
18
18
  end
19
19
  end
20
20
 
21
21
  desc 'services', 'list services'
22
22
  def services
23
- kubectl_run(:get, :services, selector('app.kubernetes.io/instance': helm_release_name))
24
- end
25
-
26
- desc 'ingresses', 'list ingresses'
27
- def ingresses
28
- kubectl_run(:get, :ingresses, selector('app.kubernetes.io/instance': helm_release_name))
29
- end
30
-
31
- desc 'deployments', 'list deployments'
32
- def deployments
33
- kubectl_run(:get, :deployments, selector('app.kubernetes.io/instance': helm_release_name))
34
- end
35
-
36
- desc 'pods', 'list pods'
37
- def pods
38
- kubectl_run(:get, :pods, selector('app.kubernetes.io/instance': helm_release_name))
39
- end
40
-
41
- desc 'containers', 'list containers'
42
- def containers
43
- columns = 'NAME:.metadata.name,CONTAINERS:.spec.containers[*].name'
44
- kubectl_run(:get, :pods, '-o', "custom-columns=#{columns}", selector('app.kubernetes.io/instance': helm_release_name))
45
- end
46
-
47
- ## FIXME this is terrible, will be replaced with something better later
48
- desc 'logs COMPONENT [CONTAINER]', 'show container logs'
49
- method_option :container, aliases: '-c', type: :string, default: nil, desc: 'container from pod'
50
- def logs(component)
51
- container = options[:container] ? "-c #{options[:container]}" : ''
52
- kubectl_run(
53
- :logs,
54
- container,
55
- selector(
56
- 'app.kubernetes.io/instance': helm_release_name,
57
- 'app.kubernetes.io/component': component,
58
- )
59
- )
23
+ kubectl_run(:get, :services, '-l', helm_selector)
60
24
  end
61
25
 
62
26
  end
@@ -0,0 +1,48 @@
1
+ ## tasks to work on pods
2
+ module Stax
3
+ module Helm
4
+ class Cmd < Base
5
+
6
+ no_commands do
7
+ def helm_pods
8
+ jsonpath = '{.items[*].metadata.name}'
9
+ %x[kubectl get pods -o=jsonpath='#{jsonpath}' -l #{helm_selector}].split
10
+ end
11
+
12
+ def helm_ask_pod(msg)
13
+ pods = helm_pods
14
+ index = 0
15
+ if pods.count > 1
16
+ puts pods.each_with_index.map { |p, i| "#{i}: #{p}" }
17
+ index = ask(msg, default: index)
18
+ end
19
+ pods[index.to_i]
20
+ end
21
+ end
22
+
23
+ desc 'pods', 'list pods'
24
+ def pods
25
+ kubectl_run(:get, :pods, '-l', helm_selector)
26
+ end
27
+
28
+ desc 'containers', 'list containers'
29
+ def containers
30
+ columns = 'NAME:.metadata.name,CONTAINERS:.spec.containers[*].name'
31
+ kubectl_run(:get, :pods, '-o', "custom-columns=#{columns}", '-l', helm_selector)
32
+ end
33
+
34
+ desc 'logs [OPTIONS]', 'run kubectl logs with same options'
35
+ def logs(*args)
36
+ args = [ '--all-containers', '--prefix', '--follow' ] if args.empty? # helpful default args
37
+ kubectl_run(:logs, '-l', helm_selector, *args)
38
+ end
39
+
40
+ desc 'exec [CMD]', 'exec command in a web pod'
41
+ def exec(cmd = 'sh')
42
+ pod = helm_ask_pod('choose a pod')
43
+ kubectl_run(:exec, '-it', pod, '--', cmd)
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -16,7 +16,7 @@ module Stax
16
16
  ## pass through args to stern
17
17
  desc 'stern [STERN_ARGS]', 'use stern to show logs'
18
18
  def stern(*args)
19
- stern_run(selector('app.kubernetes.io/instance': helm_release_name), *args)
19
+ stern_run('-l', helm_selector, *args)
20
20
  end
21
21
 
22
22
  end
@@ -1,5 +1,5 @@
1
1
  module Stax
2
2
  module Helm
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stax-helm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Lister
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-30 00:00:00.000000000 Z
11
+ date: 2020-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -68,7 +68,10 @@ files:
68
68
  - Rakefile
69
69
  - lib/stax/helm.rb
70
70
  - lib/stax/helm/cmd.rb
71
+ - lib/stax/helm/deployment.rb
72
+ - lib/stax/helm/ingress.rb
71
73
  - lib/stax/helm/kubectl.rb
74
+ - lib/stax/helm/pod.rb
72
75
  - lib/stax/helm/stern.rb
73
76
  - lib/stax/helm/version.rb
74
77
  - stax-helm.gemspec
@@ -76,7 +79,7 @@ homepage: https://github.com/rlister/stax-helm
76
79
  licenses:
77
80
  - MIT
78
81
  metadata: {}
79
- post_install_message:
82
+ post_install_message:
80
83
  rdoc_options: []
81
84
  require_paths:
82
85
  - lib
@@ -91,8 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
94
  - !ruby/object:Gem::Version
92
95
  version: '0'
93
96
  requirements: []
94
- rubygems_version: 3.1.2
95
- signing_key:
97
+ rubygems_version: 3.0.3
98
+ signing_key:
96
99
  specification_version: 4
97
100
  summary: Control helm charts with stax.
98
101
  test_files: []