cron-kubernetes 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 218b54415c313d661475b6f73f5cf3218b2a928e8fc65d7236a06ac480f07db1
4
- data.tar.gz: 4d9a5e7687abe849a14ee8c9d817ee418be6ca22738177c65d21be1f0724f526
3
+ metadata.gz: 8d270469720001ff34f95dd439c0de2a23c282a33ccd4ed1b14f4286f39968c8
4
+ data.tar.gz: ab6337710606835428a34ba7a5e7bc8530bf6e8e09eca98a1f245866c4e2ea40
5
5
  SHA512:
6
- metadata.gz: 545a23464d897e6b6591e5ed37c017e6330692bdbc8892f5ffccb023b32c41292af8a7ab8add6de0dc60018eb30299a56bc442166a794956f51ee547938fe62e
7
- data.tar.gz: 262182d7eda44214339da475f0fd488dd20ffd702310267b34b5f80dd3e62d4da298788b88a87c76d60735ecd88334a86e00dc88d7e7df22c10cc75200684d17
6
+ metadata.gz: e5a914ae99f3475d65145458746ed5fe78c0599c1a188b96469332c6b0cf112cde6be15008f0943c3bded3e19b184008fa10077854f660628ddf0ecd241a09fd
7
+ data.tar.gz: a38265b2e4c43ddb8c3f70a10cbd9a8fe5729930c8a11ee120678323ee8e26dd934d44681da36212671314b6f791c6384ee1b38183d4340d8e192b7430d82e5e
data/.rubocop.yml CHANGED
@@ -1,6 +1,8 @@
1
1
  AllCops:
2
2
  Exclude:
3
3
  - "gemfiles/*"
4
+ SuggestExtensions: false
5
+ TargetRubyVersion: 2.7
4
6
 
5
7
  Documentation:
6
8
  Exclude:
@@ -9,9 +11,9 @@ Documentation:
9
11
 
10
12
  Style/StringLiterals:
11
13
  EnforcedStyle: double_quotes
12
- Metrics/LineLength:
14
+ Layout/LineLength:
13
15
  Max: 120
14
- Layout/AlignHash:
16
+ Layout/HashAlignment:
15
17
  EnforcedHashRocketStyle: table
16
18
  EnforcedColonStyle: table
17
19
  Layout/SpaceInsideHashLiteralBraces:
@@ -20,9 +22,9 @@ Style/RaiseArgs:
20
22
  EnforcedStyle: compact
21
23
  Style/EmptyMethod:
22
24
  EnforcedStyle: expanded
23
- Layout/IndentArray:
25
+ Layout/FirstArrayElementIndentation:
24
26
  IndentationWidth: 4
25
- Layout/IndentHash:
27
+ Layout/FirstHashElementIndentation:
26
28
  IndentationWidth: 4
27
29
  Style/ConditionalAssignment:
28
30
  EnforcedStyle: assign_inside_condition
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.0
1
+ 3.2.2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # v2.0.0
2
+ **Breaking Change:**
3
+ - Requires ruby 2.7 or later
4
+
5
+ **Changes:**
6
+ - Fix issue where running `cron_kubernetes` would fail with "ResourceNotFoundError"
7
+
1
8
  # v1.1.0
2
9
  - Fix issue where all cron jobs in a cluster would be removed, not just ones matching `identifier`
3
10
 
data/README.md CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
22
22
  ## Configuration
23
23
 
24
24
  You can configure global settings for your cron jobs. Add a file to your source like the example
25
- below. If you are using Rails, you can add this to something like `config/initializers/cron_kuberentes.rb`.
25
+ below. If you are using Rails, you can add this to something like `config/initializers/cron_kubernetes.rb`.
26
26
 
27
27
  You _must_ configure the `identifier` and `manifest` settings. The other settings are optional
28
28
  and default values are shown below.
@@ -111,12 +111,12 @@ There are many other ways to connect and you can do so by providing your own
111
111
  # config/initializers/resque-kubernetes.rb
112
112
 
113
113
  CronKubernetes.configuration do |config|
114
- config.kubeclient = Kubeclient::Client.new("http://localhost:8080/apis/batch", "v1beta1")
114
+ config.kubeclient = Kubeclient::Client.new("http://localhost:8080/apis/batch", "v1")
115
115
  end
116
116
  ```
117
117
 
118
118
  Because this uses the `CronJob` resource, make sure to connect to the `/apis/batch` API endpoint and
119
- API version `v1beta1` in your client.
119
+ API version `v1` in your client.
120
120
 
121
121
  ## Usage
122
122
 
@@ -161,7 +161,7 @@ Once you have configuration and cluster, then you can run the `cron_kubernetes`
161
161
  to update your cluster.
162
162
 
163
163
  ```bash
164
- cron_kubernetes --configuration config/initializers/cron_kubernetes.rb --schedule config/schedule.rb
164
+ bundle exec cron_kubernetes --configuration config/initializers/cron_kubernetes.rb --schedule config/schedule.rb
165
165
  ```
166
166
 
167
167
  The command will read the provided configuration and current schedule, compare to any
@@ -173,7 +173,7 @@ loaded both a configuration and a schedule. For example, if they are in the same
173
173
  just pass a single value:
174
174
 
175
175
  ```bash
176
- cron_kubernetes --schedule schedule.rb
176
+ bundle exec cron_kubernetes --schedule schedule.rb
177
177
  ```
178
178
 
179
179
  If you are running in a Rails application where the initializers are auto-loaded, and your
@@ -207,7 +207,7 @@ https://github.com/keylime-toolbox/cron-kubernetes-ruby.
207
207
  ### Development
208
208
 
209
209
  After checking out the repo, run `bin/setup` to install dependencies. Then,
210
- run `bin/rake` to run the test suite.
210
+ run `rake` to run the test suite.
211
211
 
212
212
  You can run `bin/console` for an interactive prompt that will allow you to
213
213
  experiment.
data/bin/setup CHANGED
@@ -6,3 +6,4 @@ set -vx
6
6
  bundle install
7
7
 
8
8
  # Do any other automated setup that you need to do here
9
+ appraisal install
@@ -1,4 +1,3 @@
1
-
2
1
  # frozen_string_literal: true
3
2
 
4
3
  lib = File.expand_path("lib", __dir__)
@@ -15,8 +14,9 @@ Gem::Specification.new do |spec|
15
14
  spec.description = "Configure and deploy Kubernetes CronJobs from ruby with a single schedule."
16
15
  spec.homepage = "https://github.com/keylimetoolbox/cron-kubernetes"
17
16
  spec.license = "MIT"
17
+ spec.required_ruby_version = ">= 2.7"
18
18
 
19
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
20
  f.match(%r{^(test|spec|features)/})
21
21
  end
22
22
  spec.require_paths = ["lib"]
@@ -27,12 +27,12 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency "kubeclient", ">= 3.1.2", "< 5.0"
28
28
 
29
29
  spec.add_development_dependency "appraisal"
30
- spec.add_development_dependency "bundler", "~> 1.16"
30
+ spec.add_development_dependency "bundler", "~> 2.4"
31
31
  spec.add_development_dependency "bundler-audit", "~> 0"
32
32
  spec.add_development_dependency "mocha", "~> 1.3"
33
- spec.add_development_dependency "rake", "~> 12.3"
34
- spec.add_development_dependency "rspec", "~> 3.7"
35
- spec.add_development_dependency "rubocop", "~> 0.52", ">= 0.52.1"
33
+ spec.add_development_dependency "rake", "~> 13.1"
34
+ spec.add_development_dependency "rspec", "~> 3.12"
35
+ spec.add_development_dependency "rubocop", "~> 1.57"
36
36
 
37
37
  # For connecting to a GKE cluster in development/test
38
38
  spec.add_development_dependency "googleauth"
@@ -11,6 +11,7 @@ module CronKubernetes
11
11
  #
12
12
  # name: The name of the setting.
13
13
  # default: A default value for the setting. (Optional)
14
+ # rubocop: disable Style/ClassVars
14
15
  def define_setting(name, default = nil)
15
16
  class_variable_set("@@#{name}", default)
16
17
 
@@ -22,6 +23,7 @@ module CronKubernetes
22
23
  class_variable_get("@@#{name}")
23
24
  end
24
25
  end
26
+ # rubocop: enable Style/ClassVars
25
27
 
26
28
  private
27
29
 
@@ -12,11 +12,11 @@ module CronKubernetes
12
12
  config = Kubeclient::Config.read(kubeconfig)
13
13
 
14
14
  CronKubernetes::KubeclientContext::Context.new(
15
- config.context.api_endpoint,
16
- config.context.api_version,
17
- config.context.namespace,
18
- auth_options: auth_options(config),
19
- ssl_options: config.context.ssl_options
15
+ config.context.api_endpoint,
16
+ config.context.api_version,
17
+ config.context.namespace,
18
+ auth_options: auth_options(config),
19
+ ssl_options: config.context.ssl_options
20
20
  )
21
21
  end
22
22
 
@@ -29,11 +29,13 @@ module CronKubernetes
29
29
  def auth_options(config)
30
30
  options = config.context.auth_options
31
31
  return options unless options.empty?
32
+
32
33
  google_application_default_credentials
33
34
  end
34
35
 
35
36
  def google_application_default_credentials
36
37
  return unless defined?(Google) && defined?(Google::Auth)
38
+
37
39
  {bearer_token: Kubeclient::GoogleApplicationDefaultCredentials.token}
38
40
  end
39
41
  end
@@ -14,11 +14,11 @@ module CronKubernetes
14
14
 
15
15
  def context
16
16
  CronKubernetes::KubeclientContext::Context.new(
17
- "https://kubernetes.default.svc",
18
- "v1",
19
- namespace,
20
- auth_options: {bearer_token_file: TOKEN_FILE},
21
- ssl_options: ssl_options
17
+ "https://kubernetes.default.svc",
18
+ "v1",
19
+ namespace,
20
+ auth_options: {bearer_token_file: TOKEN_FILE},
21
+ ssl_options: ssl_options
22
22
  )
23
23
  end
24
24
 
@@ -26,11 +26,13 @@ module CronKubernetes
26
26
 
27
27
  def namespace
28
28
  return nil unless File.exist?(NAMESPACE_FILE)
29
+
29
30
  File.read(NAMESPACE_FILE)
30
31
  end
31
32
 
32
33
  def ssl_options
33
34
  return {} unless File.exist?(CA_FILE)
35
+
34
36
  {ca_file: CA_FILE}
35
37
  end
36
38
  end
@@ -18,7 +18,7 @@ module CronKubernetes
18
18
  # rubocop:disable Metrics/MethodLength
19
19
  def cron_job_manifest
20
20
  {
21
- "apiVersion" => "batch/v1beta1",
21
+ "apiVersion" => "batch/v1",
22
22
  "kind" => "CronJob",
23
23
  "metadata" => {
24
24
  "name" => "#{identifier}-#{cron_job_name}",
@@ -40,6 +40,7 @@ module CronKubernetes
40
40
 
41
41
  def namespace
42
42
  return job_manifest["metadata"]["namespace"] if job_manifest["metadata"] && job_manifest["metadata"]["namespace"]
43
+
43
44
  "default"
44
45
  end
45
46
 
@@ -57,17 +58,17 @@ module CronKubernetes
57
58
  def cron_job_name
58
59
  return name if name
59
60
  return job_hash(job_manifest["metadata"]["name"]) if job_manifest["metadata"]
61
+
60
62
  pod_template_name
61
63
  end
62
64
 
63
- # rubocop:disable Metrics/AbcSize
64
65
  def pod_template_name
65
66
  return nil unless job_manifest["spec"] &&
66
- job_manifest["spec"]["template"] &&
67
- job_manifest["spec"]["template"]["metadata"]
67
+ job_manifest["spec"]["template"] &&
68
+ job_manifest["spec"]["template"]["metadata"]
69
+
68
70
  job_hash(job_manifest["spec"]["template"]["metadata"]["name"])
69
71
  end
70
- # rubocop:enable Metrics/AbcSize
71
72
 
72
73
  def job_hash(name)
73
74
  "#{name}-#{Digest::SHA1.hexdigest(schedule + command.join)[0..7]}"
@@ -18,7 +18,7 @@ module CronKubernetes
18
18
  private
19
19
 
20
20
  def client
21
- @client ||= CronKubernetes::KubernetesClient.new.batch_beta1_client
21
+ @client ||= CronKubernetes::KubernetesClient.new.batch_client
22
22
  end
23
23
 
24
24
  # Define a label for our jobs based on an identifier
@@ -3,8 +3,8 @@
3
3
  module CronKubernetes
4
4
  # Encapsulate access to Kubernetes API for different API versions.
5
5
  class KubernetesClient
6
- def batch_beta1_client
7
- @batch_beta1_client ||= client("/apis/batch", "v1beta1")
6
+ def batch_client
7
+ @batch_client ||= client("/apis/batch", "v1")
8
8
  end
9
9
 
10
10
  def namespace
@@ -16,11 +16,13 @@ module CronKubernetes
16
16
  def client(scope, version = nil)
17
17
  return CronKubernetes.kubeclient if CronKubernetes.kubeclient
18
18
  return unless context
19
+
19
20
  Kubeclient::Client.new(context.endpoint + scope, version || context.version, context.options)
20
21
  end
21
22
 
22
23
  def context
23
24
  return nil if CronKubernetes.kubeclient
25
+
24
26
  @context ||= KubeclientContext.context
25
27
  end
26
28
  end
@@ -44,11 +44,11 @@ module CronKubernetes
44
44
 
45
45
  def new_cron_job(schedule, command, name)
46
46
  CronJob.new(
47
- schedule: schedule,
48
- command: make_command(command),
49
- job_manifest: CronKubernetes.manifest,
50
- name: name,
51
- identifier: @identifier
47
+ schedule: schedule,
48
+ command: make_command(command),
49
+ job_manifest: CronKubernetes.manifest,
50
+ name: name,
51
+ identifier: @identifier
52
52
  )
53
53
  end
54
54
 
@@ -58,6 +58,7 @@ module CronKubernetes
58
58
 
59
59
  def root
60
60
  return Rails.root if defined? Rails
61
+
61
62
  Dir.pwd
62
63
  end
63
64
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CronKubernetes
4
- VERSION = "1.1.0"
4
+ VERSION = "2.0.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cron-kubernetes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Wadsack
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-03 00:00:00.000000000 Z
11
+ date: 2023-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kubeclient
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '1.16'
53
+ version: '2.4'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '1.16'
60
+ version: '2.4'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: bundler-audit
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -92,48 +92,42 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '12.3'
95
+ version: '13.1'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '12.3'
102
+ version: '13.1'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: rspec
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: '3.7'
109
+ version: '3.12'
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: '3.7'
116
+ version: '3.12'
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: rubocop
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: '0.52'
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- version: 0.52.1
123
+ version: '1.57'
127
124
  type: :development
128
125
  prerelease: false
129
126
  version_requirements: !ruby/object:Gem::Requirement
130
127
  requirements:
131
128
  - - "~>"
132
129
  - !ruby/object:Gem::Version
133
- version: '0.52'
134
- - - ">="
135
- - !ruby/object:Gem::Version
136
- version: 0.52.1
130
+ version: '1.57'
137
131
  - !ruby/object:Gem::Dependency
138
132
  name: googleauth
139
133
  requirement: !ruby/object:Gem::Requirement
@@ -188,7 +182,7 @@ homepage: https://github.com/keylimetoolbox/cron-kubernetes
188
182
  licenses:
189
183
  - MIT
190
184
  metadata: {}
191
- post_install_message:
185
+ post_install_message:
192
186
  rdoc_options: []
193
187
  require_paths:
194
188
  - lib
@@ -196,16 +190,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
196
190
  requirements:
197
191
  - - ">="
198
192
  - !ruby/object:Gem::Version
199
- version: '0'
193
+ version: '2.7'
200
194
  required_rubygems_version: !ruby/object:Gem::Requirement
201
195
  requirements:
202
196
  - - ">="
203
197
  - !ruby/object:Gem::Version
204
198
  version: '0'
205
199
  requirements: []
206
- rubyforge_project:
207
- rubygems_version: 2.7.4
208
- signing_key:
200
+ rubygems_version: 3.4.10
201
+ signing_key:
209
202
  specification_version: 4
210
203
  summary: Configure and deploy Kubernetes CronJobs from ruby.
211
204
  test_files: []