stax-helm 0.0.8 → 0.0.12
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 +4 -4
- data/lib/stax/helm/base.rb +1 -1
- data/lib/stax/helm/cronjobs.rb +13 -0
- data/lib/stax/helm/jobs.rb +13 -0
- data/lib/stax/helm/runcmd.rb +20 -8
- data/lib/stax/helm/version.rb +1 -1
- data/lib/stax/helm.rb +2 -0
- data/stax-helm.gemspec +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3909b351d090d040c868d10944e88a1701d66bba982d32692a278cd15fe3ebce
|
|
4
|
+
data.tar.gz: 51bc19ccc238fff367b62128862836088efbdebff095536816f3432f2112a526
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 49dd63da8e6ce484a620c5f71f73929bf0be858cb793e7b7ad6e596e8c102dacce8d0995e086f22e372ab6695ed79a54eedfcb45b38c9a3b604a22f452e829ab
|
|
7
|
+
data.tar.gz: 433e7b094f0baf03fc2a1690c6da212af9335dbcd8ccccfc31456db5b7c4c519394fe783856cf833f79722984647cd8e666949f47e1bb363e2fa3cf3f97ef001
|
data/lib/stax/helm/base.rb
CHANGED
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
|
|
@@ -55,30 +54,43 @@ module Stax
|
|
|
55
54
|
desc 'runcmd [CMD]', 'run dedicated interactive container'
|
|
56
55
|
method_option :sleep, type: :string, default: '1h', description: 'kill container after time'
|
|
57
56
|
method_option :keep, type: :boolean, default: false, description: 'do not delete job'
|
|
57
|
+
method_option :ttl, type: :numeric, default: 30, description: 'secs to keep job after pod terminates'
|
|
58
58
|
def runcmd(*cmd)
|
|
59
59
|
## use default if not set
|
|
60
60
|
cmd = Array(helm_run_cmd) if cmd.empty?
|
|
61
61
|
|
|
62
|
-
## name of k8s Job to create
|
|
62
|
+
## name of k8s Job to create, and basic template
|
|
63
63
|
job = helm_run_job
|
|
64
|
+
template = helm_run_template(job)
|
|
64
65
|
|
|
65
66
|
## get deployment and extract container spec
|
|
66
67
|
deployment = kubectl_json(:get, :deployment, helm_run_deployment)
|
|
67
|
-
spec = deployment
|
|
68
|
+
spec = deployment.dig('spec', 'template', 'spec', 'containers').find do |c|
|
|
68
69
|
c['name'] == helm_run_container
|
|
69
70
|
end
|
|
70
71
|
|
|
71
72
|
## cleanup the container spec so we can use it in a Job
|
|
72
73
|
spec.delete('livenessProbe')
|
|
73
74
|
spec.delete('readinessProbe')
|
|
75
|
+
spec.delete('startupProbe')
|
|
74
76
|
spec.delete('volumeMounts')
|
|
75
77
|
spec['name'] = 'run'
|
|
76
78
|
spec['args'] = ['sleep', options[:sleep]]
|
|
77
79
|
|
|
80
|
+
## add container to Job template
|
|
81
|
+
template[:spec][:template][:spec][:containers] = [ spec ]
|
|
82
|
+
|
|
83
|
+
## add ttl to Job so it will be cleaned up after Pod terminates
|
|
84
|
+
template[:spec][:ttlSecondsAfterFinished] = options[:ttl]
|
|
85
|
+
|
|
86
|
+
## get service account and add to template
|
|
87
|
+
service_account = deployment.dig('spec', 'template', 'spec', 'serviceAccountName')
|
|
88
|
+
template[:spec][:template][:spec][:serviceAccountName] = service_account if service_account
|
|
89
|
+
|
|
78
90
|
## create new unique Job based on the container spec
|
|
79
91
|
debug("Creating job #{job}")
|
|
80
92
|
Open3.popen2('kubectl create -f -') { |stdin, stdout, _|
|
|
81
|
-
stdin.print(
|
|
93
|
+
stdin.print(template.to_json)
|
|
82
94
|
stdin.close
|
|
83
95
|
puts stdout.gets
|
|
84
96
|
}
|
data/lib/stax/helm/version.rb
CHANGED
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/stax-helm.gemspec
CHANGED
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
22
22
|
spec.require_paths = ['lib']
|
|
23
23
|
|
|
24
|
-
spec.add_development_dependency 'bundler', '~>
|
|
24
|
+
spec.add_development_dependency 'bundler', '~> 2'
|
|
25
25
|
spec.add_development_dependency 'rake', '>= 12.3.3'
|
|
26
26
|
|
|
27
27
|
spec.add_dependency('stax')
|
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.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Richard Lister
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-09-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '2'
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '2'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rake
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -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
|
|
@@ -96,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
96
98
|
- !ruby/object:Gem::Version
|
|
97
99
|
version: '0'
|
|
98
100
|
requirements: []
|
|
99
|
-
rubygems_version: 3.
|
|
101
|
+
rubygems_version: 3.1.4
|
|
100
102
|
signing_key:
|
|
101
103
|
specification_version: 4
|
|
102
104
|
summary: Control helm charts with stax.
|