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 +4 -4
- data/lib/stax/helm.rb +3 -0
- data/lib/stax/helm/deployment.rb +13 -0
- data/lib/stax/helm/ingress.rb +19 -0
- data/lib/stax/helm/kubectl.rb +5 -41
- data/lib/stax/helm/pod.rb +48 -0
- data/lib/stax/helm/stern.rb +1 -1
- data/lib/stax/helm/version.rb +1 -1
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c41b28fe1fde84c9dc771a618e0bfbeccd1718854aea285f41a4e115c73252f
|
4
|
+
data.tar.gz: '09525e2ae890c6b35306b578ac7099488f734920ac5f8aea250413652f7eebf7'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2a5c1f4c00e3211799a516e6645af725c537a7ad96bb4ae4f60dd48be1df90be961a78108fa0a11057f7ba9832a842561d9a47cd3d341b9aacaa83da87b7906
|
7
|
+
data.tar.gz: 7260772678070aa147160ec8e072fe912a1bd79d772917b9a347fd65565c8ab5b2724f1fddc6d02e6c5e400a4748f9ec0523e01777686a980472c9215ca8d2e1
|
data/lib/stax/helm.rb
CHANGED
@@ -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
|
data/lib/stax/helm/kubectl.rb
CHANGED
@@ -9,54 +9,18 @@ module Stax
|
|
9
9
|
|
10
10
|
def kubectl_run(*args)
|
11
11
|
cmd = [kubectl_bin, *args].join(' ')
|
12
|
-
options[:
|
12
|
+
options[:recon] ? puts(cmd) : system(cmd)
|
13
13
|
end
|
14
14
|
|
15
|
-
##
|
16
|
-
def
|
17
|
-
|
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,
|
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
|
data/lib/stax/helm/stern.rb
CHANGED
data/lib/stax/helm/version.rb
CHANGED
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.
|
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-
|
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.
|
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: []
|