active_job_kubernetes 0.1.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 +7 -0
- data/.gitignore +161 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +86 -0
- data/Rakefile +2 -0
- data/active_job_kubernetes.gemspec +32 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/active_job/queue_adapters/kubernetes_adapter.rb +28 -0
- data/lib/active_job_kubernetes.rb +5 -0
- data/lib/active_job_kubernetes/railtie.rb +9 -0
- data/lib/active_job_kubernetes/tasks.rb +7 -0
- data/lib/active_job_kubernetes/version.rb +5 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 20cb5ea1a776e1bdc7a93510580960fafea94e8dbb8fa739c849b27b772491cb
|
4
|
+
data.tar.gz: 392ea4a6686dce2dc6811e4bf42a0216d1273daad44ed33cd164b1c2fb63f102
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8c546c75198de4773100c310bf24dfebc7f9904813380545de75b02a0b64fdd0d95b19c33e3251f5bcbc3de201bba677c5005f61bfebdbb1a8d28288d06de123
|
7
|
+
data.tar.gz: 601c2c186a5316b08207f01edfe4f55716678790d9c779e278fd27078a04e759465368b94029f1fdb144f1097065f235ec415a272f63a075faa89f8fd97c7055
|
data/.gitignore
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
### Linux ###
|
2
|
+
*~
|
3
|
+
|
4
|
+
# temporary files which can be created if a process still has a handle open of a deleted file
|
5
|
+
.fuse_hidden*
|
6
|
+
|
7
|
+
# KDE directory preferences
|
8
|
+
.directory
|
9
|
+
|
10
|
+
# Linux trash folder which might appear on any partition or disk
|
11
|
+
.Trash-*
|
12
|
+
|
13
|
+
# .nfs files are created when an open file is removed but is still being accessed
|
14
|
+
.nfs*
|
15
|
+
|
16
|
+
### macOS ###
|
17
|
+
# General
|
18
|
+
.DS_Store
|
19
|
+
.AppleDouble
|
20
|
+
.LSOverride
|
21
|
+
|
22
|
+
# Icon must end with two \r
|
23
|
+
Icon
|
24
|
+
|
25
|
+
|
26
|
+
# Thumbnails
|
27
|
+
._*
|
28
|
+
|
29
|
+
# Files that might appear in the root of a volume
|
30
|
+
.DocumentRevisions-V100
|
31
|
+
.fseventsd
|
32
|
+
.Spotlight-V100
|
33
|
+
.TemporaryItems
|
34
|
+
.Trashes
|
35
|
+
.VolumeIcon.icns
|
36
|
+
.com.apple.timemachine.donotpresent
|
37
|
+
|
38
|
+
# Directories potentially created on remote AFP share
|
39
|
+
.AppleDB
|
40
|
+
.AppleDesktop
|
41
|
+
Network Trash Folder
|
42
|
+
Temporary Items
|
43
|
+
.apdisk
|
44
|
+
|
45
|
+
### Ruby ###
|
46
|
+
*.gem
|
47
|
+
*.rbc
|
48
|
+
/.config
|
49
|
+
/coverage/
|
50
|
+
/InstalledFiles
|
51
|
+
/pkg/
|
52
|
+
/spec/reports/
|
53
|
+
/spec/examples.txt
|
54
|
+
/test/tmp/
|
55
|
+
/test/version_tmp/
|
56
|
+
/tmp/
|
57
|
+
|
58
|
+
# Used by dotenv library to load environment variables.
|
59
|
+
# .env
|
60
|
+
|
61
|
+
# Ignore Byebug command history file.
|
62
|
+
.byebug_history
|
63
|
+
|
64
|
+
## Specific to RubyMotion:
|
65
|
+
.dat*
|
66
|
+
.repl_history
|
67
|
+
build/
|
68
|
+
*.bridgesupport
|
69
|
+
build-iPhoneOS/
|
70
|
+
build-iPhoneSimulator/
|
71
|
+
|
72
|
+
## Specific to RubyMotion (use of CocoaPods):
|
73
|
+
#
|
74
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
75
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
76
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
77
|
+
# vendor/Pods/
|
78
|
+
|
79
|
+
## Documentation cache and generated files:
|
80
|
+
/.yardoc/
|
81
|
+
/_yardoc/
|
82
|
+
/doc/
|
83
|
+
/rdoc/
|
84
|
+
|
85
|
+
## Environment normalization:
|
86
|
+
/.bundle/
|
87
|
+
/vendor/bundle
|
88
|
+
/lib/bundler/man/
|
89
|
+
|
90
|
+
# for a library or gem, you might want to ignore these files since the code is
|
91
|
+
# intended to run in multiple environments; otherwise, check them in:
|
92
|
+
Gemfile.lock
|
93
|
+
.ruby-version
|
94
|
+
.ruby-gemset
|
95
|
+
|
96
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
97
|
+
.rvmrc
|
98
|
+
|
99
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
100
|
+
# .rubocop-https?--*
|
101
|
+
|
102
|
+
### Vim ###
|
103
|
+
# Swap
|
104
|
+
[._]*.s[a-v][a-z]
|
105
|
+
!*.svg # comment out if you don't need vector files
|
106
|
+
[._]*.sw[a-p]
|
107
|
+
[._]s[a-rt-v][a-z]
|
108
|
+
[._]ss[a-gi-z]
|
109
|
+
[._]sw[a-p]
|
110
|
+
|
111
|
+
# Session
|
112
|
+
Session.vim
|
113
|
+
Sessionx.vim
|
114
|
+
|
115
|
+
# Temporary
|
116
|
+
.netrwhist
|
117
|
+
# Auto-generated tag files
|
118
|
+
tags
|
119
|
+
# Persistent undo
|
120
|
+
[._]*.un~
|
121
|
+
|
122
|
+
### VisualStudioCode ###
|
123
|
+
.vscode/*
|
124
|
+
!.vscode/tasks.json
|
125
|
+
!.vscode/launch.json
|
126
|
+
!.vscode/extensions.json
|
127
|
+
*.code-workspace
|
128
|
+
|
129
|
+
# Local History for Visual Studio Code
|
130
|
+
.history/
|
131
|
+
|
132
|
+
### VisualStudioCode Patch ###
|
133
|
+
# Ignore all local history of files
|
134
|
+
.history
|
135
|
+
.ionide
|
136
|
+
|
137
|
+
### Windows ###
|
138
|
+
# Windows thumbnail cache files
|
139
|
+
Thumbs.db
|
140
|
+
Thumbs.db:encryptable
|
141
|
+
ehthumbs.db
|
142
|
+
ehthumbs_vista.db
|
143
|
+
|
144
|
+
# Dump file
|
145
|
+
*.stackdump
|
146
|
+
|
147
|
+
# Folder config file
|
148
|
+
[Dd]esktop.ini
|
149
|
+
|
150
|
+
# Recycle Bin used on file shares
|
151
|
+
$RECYCLE.BIN/
|
152
|
+
|
153
|
+
# Windows Installer files
|
154
|
+
*.cab
|
155
|
+
*.msi
|
156
|
+
*.msix
|
157
|
+
*.msm
|
158
|
+
*.msp
|
159
|
+
|
160
|
+
# Windows shortcuts
|
161
|
+
*.lnk
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 Omja Das
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# active-job-kubernetes
|
2
|
+
|
3
|
+
Rails Active Job adapter to run background jobs using
|
4
|
+
[Kubernetes Jobs](https://kubernetes.io/docs/concepts/workloads/controllers/job/).
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'active_job_kubernetes'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
```bash
|
17
|
+
bundle install
|
18
|
+
```
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
```bash
|
23
|
+
gem install active-job-kubernetes
|
24
|
+
```
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
class HelloWorldJob < ApplicationJob
|
30
|
+
self.queue_adapter = :kubernetes
|
31
|
+
|
32
|
+
def perform
|
33
|
+
puts 'Hello, world'
|
34
|
+
end
|
35
|
+
|
36
|
+
def manifest
|
37
|
+
YAML.safe_load(
|
38
|
+
<<~MANIFEST
|
39
|
+
apiVersion: batch/v1
|
40
|
+
kind: Job
|
41
|
+
metadata:
|
42
|
+
generatedName: hello-world
|
43
|
+
spec:
|
44
|
+
template:
|
45
|
+
metadata:
|
46
|
+
name: hello-world
|
47
|
+
spec:
|
48
|
+
restartPolicy: Never
|
49
|
+
containers:
|
50
|
+
- name: worker
|
51
|
+
image: example:latest
|
52
|
+
command: ["rake"]
|
53
|
+
args: ["active_job_kubernetes:run_job"]
|
54
|
+
MANIFEST
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
def kubeclient(scope)
|
59
|
+
endpoint = '' # cluster endpoint
|
60
|
+
|
61
|
+
Kubeclient::Client.new(endpoint + scope, 'v1')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
66
|
+
## Development
|
67
|
+
|
68
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can
|
69
|
+
also run `bin/console` for an interactive prompt that will allow you to
|
70
|
+
experiment.
|
71
|
+
|
72
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
73
|
+
release a new version, update the version number in `version.rb`, and then run
|
74
|
+
`bundle exec rake release`, which will create a git tag for the version, push
|
75
|
+
git commits and tags, and push the `.gem` file to
|
76
|
+
[rubygems.org](https://rubygems.org).
|
77
|
+
|
78
|
+
## Contributing
|
79
|
+
|
80
|
+
Bug reports and pull requests are welcome on GitHub at
|
81
|
+
<https://github.com/omjadas/active-job-kubernetes>.
|
82
|
+
|
83
|
+
## License
|
84
|
+
|
85
|
+
The gem is available as open source under the terms of the
|
86
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/active_job_kubernetes/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'active_job_kubernetes'
|
7
|
+
spec.version = ActiveJobKubernetes::VERSION
|
8
|
+
spec.authors = ['omjadas']
|
9
|
+
spec.email = ['omja.das@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'Active Job Adapter for Kubernetes'
|
12
|
+
spec.description = 'Run Rails Active Jobs as Kubernetes Jobs'
|
13
|
+
spec.homepage = 'https://github.com/omjadas/active-job-kubernetes'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
|
16
|
+
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/omjadas/active-job-kubernetes'
|
19
|
+
spec.metadata['changelog_uri'] = 'https://github.com/omjadas/active-job-kubernetes/blob/main/CHANGELOG.md'
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = 'exe'
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
|
30
|
+
spec.add_dependency 'kubeclient', '~> 4.0'
|
31
|
+
spec.add_dependency 'rails', '>= 5.0', '<7'
|
32
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'active_job_kubernetes'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'kubeclient'
|
4
|
+
|
5
|
+
module ActiveJob
|
6
|
+
module QueueAdapters
|
7
|
+
class KubernetesAdapter
|
8
|
+
def enqueue(job)
|
9
|
+
serialized_job = JSON.dump(job.serialize)
|
10
|
+
kube_job = Kubeclient::Resource.new(job.manifest)
|
11
|
+
|
12
|
+
kube_job.spec.template.spec.containers.map do |container|
|
13
|
+
container.env ||= []
|
14
|
+
container.env.push({
|
15
|
+
'name' => 'SERIALIZED_JOB',
|
16
|
+
'value' => serialized_job
|
17
|
+
})
|
18
|
+
end
|
19
|
+
|
20
|
+
job.kubeclient('/apis/batch').create_job(kube_job)
|
21
|
+
end
|
22
|
+
|
23
|
+
def enqueue_at(_job, _timestamp)
|
24
|
+
raise NotImplementedError, 'Enqueueing jobs in the future is not supported.'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_job_kubernetes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- omjadas
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-08-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: kubeclient
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.0'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '7'
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '5.0'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '7'
|
47
|
+
description: Run Rails Active Jobs as Kubernetes Jobs
|
48
|
+
email:
|
49
|
+
- omja.das@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- ".gitignore"
|
55
|
+
- CHANGELOG.md
|
56
|
+
- Gemfile
|
57
|
+
- LICENSE
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- active_job_kubernetes.gemspec
|
61
|
+
- bin/console
|
62
|
+
- bin/setup
|
63
|
+
- lib/active_job/queue_adapters/kubernetes_adapter.rb
|
64
|
+
- lib/active_job_kubernetes.rb
|
65
|
+
- lib/active_job_kubernetes/railtie.rb
|
66
|
+
- lib/active_job_kubernetes/tasks.rb
|
67
|
+
- lib/active_job_kubernetes/version.rb
|
68
|
+
homepage: https://github.com/omjadas/active-job-kubernetes
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata:
|
72
|
+
homepage_uri: https://github.com/omjadas/active-job-kubernetes
|
73
|
+
source_code_uri: https://github.com/omjadas/active-job-kubernetes
|
74
|
+
changelog_uri: https://github.com/omjadas/active-job-kubernetes/blob/main/CHANGELOG.md
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 2.5.0
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubygems_version: 3.1.6
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Active Job Adapter for Kubernetes
|
94
|
+
test_files: []
|