metatron 0.1.9 → 0.2.0
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/.rubocop.yml +3 -0
- data/Gemfile.lock +2 -2
- data/README.md +11 -6
- data/lib/metatron/sync_controller.rb +3 -1
- data/lib/metatron/template.rb +11 -3
- data/lib/metatron/templates/concerns/pod_producer.rb +6 -42
- data/lib/metatron/templates/container.rb +90 -0
- data/lib/metatron/templates/cron_job.rb +83 -0
- data/lib/metatron/templates/daemon_set.rb +4 -16
- data/lib/metatron/templates/deployment.rb +3 -15
- data/lib/metatron/templates/job.rb +62 -0
- data/lib/metatron/templates/namespace.rb +2 -0
- data/lib/metatron/templates/pod.rb +3 -17
- data/lib/metatron/templates/replica_set.rb +3 -15
- data/lib/metatron/templates/stateful_set.rb +3 -15
- data/lib/metatron/version.rb +2 -2
- data/lib/metatron.rb +3 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2595e703b422eadf0c748386541eae93f9b447d74e2bd70160a85dc14c7f59a
|
4
|
+
data.tar.gz: 599adf4652b4e2bbf35f86f95c083f6e6e03780d44fa563c83ca714c90aa3004
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd16efd8685097c4fdb321de668cecb60ac24c0dab98e1e97ab40590007d524dfa9b0ba644174786d659a0fc6bc1225b48b62cb0ae2a1224e1503ee8a6aa40c7
|
7
|
+
data.tar.gz: d0255911256d4e233f300b5a82dbeba91feeba7819d920bdd2e2e3c505a02b1b7343fdfc8ec938912bc4f650491ddfdc51efc007f7e57e58527ecf0665b07adf
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
metatron (0.
|
4
|
+
metatron (0.2.0)
|
5
5
|
json (~> 2.6)
|
6
6
|
puma (~> 6.3)
|
7
7
|
sinatra (~> 2.2)
|
@@ -50,7 +50,7 @@ GEM
|
|
50
50
|
regexp_parser (2.8.1)
|
51
51
|
reverse_markdown (2.1.1)
|
52
52
|
nokogiri
|
53
|
-
rexml (3.2.
|
53
|
+
rexml (3.2.6)
|
54
54
|
rspec (3.12.0)
|
55
55
|
rspec-core (~> 3.12.0)
|
56
56
|
rspec-expectations (~> 3.12.0)
|
data/README.md
CHANGED
@@ -203,7 +203,7 @@ module BlogController
|
|
203
203
|
# status = compare_children(request_body["children"], desired_children)
|
204
204
|
status = {}
|
205
205
|
|
206
|
-
{ status:, children: desired_children
|
206
|
+
{ status:, children: desired_children }
|
207
207
|
end
|
208
208
|
|
209
209
|
def construct_app_resources(parent, db_secret)
|
@@ -235,18 +235,23 @@ module BlogController
|
|
235
235
|
|
236
236
|
def construct_db_stateful_set(secret)
|
237
237
|
stateful_set = Metatron::Templates::StatefulSet.new("db")
|
238
|
-
|
238
|
+
container = Metatron::Templates::Container.new("db")
|
239
|
+
container.image = "mysql:8.0"
|
240
|
+
container.envfrom << secret.name
|
241
|
+
stateful_set.containers << container
|
239
242
|
stateful_set.additional_pod_labels = { "app.kubernetes.io/component": "db" }
|
240
|
-
stateful_set.envfrom << secret.name
|
241
243
|
stateful_set
|
242
244
|
end
|
243
245
|
|
244
246
|
def construct_app_deployment(meta, spec, auth_secret)
|
245
247
|
deployment = Metatron::Templates::Deployment.new(meta["name"], replicas: spec["replicas"])
|
246
|
-
|
248
|
+
container = Metatron::Templates::Container.new("app")
|
249
|
+
container.image = spec["image"]
|
250
|
+
container.envfrom << auth_secret.name
|
251
|
+
container.ports << { name: "web", containerPort: 3000 }
|
252
|
+
|
253
|
+
deployment.containers << container
|
247
254
|
deployment.additional_pod_labels = { "app.kubernetes.io/component": "app" }
|
248
|
-
deployment.envfrom << auth_secret.name
|
249
|
-
deployment.ports << { name: "web", containerPort: 3000 }
|
250
255
|
deployment
|
251
256
|
end
|
252
257
|
|
data/lib/metatron/template.rb
CHANGED
@@ -3,12 +3,20 @@
|
|
3
3
|
module Metatron
|
4
4
|
# Base class for templating Kubernetes resources
|
5
5
|
class Template
|
6
|
-
attr_accessor :api_version, :
|
7
|
-
attr_reader :kind
|
6
|
+
attr_accessor :api_version, :name
|
7
|
+
attr_reader :kind, :label_namespace
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_writer :label_namespace
|
11
|
+
|
12
|
+
def label_namespace
|
13
|
+
@label_namespace ||= "metatron.therubyist.org"
|
14
|
+
end
|
15
|
+
end
|
8
16
|
|
9
17
|
def initialize(name)
|
10
18
|
@name = name
|
11
|
-
@label_namespace =
|
19
|
+
@label_namespace = self.class.label_namespace
|
12
20
|
@api_version = "v1"
|
13
21
|
@kind = self.class.name.split("::").last
|
14
22
|
run_initializers
|
@@ -8,78 +8,42 @@ module Metatron
|
|
8
8
|
def self.included(base)
|
9
9
|
# base.extend ClassMethods
|
10
10
|
base.class_eval do
|
11
|
-
attr_accessor :
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:container_security_context, :affinity, :termination_grace_period_seconds,
|
11
|
+
attr_accessor :additional_labels, :additional_pod_labels,
|
12
|
+
:security_context, :volumes, :containers, :init_containers,
|
13
|
+
:affinity, :termination_grace_period_seconds,
|
15
14
|
:tolerations, :pod_annotations
|
16
15
|
|
17
16
|
initializer :pod_producer_initialize
|
18
17
|
|
19
|
-
alias_method :imagePullPolicy, :image_pull_policy
|
20
|
-
alias_method :volumeMounts, :volume_mounts
|
21
18
|
alias_method :securityContext, :security_context
|
22
|
-
alias_method :environment, :env
|
23
19
|
alias_method :terminationGracePeriodSeconds, :termination_grace_period_seconds
|
24
20
|
end
|
25
21
|
end
|
26
22
|
|
27
23
|
def pod_producer_initialize
|
28
|
-
@image = "gcr.io/google_containers/pause"
|
29
|
-
@image_pull_policy = "IfNotPresent"
|
30
|
-
@resource_limits = { memory: "512Mi", cpu: "500m" }
|
31
|
-
@resource_requests = { memory: "64Mi", cpu: "10m" }
|
32
24
|
@affinity = {}
|
33
|
-
@env = {}
|
34
|
-
@envfrom = []
|
35
|
-
@probes = {}
|
36
|
-
@ports = []
|
37
|
-
@volume_mounts = []
|
38
25
|
@volumes = []
|
39
26
|
@security_context = {}
|
40
|
-
@
|
41
|
-
@
|
27
|
+
@containers = []
|
28
|
+
@init_containers = []
|
42
29
|
@additional_labels = {}
|
43
30
|
@additional_pod_labels = {}
|
44
31
|
@pod_annotations = {}
|
45
|
-
@termination_grace_period_seconds =
|
32
|
+
@termination_grace_period_seconds = nil
|
46
33
|
@tolerations = []
|
47
34
|
end
|
48
35
|
|
49
36
|
def formatted_affinity = affinity && !affinity.empty? ? { affinity: } : {}
|
50
37
|
|
51
|
-
def formatted_environment
|
52
|
-
env && !env.empty? ? { env: env.map { |k, v| { name: k, value: v } } } : {}
|
53
|
-
end
|
54
|
-
|
55
|
-
def formatted_envfrom
|
56
|
-
if envfrom && !envfrom.empty?
|
57
|
-
{ envFrom: envfrom.map { |secret| { secretRef: { name: secret } } } }
|
58
|
-
else
|
59
|
-
{}
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
38
|
def formatted_pod_annotations
|
64
39
|
pod_annotations && !pod_annotations.empty? ? { annotations: pod_annotations } : {}
|
65
40
|
end
|
66
41
|
|
67
|
-
def formatted_ports = ports&.any? ? { ports: } : {}
|
68
|
-
|
69
42
|
def formatted_security_context
|
70
43
|
security_context && !security_context.empty? ? { securityContext: } : {}
|
71
44
|
end
|
72
45
|
|
73
|
-
def formatted_container_security_context
|
74
|
-
if container_security_context && !container_security_context.empty?
|
75
|
-
{ securityContext: container_security_context }
|
76
|
-
else
|
77
|
-
{}
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
46
|
def formatted_tolerations = tolerations&.any? ? { tolerations: } : {}
|
82
|
-
def formatted_volume_mounts = volume_mounts&.any? ? { volumeMounts: } : {}
|
83
47
|
def formatted_volumes = volumes&.any? ? { volumes: } : {}
|
84
48
|
end
|
85
49
|
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Metatron
|
4
|
+
module Templates
|
5
|
+
# Template for containers used by k8s resources (not an actual resource)
|
6
|
+
class Container
|
7
|
+
attr_accessor :name, :image, :command, :args, :env, :envfrom, :resources, :volume_mounts,
|
8
|
+
:image_pull_policy, :life_cycle, :probes, :security_context, :ports,
|
9
|
+
:stdin, :tty
|
10
|
+
|
11
|
+
alias imagePullPolicy image_pull_policy
|
12
|
+
alias volumeMounts volume_mounts
|
13
|
+
alias securityContext security_context
|
14
|
+
alias environment env
|
15
|
+
alias envFrom envfrom
|
16
|
+
|
17
|
+
def initialize(name, image = "gcr.io/google_containers/pause")
|
18
|
+
@name = name
|
19
|
+
@image = image
|
20
|
+
@command = nil
|
21
|
+
@args = []
|
22
|
+
@env = []
|
23
|
+
@resources = {}
|
24
|
+
@volume_mounts = []
|
25
|
+
@image_pull_policy = "IfNotPresent"
|
26
|
+
@life_cycle = {}
|
27
|
+
@probes = {}
|
28
|
+
@stdin = true
|
29
|
+
@tty = true
|
30
|
+
end
|
31
|
+
|
32
|
+
def render
|
33
|
+
{
|
34
|
+
name:,
|
35
|
+
image:,
|
36
|
+
imagePullPolicy:,
|
37
|
+
stdin:,
|
38
|
+
tty:
|
39
|
+
}.merge(probes)
|
40
|
+
.merge(formatted_resources)
|
41
|
+
.merge(formatted_environment)
|
42
|
+
.merge(formatted_envfrom)
|
43
|
+
.merge(formatted_ports)
|
44
|
+
.merge(formatted_volume_mounts)
|
45
|
+
.merge(formatted_security_context)
|
46
|
+
.compact
|
47
|
+
end
|
48
|
+
|
49
|
+
def formatted_environment # rubocop:disable Metrics/PerceivedComplexity
|
50
|
+
return {} unless env && !env.empty?
|
51
|
+
|
52
|
+
if env.is_a?(Hash)
|
53
|
+
mapped_values = env.map do |key, value|
|
54
|
+
v = { name: key }
|
55
|
+
if value.is_a?(Hash)
|
56
|
+
v.merge!(value)
|
57
|
+
else
|
58
|
+
v[:value] = value
|
59
|
+
end
|
60
|
+
v
|
61
|
+
end
|
62
|
+
|
63
|
+
{ env: mapped_values }
|
64
|
+
elsif env.is_a?(Array)
|
65
|
+
{ env: }
|
66
|
+
else
|
67
|
+
raise "Environment must be a Hash or Array"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def formatted_envfrom
|
72
|
+
if envfrom && !envfrom.empty?
|
73
|
+
{ envFrom: envfrom.map { |secret| { secretRef: { name: secret } } } }
|
74
|
+
else
|
75
|
+
{}
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def formatted_resources = resources&.any? ? { resources: } : {}
|
80
|
+
|
81
|
+
def formatted_ports = ports&.any? ? { ports: } : {}
|
82
|
+
|
83
|
+
def formatted_security_context
|
84
|
+
security_context && !security_context.empty? ? { securityContext: } : {}
|
85
|
+
end
|
86
|
+
|
87
|
+
def formatted_volume_mounts = volume_mounts&.any? ? { volumeMounts: } : {}
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Metatron
|
4
|
+
module Templates
|
5
|
+
# Template for basic CronJob k8s resource
|
6
|
+
class CronJob < Template
|
7
|
+
include Concerns::Annotated
|
8
|
+
include Concerns::PodProducer
|
9
|
+
include Concerns::Namespaced
|
10
|
+
|
11
|
+
attr_accessor :schedule, :suspend, :concurrency_policy, :starting_deadline_seconds,
|
12
|
+
:successful_jobs_history_limit, :failed_jobs_history_limit,
|
13
|
+
:automount_service_account_token, :backoff_limit, :active_deadline_seconds,
|
14
|
+
:dns_policy, :restart_policy,
|
15
|
+
:scheduler_name, :service_account, :service_account_name
|
16
|
+
|
17
|
+
alias automountServiceAccountToken automount_service_account_token
|
18
|
+
alias backoffLimit backoff_limit
|
19
|
+
alias activeDeadlineSeconds active_deadline_seconds
|
20
|
+
alias concurrencyPolicy concurrency_policy
|
21
|
+
alias dnsPolicy dns_policy
|
22
|
+
alias restartPolicy restart_policy
|
23
|
+
alias schedulerName scheduler_name
|
24
|
+
alias serviceAccount service_account
|
25
|
+
alias serviceAccountName service_account_name
|
26
|
+
alias startingDeadlineSeconds starting_deadline_seconds
|
27
|
+
alias successfulJobsHistoryLimit successful_jobs_history_limit
|
28
|
+
alias failedJobsHistoryLimit failed_jobs_history_limit
|
29
|
+
|
30
|
+
def initialize(name, schedule = "* * * * *")
|
31
|
+
super(name)
|
32
|
+
@schedule = schedule
|
33
|
+
@api_version = "batch/v1"
|
34
|
+
@restart_policy = "OnFailure"
|
35
|
+
end
|
36
|
+
|
37
|
+
# rubocop:disable Metrics/AbcSize
|
38
|
+
# rubocop:disable Metrics/MethodLength
|
39
|
+
def render
|
40
|
+
{
|
41
|
+
apiVersion:,
|
42
|
+
kind:,
|
43
|
+
metadata: {
|
44
|
+
labels: { "#{label_namespace}/name": name }.merge(additional_labels),
|
45
|
+
name:
|
46
|
+
}.merge(formatted_annotations).merge(formatted_namespace),
|
47
|
+
spec: {
|
48
|
+
schedule:,
|
49
|
+
suspend:,
|
50
|
+
concurrencyPolicy:,
|
51
|
+
startingDeadlineSeconds:,
|
52
|
+
successfulJobsHistoryLimit:,
|
53
|
+
failedJobsHistoryLimit:,
|
54
|
+
jobTemplate: {
|
55
|
+
spec: {
|
56
|
+
activeDeadlineSeconds:,
|
57
|
+
backoffLimit:,
|
58
|
+
template: {
|
59
|
+
spec: {
|
60
|
+
automountServiceAccountToken:,
|
61
|
+
terminationGracePeriodSeconds:,
|
62
|
+
dnsPolicy:,
|
63
|
+
restartPolicy:,
|
64
|
+
schedulerName:,
|
65
|
+
serviceAccount:,
|
66
|
+
serviceAccountName:,
|
67
|
+
containers: containers.map(&:render),
|
68
|
+
init_containers: init_containers.any? ? init_containers.map(&:render) : nil
|
69
|
+
}.merge(formatted_volumes)
|
70
|
+
.merge(formatted_security_context)
|
71
|
+
.compact
|
72
|
+
}.compact
|
73
|
+
}.compact
|
74
|
+
}.merge(formatted_tolerations)
|
75
|
+
.compact
|
76
|
+
}.compact
|
77
|
+
}
|
78
|
+
end
|
79
|
+
# rubocop:enable Metrics/AbcSize
|
80
|
+
# rubocop:enable Metrics/MethodLength
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -15,8 +15,8 @@ module Metatron
|
|
15
15
|
@api_version = "apps/v1"
|
16
16
|
end
|
17
17
|
|
18
|
-
# rubocop:disable Metrics/MethodLength
|
19
18
|
# rubocop:disable Metrics/AbcSize
|
19
|
+
# rubocop:disable Metrics/MethodLength
|
20
20
|
def render
|
21
21
|
{
|
22
22
|
apiVersion:,
|
@@ -35,24 +35,12 @@ module Metatron
|
|
35
35
|
}.merge(formatted_pod_annotations),
|
36
36
|
spec: {
|
37
37
|
terminationGracePeriodSeconds:,
|
38
|
-
containers:
|
39
|
-
|
40
|
-
name: "app",
|
41
|
-
image:,
|
42
|
-
imagePullPolicy:,
|
43
|
-
stdin: true,
|
44
|
-
tty: true,
|
45
|
-
resources: { limits: resource_limits, requests: resource_requests }
|
46
|
-
}.merge(probes)
|
47
|
-
.merge(formatted_environment)
|
48
|
-
.merge(formatted_envfrom)
|
49
|
-
.merge(formatted_ports)
|
50
|
-
.merge(formatted_volume_mounts)
|
51
|
-
.merge(formatted_container_security_context)
|
52
|
-
] + additional_containers
|
38
|
+
containers: containers.map(&:render),
|
39
|
+
init_containers: init_containers.any? ? init_containers.map(&:render) : nil
|
53
40
|
}.merge(formatted_volumes)
|
54
41
|
.merge(formatted_security_context)
|
55
42
|
.merge(formatted_tolerations)
|
43
|
+
.compact
|
56
44
|
}
|
57
45
|
}
|
58
46
|
}
|
@@ -38,24 +38,12 @@ module Metatron
|
|
38
38
|
}.merge(formatted_pod_annotations).merge(formatted_namespace),
|
39
39
|
spec: {
|
40
40
|
terminationGracePeriodSeconds:,
|
41
|
-
containers:
|
42
|
-
|
43
|
-
name: "app",
|
44
|
-
image:,
|
45
|
-
imagePullPolicy:,
|
46
|
-
stdin: true,
|
47
|
-
tty: true,
|
48
|
-
resources: { limits: resource_limits, requests: resource_requests }
|
49
|
-
}.merge(probes)
|
50
|
-
.merge(formatted_environment)
|
51
|
-
.merge(formatted_envfrom)
|
52
|
-
.merge(formatted_ports)
|
53
|
-
.merge(formatted_volume_mounts)
|
54
|
-
.merge(formatted_container_security_context)
|
55
|
-
] + additional_containers
|
41
|
+
containers: containers.map(&:render),
|
42
|
+
init_containers: init_containers.any? ? init_containers.map(&:render) : nil
|
56
43
|
}.merge(formatted_volumes)
|
57
44
|
.merge(formatted_security_context)
|
58
45
|
.merge(formatted_tolerations)
|
46
|
+
.compact
|
59
47
|
}
|
60
48
|
}
|
61
49
|
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Metatron
|
4
|
+
module Templates
|
5
|
+
# Template for basic Job k8s resource
|
6
|
+
class Job < Template
|
7
|
+
include Concerns::Annotated
|
8
|
+
include Concerns::PodProducer
|
9
|
+
include Concerns::Namespaced
|
10
|
+
|
11
|
+
attr_accessor :backoff_limit, :completions, :parallelism, :restart_policy,
|
12
|
+
:pod_failure_policy, :active_deadline_seconds, :ttl_seconds_after_finished,
|
13
|
+
:suspend
|
14
|
+
|
15
|
+
alias activeDeadlineSeconds active_deadline_seconds
|
16
|
+
alias backoffLimit backoff_limit
|
17
|
+
alias podFailurePolicy pod_failure_policy
|
18
|
+
alias restartPolicy restart_policy
|
19
|
+
alias ttlSecondsAfterFinished ttl_seconds_after_finished
|
20
|
+
|
21
|
+
def initialize(name)
|
22
|
+
super(name)
|
23
|
+
@api_version = "batch/v1"
|
24
|
+
end
|
25
|
+
|
26
|
+
# rubocop:disable Metrics/AbcSize
|
27
|
+
# rubocop:disable Metrics/MethodLength
|
28
|
+
def render
|
29
|
+
{
|
30
|
+
apiVersion:,
|
31
|
+
kind:,
|
32
|
+
metadata: {
|
33
|
+
labels: { "#{label_namespace}/name": name }.merge(additional_labels),
|
34
|
+
name:
|
35
|
+
}.merge(formatted_annotations).merge(formatted_namespace),
|
36
|
+
spec: {
|
37
|
+
suspend:,
|
38
|
+
backoffLimit:,
|
39
|
+
activeDeadlineSeconds:,
|
40
|
+
completions:,
|
41
|
+
parallelism:,
|
42
|
+
podFailurePolicy:,
|
43
|
+
ttlSecondsAfterFinished:,
|
44
|
+
template: {
|
45
|
+
spec: {
|
46
|
+
terminationGracePeriodSeconds:,
|
47
|
+
restartPolicy:,
|
48
|
+
containers: containers.map(&:render),
|
49
|
+
init_containers: init_containers.any? ? init_containers.map(&:render) : nil
|
50
|
+
}.merge(formatted_volumes)
|
51
|
+
.merge(formatted_security_context)
|
52
|
+
.merge(formatted_tolerations)
|
53
|
+
.compact
|
54
|
+
}.compact
|
55
|
+
}.compact
|
56
|
+
}
|
57
|
+
end
|
58
|
+
# rubocop:enable Metrics/AbcSize
|
59
|
+
# rubocop:enable Metrics/MethodLength
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -8,7 +8,6 @@ module Metatron
|
|
8
8
|
include Concerns::PodProducer
|
9
9
|
include Concerns::Namespaced
|
10
10
|
|
11
|
-
# rubocop:disable Metrics/MethodLength
|
12
11
|
# rubocop:disable Metrics/AbcSize
|
13
12
|
def render
|
14
13
|
{
|
@@ -20,28 +19,15 @@ module Metatron
|
|
20
19
|
}.merge(formatted_annotations).merge(formatted_namespace),
|
21
20
|
spec: {
|
22
21
|
terminationGracePeriodSeconds:,
|
23
|
-
containers:
|
24
|
-
|
25
|
-
name: "app",
|
26
|
-
image:,
|
27
|
-
imagePullPolicy:,
|
28
|
-
stdin: true,
|
29
|
-
tty: true,
|
30
|
-
resources: { limits: resource_limits, requests: resource_requests }
|
31
|
-
}.merge(probes)
|
32
|
-
.merge(formatted_environment)
|
33
|
-
.merge(formatted_envfrom)
|
34
|
-
.merge(formatted_ports)
|
35
|
-
.merge(formatted_volume_mounts)
|
36
|
-
.merge(formatted_container_security_context)
|
37
|
-
] + additional_containers
|
22
|
+
containers: containers.map(&:render),
|
23
|
+
init_containers: init_containers.any? ? init_containers.map(&:render) : nil
|
38
24
|
}.merge(formatted_volumes)
|
39
25
|
.merge(formatted_security_context)
|
40
26
|
.merge(formatted_tolerations)
|
27
|
+
.compact
|
41
28
|
}
|
42
29
|
end
|
43
30
|
# rubocop:enable Metrics/AbcSize
|
44
|
-
# rubocop:enable Metrics/MethodLength
|
45
31
|
end
|
46
32
|
end
|
47
33
|
end
|
@@ -37,24 +37,12 @@ module Metatron
|
|
37
37
|
}.merge(formatted_pod_annotations),
|
38
38
|
spec: {
|
39
39
|
terminationGracePeriodSeconds:,
|
40
|
-
containers:
|
41
|
-
|
42
|
-
name: "app",
|
43
|
-
image:,
|
44
|
-
imagePullPolicy:,
|
45
|
-
stdin: true,
|
46
|
-
tty: true,
|
47
|
-
resources: { limits: resource_limits, requests: resource_requests }
|
48
|
-
}.merge(probes)
|
49
|
-
.merge(formatted_environment)
|
50
|
-
.merge(formatted_envfrom)
|
51
|
-
.merge(formatted_ports)
|
52
|
-
.merge(formatted_volume_mounts)
|
53
|
-
.merge(formatted_container_security_context)
|
54
|
-
] + additional_containers
|
40
|
+
containers: containers.map(&:render),
|
41
|
+
init_containers: init_containers.any? ? init_containers.map(&:render) : nil
|
55
42
|
}.merge(formatted_volumes)
|
56
43
|
.merge(formatted_security_context)
|
57
44
|
.merge(formatted_tolerations)
|
45
|
+
.compact
|
58
46
|
}
|
59
47
|
}
|
60
48
|
}
|
@@ -47,24 +47,12 @@ module Metatron
|
|
47
47
|
}.merge(formatted_pod_annotations),
|
48
48
|
spec: {
|
49
49
|
terminationGracePeriodSeconds:,
|
50
|
-
containers:
|
51
|
-
|
52
|
-
name: "app",
|
53
|
-
image:,
|
54
|
-
imagePullPolicy:,
|
55
|
-
stdin: true,
|
56
|
-
tty: true,
|
57
|
-
resources: { limits: resource_limits, requests: resource_requests }
|
58
|
-
}.merge(probes)
|
59
|
-
.merge(formatted_environment)
|
60
|
-
.merge(formatted_envfrom)
|
61
|
-
.merge(formatted_ports)
|
62
|
-
.merge(formatted_volume_mounts)
|
63
|
-
.merge(formatted_security_context)
|
64
|
-
] + additional_containers
|
50
|
+
containers: containers.map(&:render),
|
51
|
+
init_containers: init_containers.any? ? init_containers.map(&:render) : nil
|
65
52
|
}.merge(formatted_volumes)
|
66
53
|
.merge(formatted_affinity)
|
67
54
|
.merge(formatted_tolerations)
|
55
|
+
.compact
|
68
56
|
}
|
69
57
|
}
|
70
58
|
}
|
data/lib/metatron/version.rb
CHANGED
data/lib/metatron.rb
CHANGED
@@ -28,6 +28,9 @@ require "metatron/template"
|
|
28
28
|
require "metatron/templates/concerns/annotated"
|
29
29
|
require "metatron/templates/concerns/namespaced"
|
30
30
|
require "metatron/templates/concerns/pod_producer"
|
31
|
+
require "metatron/templates/container"
|
32
|
+
require "metatron/templates/job"
|
33
|
+
require "metatron/templates/cron_job"
|
31
34
|
require "metatron/templates/pod"
|
32
35
|
require "metatron/templates/persistent_volume_claim"
|
33
36
|
require "metatron/templates/deployment"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metatron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Gnagy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -260,9 +260,12 @@ files:
|
|
260
260
|
- lib/metatron/templates/concerns/namespaced.rb
|
261
261
|
- lib/metatron/templates/concerns/pod_producer.rb
|
262
262
|
- lib/metatron/templates/config_map.rb
|
263
|
+
- lib/metatron/templates/container.rb
|
264
|
+
- lib/metatron/templates/cron_job.rb
|
263
265
|
- lib/metatron/templates/daemon_set.rb
|
264
266
|
- lib/metatron/templates/deployment.rb
|
265
267
|
- lib/metatron/templates/ingress.rb
|
268
|
+
- lib/metatron/templates/job.rb
|
266
269
|
- lib/metatron/templates/namespace.rb
|
267
270
|
- lib/metatron/templates/persistent_volume_claim.rb
|
268
271
|
- lib/metatron/templates/pod.rb
|