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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a39d86691aa95175038ebb17eea1a61d0c5c10c494de2a620cfa896621c646a5
4
- data.tar.gz: 0bb2e82a0901daf51b69aaff4eda6b34edf8b77f2feecd991b127b797a0c2d86
3
+ metadata.gz: 8db16bbf17c66b24cf72a3e807ffeda939a1fda49ced1f7d9b708eae254b66ed
4
+ data.tar.gz: cd11b9f4eb2d4732a067e1aa51da1613e64903f3668e57e2b9886a084a599e95
5
5
  SHA512:
6
- metadata.gz: 7c13bf85d7e78a3ae7494fb56d89cda5e7366d660c8b92bf7065dd859ba2b04761ef35db2e93a835a2f0945f629664fc53e495866e3fc639fb9264e5e59ade58
7
- data.tar.gz: 13e34d76337048c8ab014427139f4f9f4373c1561ae29ee78b0b6a7ab4f0526d159557cb39f9f0fec97b359b6150d31d552d259b345f0a08c1faedb2b927c629
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
- ## Usage
23
+ ## Opinions
20
24
 
21
- TODO: Write usage instructions here
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
- ## Development
31
+ ## Usage
24
32
 
25
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
+ In your `Staxfile` add:
26
34
 
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
35
+ ```ruby
36
+ require 'stax/helm'
37
+ ```
28
38
 
29
- ## Contributing
39
+ and use commands like:
30
40
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/rlister/stax-helm. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
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).
@@ -1,2 +1,4 @@
1
1
  require 'stax/helm/cmd'
2
+ require 'stax/helm/kubectl'
3
+ require 'stax/helm/stern'
2
4
  Stax.add_command(:helm, Stax::Helm::Cmd)
@@ -86,6 +86,11 @@ module Stax
86
86
  helm_run(:rollback, helm_release_name, revision)
87
87
  end
88
88
 
89
+ desc 'ls', 'list helm release'
90
+ def ls
91
+ helm_run(:ls, "--filter '^#{helm_release_name}$'")
92
+ end
93
+
89
94
  end
90
95
  end
91
96
  end
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Stax
2
2
  module Helm
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
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.1
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-24 00:00:00.000000000 Z
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