stax-helm 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -11
- data/lib/stax/helm.rb +2 -0
- data/lib/stax/helm/cmd.rb +5 -0
- data/lib/stax/helm/kubectl.rb +64 -0
- data/lib/stax/helm/stern.rb +24 -0
- data/lib/stax/helm/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8db16bbf17c66b24cf72a3e807ffeda939a1fda49ced1f7d9b708eae254b66ed
|
4
|
+
data.tar.gz: cd11b9f4eb2d4732a067e1aa51da1613e64903f3668e57e2b9886a084a599e95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3a6d9400080112015b5dd688939d84f80df7cae7d9f094316f8b51c2cc6c8aa5a1ab127ef0876a148e0761c1e875ebae78ff33c51c12700925e03d72513def2
|
7
|
+
data.tar.gz: be3eb884e62f76be25450face25c860095380ddca05f72b98cb2ba971e538fb874c0ebd7e0e476bab36af2a9dec8d238f239e709844f44dc1e14acbe88bd58cf
|
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Stax::Helm
|
2
2
|
|
3
|
+
[Stax](https://github.com/rlister/stax) is a highly-opionated framework for managing Cloudformation stacks.
|
4
|
+
|
5
|
+
Stax::Helm is highly-opionated framework for managing helm releases alongside their supporting Cloudformation stacks
|
6
|
+
|
3
7
|
## Installation
|
4
8
|
|
5
9
|
Add this line to your application's Gemfile:
|
@@ -16,24 +20,32 @@ Or install it yourself as:
|
|
16
20
|
|
17
21
|
$ gem install stax-helm
|
18
22
|
|
19
|
-
##
|
23
|
+
## Opinions
|
20
24
|
|
21
|
-
|
25
|
+
- you have one chart per application repo
|
26
|
+
- chart lives in `helm` dir alongside your `Staxfile`
|
27
|
+
- objects are labeled per the suggestions in
|
28
|
+
https://helm.sh/docs/chart_best_practices/labels/ and
|
29
|
+
https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/
|
22
30
|
|
23
|
-
##
|
31
|
+
## Usage
|
24
32
|
|
25
|
-
|
33
|
+
In your `Staxfile` add:
|
26
34
|
|
27
|
-
|
35
|
+
```ruby
|
36
|
+
require 'stax/helm'
|
37
|
+
```
|
28
38
|
|
29
|
-
|
39
|
+
and use commands like:
|
30
40
|
|
31
|
-
|
41
|
+
```
|
42
|
+
stax helm create
|
43
|
+
stax helm update
|
44
|
+
stax helm delete
|
45
|
+
```
|
46
|
+
|
47
|
+
See inline help for other tasks.
|
32
48
|
|
33
49
|
## License
|
34
50
|
|
35
51
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
36
|
-
|
37
|
-
## Code of Conduct
|
38
|
-
|
39
|
-
Everyone interacting in the Stax::Helm project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rlister/stax-helm/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/stax/helm.rb
CHANGED
data/lib/stax/helm/cmd.rb
CHANGED
@@ -0,0 +1,64 @@
|
|
1
|
+
module Stax
|
2
|
+
module Helm
|
3
|
+
class Cmd < Base
|
4
|
+
|
5
|
+
no_commands do
|
6
|
+
def kubectl_bin
|
7
|
+
'kubectl'
|
8
|
+
end
|
9
|
+
|
10
|
+
def kubectl_run(*args)
|
11
|
+
cmd = [kubectl_bin, *args].join(' ')
|
12
|
+
options[:dry_run] ? puts(cmd) : system(cmd)
|
13
|
+
end
|
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(',')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'services', 'list services'
|
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
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Stax
|
2
|
+
module Helm
|
3
|
+
class Cmd < Base
|
4
|
+
|
5
|
+
no_commands do
|
6
|
+
def stern_bin
|
7
|
+
'stern'
|
8
|
+
end
|
9
|
+
|
10
|
+
def stern_run(*args)
|
11
|
+
cmd = [stern_bin, *args].join(' ')
|
12
|
+
options[:dry_run] ? puts(cmd) : system(cmd)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
## pass through args to stern
|
17
|
+
desc 'stern [STERN_ARGS]', 'use stern to show logs'
|
18
|
+
def stern(*args)
|
19
|
+
stern_run(selector('app.kubernetes.io/instance': helm_release_name), *args)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Lister
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -68,6 +68,8 @@ files:
|
|
68
68
|
- Rakefile
|
69
69
|
- lib/stax/helm.rb
|
70
70
|
- lib/stax/helm/cmd.rb
|
71
|
+
- lib/stax/helm/kubectl.rb
|
72
|
+
- lib/stax/helm/stern.rb
|
71
73
|
- lib/stax/helm/version.rb
|
72
74
|
- stax-helm.gemspec
|
73
75
|
homepage: https://github.com/rlister/stax-helm
|