cuber 1.6.0 → 1.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39f690dbfe51c572573fa0bf59c5f43c1b2806576aed7249afafa94d9184f146
4
- data.tar.gz: 03a35ba128901bb1d2a86a95f517cfeb44383da40b5351914ccdda21e8d21315
3
+ metadata.gz: 8c28c18ed3acd87a99a88d336b9b729d4089efe1f97224b9bc4d16058a7ace8e
4
+ data.tar.gz: 36957c9449da91c15284dbd041edef524627c33dbf3252300049baf717f64c5b
5
5
  SHA512:
6
- metadata.gz: 1800876c72eac1ad1066cf17bdf139ee3ce204c3d32eff529dad6fd031632a0c1c8b912012fb37ce900d912d76f846bdfd9ffdc505cbbc6e54f1fd80ceecff92
7
- data.tar.gz: f6a2dc6449e62325d82d988b392b9dd2cea53cc7584701fe7901093c7d6ceef009114f7dda2a95bec25f9426d40fcc56e333bd7240309f3d272341cde8a0a486
6
+ metadata.gz: 8498fc1f4c44b8e6fe4ed0939eec0e6229bb44e0dc66da2eb1e504e3304d0e2f74dc5d5ba40a123f884d9550fa584e245400cf0a1e3124beda52c0a078a48628
7
+ data.tar.gz: 2f76ecbc4462b448069ec251ccfebbc9c4def63ca4be2e2378d37e63b3db8df38ea889830b4a1ef0e73be51a9f2de418fc81bb3f83c5c79eb46080825a2706d8
data/lib/cuber/cli.rb CHANGED
@@ -7,6 +7,7 @@ require 'yaml'
7
7
  require 'json'
8
8
  require 'shellwords'
9
9
  require 'time'
10
+ require 'uri'
10
11
 
11
12
  module Cuber
12
13
  class CLI
@@ -26,7 +27,7 @@ module Cuber
26
27
  end
27
28
 
28
29
  def parse_cuberfile
29
- abort 'Cuberfile not found in current directory' unless File.exists? 'Cuberfile'
30
+ abort 'Cuberfile not found in current directory' unless File.exist? 'Cuberfile'
30
31
  content = File.read 'Cuberfile'
31
32
  parser = CuberfileParser.new
32
33
  parser.instance_eval(content)
@@ -98,7 +98,7 @@ module Cuber::Commands
98
98
  schedule = cron['spec']['schedule']
99
99
  command = cron['spec']['jobTemplate']['spec']['template']['spec']['containers'][0]['command'].shelljoin
100
100
  last = cron['status']['lastScheduleTime']
101
- puts "#{name}: #{schedule} #{command} (#{time_ago_in_words last})"
101
+ puts "#{name}: #{schedule} #{command} #{'(' + time_ago_in_words(last) + ')' if last}"
102
102
  end
103
103
  end
104
104
 
@@ -15,6 +15,7 @@ module Cuber
15
15
  @cron = {}
16
16
  @secrets = {}
17
17
  @env = {}
18
+ @health = nil
18
19
  @lb = {}
19
20
  @ingress = nil
20
21
  @ssl = nil
@@ -75,6 +76,10 @@ module Cuber
75
76
  def env key, value, secret: false
76
77
  secret ? (@secrets[key] = value) : (@env[key] = value)
77
78
  end
79
+
80
+ def health url
81
+ @health = url
82
+ end
78
83
 
79
84
  def lb key, value
80
85
  @lb[key] = value
@@ -20,6 +20,7 @@ module Cuber
20
20
  validate_procs
21
21
  validate_cron
22
22
  validate_env
23
+ validate_health
23
24
  validate_lb
24
25
  validate_ingress
25
26
  validate_ssl
@@ -49,7 +50,7 @@ module Cuber
49
50
 
50
51
  def validate_dockerfile
51
52
  return unless @options[:dockerfile]
52
- @errors << 'dockerfile must be a file' unless File.exists? @options[:dockerfile]
53
+ @errors << 'dockerfile must be a file' unless File.exist? @options[:dockerfile]
53
54
  end
54
55
 
55
56
  def validate_image
@@ -63,12 +64,12 @@ module Cuber
63
64
 
64
65
  def validate_dockerconfig
65
66
  return unless @options[:dockerconfig]
66
- @errors << 'dockerconfig must be a file' unless File.exists? @options[:dockerconfig]
67
+ @errors << 'dockerconfig must be a file' unless File.exist? @options[:dockerconfig]
67
68
  end
68
69
 
69
70
  def validate_kubeconfig
70
71
  @errors << 'kubeconfig must be present' if @options[:kubeconfig].to_s.strip.empty?
71
- @errors << 'kubeconfig must be a file' unless File.exists? @options[:kubeconfig]
72
+ @errors << 'kubeconfig must be a file' unless File.exist? @options[:kubeconfig]
72
73
  end
73
74
 
74
75
  def validate_migrate
@@ -103,6 +104,11 @@ module Cuber
103
104
  @errors << "env \"#{key}\" name can only include uppercase letters, digits or underscores" if key !~ /\A[A-Z_]+[A-Z0-9_]*\z/
104
105
  end
105
106
  end
107
+
108
+ def validate_health
109
+ return unless @options[:health]
110
+ @errors << 'health checks must be an http url' unless URI.parse(@options[:health]).kind_of? URI::HTTP
111
+ end
106
112
 
107
113
  def validate_lb
108
114
  @options[:lb].each do |key, value|
@@ -117,8 +123,8 @@ module Cuber
117
123
 
118
124
  def validate_ssl
119
125
  return unless @options[:ssl]
120
- @errors << 'ssl crt must be a file' unless File.exists? @options[:ssl][:crt]
121
- @errors << 'ssl key must be a file' unless File.exists? @options[:ssl][:key]
126
+ @errors << 'ssl crt must be a file' unless File.exist? @options[:ssl][:crt]
127
+ @errors << 'ssl key must be a file' unless File.exist? @options[:ssl][:key]
122
128
  end
123
129
 
124
130
  end
@@ -59,6 +59,23 @@ data:
59
59
  <%= key %>: <%= value.to_s.to_json %>
60
60
  <%- end -%>
61
61
 
62
+ ---
63
+ apiVersion: policy/v1
64
+ kind: PodDisruptionBudget
65
+ metadata:
66
+ name: web-pdb
67
+ namespace: <%= @options[:app] %>
68
+ labels:
69
+ app.kubernetes.io/name: <%= @options[:app] %>
70
+ app.kubernetes.io/instance: <%= @options[:instance] %>
71
+ app.kubernetes.io/version: <%= @options[:release] %>
72
+ app.kubernetes.io/managed-by: cuber
73
+ spec:
74
+ maxUnavailable: "50%"
75
+ selector:
76
+ matchLabels:
77
+ app: web-proc
78
+
62
79
  <%- if @options[:migrate] -%>
63
80
  ---
64
81
  apiVersion: batch/v1
@@ -164,10 +181,17 @@ spec:
164
181
  value: "8080"
165
182
  ports:
166
183
  - containerPort: 8080
184
+ <%- end -%>
185
+ <%- if procname.to_s == 'web' && @options[:health] -%>
167
186
  readinessProbe:
168
187
  httpGet:
169
- path: /
170
188
  port: 8080
189
+ path: <%= URI.parse(@options[:health]).path.to_json %>
190
+ httpHeaders:
191
+ - name: Host
192
+ value: <%= URI.parse(@options[:health]).host.to_json %>
193
+ - name: X-Forwarded-Proto
194
+ value: <%= URI.parse(@options[:health]).scheme.to_json %>
171
195
  <%- end -%>
172
196
  <%- if @options[:migrate] && @options[:migrate][:check] -%>
173
197
  initContainers:
data/lib/cuber/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cuber
2
- VERSION = '1.6.0'.freeze
2
+ VERSION = '1.8.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuber
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cuber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-01 00:00:00.000000000 Z
11
+ date: 2022-11-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: