stax-helm 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90efb4bc5fd77b16200e4693747b303df7644ebfe21149d715327a56397f1d25
4
- data.tar.gz: 19d2b39ef1cbd165dbd32091f317f8c11b12624d381920bdffd5295b8b8c5b68
3
+ metadata.gz: 53e53de7fb96d2b35470594bbb80e1de7bcbcf41aad867d6d20217db8bc20aef
4
+ data.tar.gz: 99f8d5f4a0964e66303803885d4f065d0979606f33cceed2afc7b5e82869f650
5
5
  SHA512:
6
- metadata.gz: 5566799f8341ace21b46a2ec7c3d90a3c5dc11d26f54c7efa1dc593df439e6dd59732286153823995573a53337252f8249000d54f26dd4813e72ebad23e943ff
7
- data.tar.gz: 8d1b6ca7b1e7465cac0f77754438ccff9ad880e12bf7d1eb9b2c58a6f48921bbad3471696ab4cd2e609aeee1cd749c0ce6304c23ad248ece555a2291140c5785
6
+ metadata.gz: 5cf3d1c0a868fdb26deb92346704bb3dacf507f28c3b70761b6525d3ecca93891fa0e1276533cfd3096913a1944d418469de7b7dbcf2383417803cc11fd7396c
7
+ data.tar.gz: d581092b08654b29454a72ab0c1ff198d47caa0aa1663baa17123898bc0cd738d01994cb4f7f9daf20cd19542124f3e8d630d55188f2bacc632339b889c556b4
@@ -4,6 +4,8 @@ require 'stax/helm/kubectl'
4
4
  require 'stax/helm/ingress'
5
5
  require 'stax/helm/pod'
6
6
  require 'stax/helm/deployment'
7
+ require 'stax/helm/jobs'
8
+ require 'stax/helm/cronjobs'
7
9
  require 'stax/helm/stern'
8
10
  require 'stax/helm/runcmd'
9
11
  Stax.add_command(:helm, Stax::Helm::Cmd)
@@ -0,0 +1,13 @@
1
+ ## tasks to get cronjob details
2
+ module Stax
3
+ module Helm
4
+ class Cmd < Base
5
+
6
+ desc 'cronjobs', 'list cronjobs'
7
+ def cronjobs
8
+ kubectl_run(:get, :cronjobs, '-l', helm_selector)
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ ## tasks to get job details
2
+ module Stax
3
+ module Helm
4
+ class Cmd < Base
5
+
6
+ desc 'jobs', 'list jobs'
7
+ def jobs
8
+ kubectl_run(:get, :jobs, '-l', helm_selector)
9
+ end
10
+
11
+ end
12
+ end
13
+ end
@@ -5,8 +5,8 @@ module Stax
5
5
  class Cmd
6
6
 
7
7
  no_commands do
8
- ## construct a Job template from passed container spec
9
- def helm_run_template(name, container_spec)
8
+ ## construct a Job template
9
+ def helm_run_template(name)
10
10
  {
11
11
  apiVersion: 'batch/v1',
12
12
  kind: :Job,
@@ -19,12 +19,11 @@ module Stax
19
19
  spec: {
20
20
  template: {
21
21
  spec: {
22
- restartPolicy: :Never,
23
- containers: [ container_spec ],
22
+ restartPolicy: :Never
24
23
  }
25
24
  }
26
25
  }
27
- }.to_json
26
+ }
28
27
  end
29
28
 
30
29
  ## Deployment to clone for container
@@ -59,12 +58,13 @@ module Stax
59
58
  ## use default if not set
60
59
  cmd = Array(helm_run_cmd) if cmd.empty?
61
60
 
62
- ## name of k8s Job to create
61
+ ## name of k8s Job to create, and basic template
63
62
  job = helm_run_job
63
+ template = helm_run_template(job)
64
64
 
65
65
  ## get deployment and extract container spec
66
66
  deployment = kubectl_json(:get, :deployment, helm_run_deployment)
67
- spec = deployment['spec']['template']['spec']['containers'].find do |c|
67
+ spec = deployment.dig('spec', 'template', 'spec', 'containers').find do |c|
68
68
  c['name'] == helm_run_container
69
69
  end
70
70
 
@@ -75,10 +75,17 @@ module Stax
75
75
  spec['name'] = 'run'
76
76
  spec['args'] = ['sleep', options[:sleep]]
77
77
 
78
+ ## add container to Job template
79
+ template[:spec][:template][:spec][:containers] = [ spec ]
80
+
81
+ ## get service account and add to template
82
+ service_account = deployment.dig('spec', 'template', 'spec', 'serviceAccountName')
83
+ template[:spec][:template][:spec][:serviceAccountName] = service_account if service_account
84
+
78
85
  ## create new unique Job based on the container spec
79
86
  debug("Creating job #{job}")
80
87
  Open3.popen2('kubectl create -f -') { |stdin, stdout, _|
81
- stdin.print(helm_run_template(job, spec))
88
+ stdin.print(template.to_json)
82
89
  stdin.close
83
90
  puts stdout.gets
84
91
  }
@@ -1,5 +1,5 @@
1
1
  module Stax
2
2
  module Helm
3
- VERSION = '0.0.8'
3
+ VERSION = '0.0.9'
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.8
4
+ version: 0.0.9
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-12-03 00:00:00.000000000 Z
11
+ date: 2020-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -69,8 +69,10 @@ files:
69
69
  - lib/stax/helm.rb
70
70
  - lib/stax/helm/base.rb
71
71
  - lib/stax/helm/cmd.rb
72
+ - lib/stax/helm/cronjobs.rb
72
73
  - lib/stax/helm/deployment.rb
73
74
  - lib/stax/helm/ingress.rb
75
+ - lib/stax/helm/jobs.rb
74
76
  - lib/stax/helm/kubectl.rb
75
77
  - lib/stax/helm/pod.rb
76
78
  - lib/stax/helm/runcmd.rb