stax-helm 0.0.8 → 0.0.9
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 +2 -0
- data/lib/stax/helm/cronjobs.rb +13 -0
- data/lib/stax/helm/jobs.rb +13 -0
- data/lib/stax/helm/runcmd.rb +15 -8
- 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: 53e53de7fb96d2b35470594bbb80e1de7bcbcf41aad867d6d20217db8bc20aef
|
4
|
+
data.tar.gz: 99f8d5f4a0964e66303803885d4f065d0979606f33cceed2afc7b5e82869f650
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cf3d1c0a868fdb26deb92346704bb3dacf507f28c3b70761b6525d3ecca93891fa0e1276533cfd3096913a1944d418469de7b7dbcf2383417803cc11fd7396c
|
7
|
+
data.tar.gz: d581092b08654b29454a72ab0c1ff198d47caa0aa1663baa17123898bc0cd738d01994cb4f7f9daf20cd19542124f3e8d630d55188f2bacc632339b889c556b4
|
data/lib/stax/helm.rb
CHANGED
@@ -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)
|
data/lib/stax/helm/runcmd.rb
CHANGED
@@ -5,8 +5,8 @@ module Stax
|
|
5
5
|
class Cmd
|
6
6
|
|
7
7
|
no_commands do
|
8
|
-
## construct a Job template
|
9
|
-
def helm_run_template(name
|
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
|
-
}
|
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
|
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(
|
88
|
+
stdin.print(template.to_json)
|
82
89
|
stdin.close
|
83
90
|
puts stdout.gets
|
84
91
|
}
|
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.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-
|
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
|