metatron 0.2.2 → 0.2.3
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/Gemfile.lock +1 -1
- data/lib/metatron/templates/concerns/pod_producer.rb +102 -10
- data/lib/metatron/templates/cron_job.rb +4 -32
- data/lib/metatron/templates/daemon_set.rb +1 -18
- data/lib/metatron/templates/deployment.rb +1 -18
- data/lib/metatron/templates/job.rb +2 -17
- data/lib/metatron/templates/pod.rb +2 -12
- data/lib/metatron/templates/replica_set.rb +1 -18
- data/lib/metatron/templates/stateful_set.rb +2 -21
- data/lib/metatron/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 677b9ecf8b5a4c678cf17d251ad3fdd916646c5ba4ac249468f19dc095e8642a
|
4
|
+
data.tar.gz: 6a0dc0822303e49d401b6cb015d446a5bfd8ffaa97a9537b1126427864995503
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de59bb3b607c464110887c24924876ad58bf025f3aa9462f1fda4a9e312c8a7c4b8aa0243bb8dafdc37dda66f866f58ed27c025944fda6d2049fce502255e0e0
|
7
|
+
data.tar.gz: f7913c719a841d6085aeeb3188d57e8bb4da7d8e6cd60fb73ab496a3929b40c0c5021d8723ae4beffa7df27ba1b71601ff16d2339c5976854147ccb2e9348214
|
data/Gemfile.lock
CHANGED
@@ -5,36 +5,79 @@ module Metatron
|
|
5
5
|
module Concerns
|
6
6
|
# A mixin to assist with templating Kubernetes resources that create Pods
|
7
7
|
module PodProducer
|
8
|
-
def self.included(base)
|
8
|
+
def self.included(base) # rubocop:disable Metrics/MethodLength
|
9
9
|
# base.extend ClassMethods
|
10
10
|
base.class_eval do
|
11
|
-
attr_accessor :additional_labels, :additional_pod_labels,
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
11
|
+
attr_accessor :active_deadline_seconds, :additional_labels, :additional_pod_labels,
|
12
|
+
:affinity, :automount_service_account_token, :containers,
|
13
|
+
:dns_policy, :enable_service_links, :hostname, :host_ipc, :host_network,
|
14
|
+
:host_pid, :image_pull_secrets, :init_containers, :node_selector,
|
15
|
+
:node_name, :persistent_volume_claims, :pod_annotations, :restart_policy,
|
16
|
+
:scheduler_name, :security_context, :service_account,
|
17
|
+
:service_account_name, :share_process_namespace, :subdomain,
|
18
|
+
:termination_grace_period_seconds, :tolerations, :volumes
|
15
19
|
|
16
20
|
initializer :pod_producer_initialize
|
17
21
|
|
22
|
+
alias_method :activeDeadlineSeconds, :active_deadline_seconds
|
23
|
+
alias_method :automountServiceAccountToken, :automount_service_account_token
|
24
|
+
alias_method :dnsPolicy, :dns_policy
|
25
|
+
alias_method :enableServiceLinks, :enable_service_links
|
26
|
+
alias_method :hostIPC, :host_ipc
|
27
|
+
alias_method :hostNetwork, :host_network
|
28
|
+
alias_method :hostPID, :host_pid
|
29
|
+
alias_method :nodeSelector, :node_selector
|
30
|
+
alias_method :nodeName, :node_name
|
31
|
+
alias_method :restartPolicy, :restart_policy
|
32
|
+
alias_method :schedulerName, :scheduler_name
|
18
33
|
alias_method :securityContext, :security_context
|
34
|
+
alias_method :serviceAccount, :service_account
|
35
|
+
alias_method :serviceAccountName, :service_account_name
|
36
|
+
alias_method :shareProcessNamespace, :share_process_namespace
|
19
37
|
alias_method :terminationGracePeriodSeconds, :termination_grace_period_seconds
|
20
38
|
end
|
21
39
|
end
|
22
40
|
|
23
41
|
def pod_producer_initialize
|
42
|
+
@additional_labels = {}
|
43
|
+
@additional_pod_labels = {}
|
24
44
|
@affinity = {}
|
25
|
-
@volumes = []
|
26
|
-
@security_context = {}
|
27
45
|
@containers = []
|
46
|
+
@enable_service_links = nil
|
47
|
+
@image_pull_secrets = []
|
28
48
|
@init_containers = []
|
29
|
-
@
|
30
|
-
@
|
49
|
+
@node_selector = {}
|
50
|
+
@persistent_volume_claims = []
|
31
51
|
@pod_annotations = {}
|
52
|
+
@restart_policy = nil
|
53
|
+
@security_context = {}
|
32
54
|
@termination_grace_period_seconds = nil
|
33
55
|
@tolerations = []
|
34
|
-
@
|
56
|
+
@volumes = []
|
35
57
|
end
|
36
58
|
|
37
59
|
def formatted_affinity = affinity && !affinity.empty? ? { affinity: } : {}
|
60
|
+
def formatted_containers = { containers: containers.map(&:render) }
|
61
|
+
|
62
|
+
def formatted_image_pull_secrets
|
63
|
+
if image_pull_secrets&.any?
|
64
|
+
{ imagePullSecrets: image_pull_secrets.map { _1.is_a?(String) ? { name: _1 } : _1 } }
|
65
|
+
else
|
66
|
+
{}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def formatted_init_containers
|
71
|
+
if init_containers&.any?
|
72
|
+
{ initContainers: init_containers.map(&:render) }
|
73
|
+
else
|
74
|
+
{}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def formatted_node_selector
|
79
|
+
node_selector && !node_selector.empty? ? { nodeSelector: } : {}
|
80
|
+
end
|
38
81
|
|
39
82
|
def formatted_pod_annotations
|
40
83
|
pod_annotations && !pod_annotations.empty? ? { annotations: pod_annotations } : {}
|
@@ -58,6 +101,55 @@ module Metatron
|
|
58
101
|
{}
|
59
102
|
end
|
60
103
|
end
|
104
|
+
|
105
|
+
def pod_metadata
|
106
|
+
{
|
107
|
+
metadata: {
|
108
|
+
labels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
|
109
|
+
}.merge(formatted_pod_annotations)
|
110
|
+
}
|
111
|
+
end
|
112
|
+
|
113
|
+
# rubocop:disable Metrics/AbcSize
|
114
|
+
# rubocop:disable Metrics/MethodLength
|
115
|
+
def pod_spec
|
116
|
+
{
|
117
|
+
spec: {
|
118
|
+
activeDeadlineSeconds:,
|
119
|
+
automountServiceAccountToken:,
|
120
|
+
dnsPolicy:,
|
121
|
+
enableServiceLinks:,
|
122
|
+
hostIPC:,
|
123
|
+
hostNetwork:,
|
124
|
+
hostPID:,
|
125
|
+
hostname:,
|
126
|
+
nodeName:,
|
127
|
+
restartPolicy:,
|
128
|
+
schedulerName:,
|
129
|
+
serviceAccount:,
|
130
|
+
serviceAccountName:,
|
131
|
+
shareProcessNamespace:,
|
132
|
+
subdomain:,
|
133
|
+
terminationGracePeriodSeconds:
|
134
|
+
}.merge(formatted_volumes)
|
135
|
+
.merge(formatted_affinity)
|
136
|
+
.merge(formatted_tolerations)
|
137
|
+
.merge(formatted_security_context)
|
138
|
+
.merge(formatted_containers)
|
139
|
+
.merge(formatted_init_containers)
|
140
|
+
.merge(formatted_image_pull_secrets)
|
141
|
+
.merge(formatted_node_selector)
|
142
|
+
.compact
|
143
|
+
}.compact
|
144
|
+
end
|
145
|
+
# rubocop:enable Metrics/AbcSize
|
146
|
+
# rubocop:enable Metrics/MethodLength
|
147
|
+
|
148
|
+
def pod_template
|
149
|
+
{
|
150
|
+
template: {}.merge(pod_metadata).merge(pod_spec).compact
|
151
|
+
}
|
152
|
+
end
|
61
153
|
end
|
62
154
|
end
|
63
155
|
end
|
@@ -10,19 +10,10 @@ module Metatron
|
|
10
10
|
|
11
11
|
attr_accessor :schedule, :suspend, :concurrency_policy, :starting_deadline_seconds,
|
12
12
|
:successful_jobs_history_limit, :failed_jobs_history_limit,
|
13
|
-
:
|
14
|
-
:dns_policy, :restart_policy,
|
15
|
-
:scheduler_name, :service_account, :service_account_name
|
13
|
+
:backoff_limit
|
16
14
|
|
17
|
-
alias automountServiceAccountToken automount_service_account_token
|
18
15
|
alias backoffLimit backoff_limit
|
19
|
-
alias activeDeadlineSeconds active_deadline_seconds
|
20
16
|
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
17
|
alias startingDeadlineSeconds starting_deadline_seconds
|
27
18
|
alias successfulJobsHistoryLimit successful_jobs_history_limit
|
28
19
|
alias failedJobsHistoryLimit failed_jobs_history_limit
|
@@ -31,11 +22,9 @@ module Metatron
|
|
31
22
|
super(name)
|
32
23
|
@schedule = schedule
|
33
24
|
@api_version = "batch/v1"
|
34
|
-
@restart_policy = "OnFailure"
|
35
25
|
end
|
36
26
|
|
37
27
|
# rubocop:disable Metrics/AbcSize
|
38
|
-
# rubocop:disable Metrics/MethodLength
|
39
28
|
def render
|
40
29
|
{
|
41
30
|
apiVersion:,
|
@@ -54,30 +43,13 @@ module Metatron
|
|
54
43
|
jobTemplate: {
|
55
44
|
spec: {
|
56
45
|
activeDeadlineSeconds:,
|
57
|
-
backoffLimit
|
58
|
-
|
59
|
-
|
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
|
46
|
+
backoffLimit:
|
47
|
+
}.merge(pod_template).compact
|
48
|
+
}.merge(formatted_tolerations).compact
|
76
49
|
}.compact
|
77
50
|
}
|
78
51
|
end
|
79
52
|
# rubocop:enable Metrics/AbcSize
|
80
|
-
# rubocop:enable Metrics/MethodLength
|
81
53
|
end
|
82
54
|
end
|
83
55
|
end
|
@@ -15,8 +15,6 @@ module Metatron
|
|
15
15
|
@api_version = "apps/v1"
|
16
16
|
end
|
17
17
|
|
18
|
-
# rubocop:disable Metrics/AbcSize
|
19
|
-
# rubocop:disable Metrics/MethodLength
|
20
18
|
def render
|
21
19
|
{
|
22
20
|
apiVersion:,
|
@@ -28,25 +26,10 @@ module Metatron
|
|
28
26
|
spec: {
|
29
27
|
selector: {
|
30
28
|
matchLabels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
|
31
|
-
},
|
32
|
-
template: {
|
33
|
-
metadata: {
|
34
|
-
labels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
|
35
|
-
}.merge(formatted_pod_annotations),
|
36
|
-
spec: {
|
37
|
-
terminationGracePeriodSeconds:,
|
38
|
-
containers: containers.map(&:render),
|
39
|
-
init_containers: init_containers.any? ? init_containers.map(&:render) : nil
|
40
|
-
}.merge(formatted_volumes)
|
41
|
-
.merge(formatted_security_context)
|
42
|
-
.merge(formatted_tolerations)
|
43
|
-
.compact
|
44
29
|
}
|
45
|
-
}
|
30
|
+
}.merge(pod_template)
|
46
31
|
}
|
47
32
|
end
|
48
|
-
# rubocop:enable Metrics/AbcSize
|
49
|
-
# rubocop:enable Metrics/MethodLength
|
50
33
|
end
|
51
34
|
end
|
52
35
|
end
|
@@ -16,8 +16,6 @@ module Metatron
|
|
16
16
|
@replicas = replicas
|
17
17
|
end
|
18
18
|
|
19
|
-
# rubocop:disable Metrics/MethodLength
|
20
|
-
# rubocop:disable Metrics/AbcSize
|
21
19
|
def render
|
22
20
|
{
|
23
21
|
apiVersion:,
|
@@ -31,25 +29,10 @@ module Metatron
|
|
31
29
|
strategy: { type: "RollingUpdate", rollingUpdate: { maxSurge: 2, maxUnavailable: 0 } },
|
32
30
|
selector: {
|
33
31
|
matchLabels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
|
34
|
-
},
|
35
|
-
template: {
|
36
|
-
metadata: {
|
37
|
-
labels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
|
38
|
-
}.merge(formatted_pod_annotations).merge(formatted_namespace),
|
39
|
-
spec: {
|
40
|
-
terminationGracePeriodSeconds:,
|
41
|
-
containers: containers.map(&:render),
|
42
|
-
init_containers: init_containers.any? ? init_containers.map(&:render) : nil
|
43
|
-
}.merge(formatted_volumes)
|
44
|
-
.merge(formatted_security_context)
|
45
|
-
.merge(formatted_tolerations)
|
46
|
-
.compact
|
47
32
|
}
|
48
|
-
}
|
33
|
+
}.merge(pod_template)
|
49
34
|
}
|
50
35
|
end
|
51
|
-
# rubocop:enable Metrics/AbcSize
|
52
|
-
# rubocop:enable Metrics/MethodLength
|
53
36
|
end
|
54
37
|
end
|
55
38
|
end
|
@@ -23,8 +23,6 @@ module Metatron
|
|
23
23
|
@api_version = "batch/v1"
|
24
24
|
end
|
25
25
|
|
26
|
-
# rubocop:disable Metrics/AbcSize
|
27
|
-
# rubocop:disable Metrics/MethodLength
|
28
26
|
def render
|
29
27
|
{
|
30
28
|
apiVersion:,
|
@@ -40,23 +38,10 @@ module Metatron
|
|
40
38
|
completions:,
|
41
39
|
parallelism:,
|
42
40
|
podFailurePolicy:,
|
43
|
-
ttlSecondsAfterFinished
|
44
|
-
|
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
|
41
|
+
ttlSecondsAfterFinished:
|
42
|
+
}.merge(pod_template).compact
|
56
43
|
}
|
57
44
|
end
|
58
|
-
# rubocop:enable Metrics/AbcSize
|
59
|
-
# rubocop:enable Metrics/MethodLength
|
60
45
|
end
|
61
46
|
end
|
62
47
|
end
|
@@ -8,7 +8,6 @@ module Metatron
|
|
8
8
|
include Concerns::PodProducer
|
9
9
|
include Concerns::Namespaced
|
10
10
|
|
11
|
-
# rubocop:disable Metrics/AbcSize
|
12
11
|
def render
|
13
12
|
{
|
14
13
|
apiVersion:,
|
@@ -16,18 +15,9 @@ module Metatron
|
|
16
15
|
metadata: {
|
17
16
|
labels: { "#{label_namespace}/name": name }.merge(additional_labels),
|
18
17
|
name:
|
19
|
-
}.merge(formatted_annotations).merge(formatted_namespace)
|
20
|
-
|
21
|
-
terminationGracePeriodSeconds:,
|
22
|
-
containers: containers.map(&:render),
|
23
|
-
init_containers: init_containers.any? ? init_containers.map(&:render) : nil
|
24
|
-
}.merge(formatted_volumes)
|
25
|
-
.merge(formatted_security_context)
|
26
|
-
.merge(formatted_tolerations)
|
27
|
-
.compact
|
28
|
-
}
|
18
|
+
}.merge(formatted_annotations).merge(formatted_namespace)
|
19
|
+
}.merge(pod_spec)
|
29
20
|
end
|
30
|
-
# rubocop:enable Metrics/AbcSize
|
31
21
|
end
|
32
22
|
end
|
33
23
|
end
|
@@ -16,8 +16,6 @@ module Metatron
|
|
16
16
|
@replicas = replicas
|
17
17
|
end
|
18
18
|
|
19
|
-
# rubocop:disable Metrics/MethodLength
|
20
|
-
# rubocop:disable Metrics/AbcSize
|
21
19
|
def render
|
22
20
|
{
|
23
21
|
apiVersion:,
|
@@ -30,25 +28,10 @@ module Metatron
|
|
30
28
|
replicas:,
|
31
29
|
selector: {
|
32
30
|
matchLabels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
|
33
|
-
},
|
34
|
-
template: {
|
35
|
-
metadata: {
|
36
|
-
labels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
|
37
|
-
}.merge(formatted_pod_annotations),
|
38
|
-
spec: {
|
39
|
-
terminationGracePeriodSeconds:,
|
40
|
-
containers: containers.map(&:render),
|
41
|
-
init_containers: init_containers.any? ? init_containers.map(&:render) : nil
|
42
|
-
}.merge(formatted_volumes)
|
43
|
-
.merge(formatted_security_context)
|
44
|
-
.merge(formatted_tolerations)
|
45
|
-
.compact
|
46
31
|
}
|
47
|
-
}
|
32
|
+
}.merge(pod_template)
|
48
33
|
}
|
49
34
|
end
|
50
|
-
# rubocop:enable Metrics/AbcSize
|
51
|
-
# rubocop:enable Metrics/MethodLength
|
52
35
|
end
|
53
36
|
end
|
54
37
|
end
|
@@ -8,14 +8,13 @@ module Metatron
|
|
8
8
|
include Concerns::PodProducer
|
9
9
|
include Concerns::Namespaced
|
10
10
|
|
11
|
-
attr_accessor :replicas, :service_name, :pod_management_policy
|
11
|
+
attr_accessor :replicas, :service_name, :pod_management_policy
|
12
12
|
|
13
13
|
def initialize(name, replicas: 1)
|
14
14
|
super(name)
|
15
15
|
@replicas = replicas
|
16
16
|
@api_version = "apps/v1"
|
17
17
|
@pod_management_policy = "OrderedReady"
|
18
|
-
@enable_service_links = true
|
19
18
|
@service_name = name
|
20
19
|
end
|
21
20
|
|
@@ -23,8 +22,6 @@ module Metatron
|
|
23
22
|
alias podManagementPolicy pod_management_policy
|
24
23
|
alias serviceName service_name
|
25
24
|
|
26
|
-
# rubocop:disable Metrics/MethodLength
|
27
|
-
# rubocop:disable Metrics/AbcSize
|
28
25
|
def render
|
29
26
|
{
|
30
27
|
apiVersion:,
|
@@ -36,29 +33,13 @@ module Metatron
|
|
36
33
|
spec: {
|
37
34
|
replicas:,
|
38
35
|
serviceName:,
|
39
|
-
enableServiceLinks:,
|
40
36
|
strategy: { type: "RollingUpdate", rollingUpdate: { maxSurge: 2, maxUnavailable: 0 } },
|
41
37
|
selector: {
|
42
38
|
matchLabels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
|
43
|
-
},
|
44
|
-
template: {
|
45
|
-
metadata: {
|
46
|
-
labels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
|
47
|
-
}.merge(formatted_pod_annotations),
|
48
|
-
spec: {
|
49
|
-
terminationGracePeriodSeconds:,
|
50
|
-
containers: containers.map(&:render),
|
51
|
-
init_containers: init_containers.any? ? init_containers.map(&:render) : nil
|
52
|
-
}.merge(formatted_volumes)
|
53
|
-
.merge(formatted_affinity)
|
54
|
-
.merge(formatted_tolerations)
|
55
|
-
.compact
|
56
39
|
}
|
57
|
-
}
|
40
|
+
}.merge(pod_template)
|
58
41
|
}.merge(volume_claim_templates)
|
59
42
|
end
|
60
|
-
# rubocop:enable Metrics/AbcSize
|
61
|
-
# rubocop:enable Metrics/MethodLength
|
62
43
|
end
|
63
44
|
end
|
64
45
|
end
|
data/lib/metatron/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.3
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|