kuby-sidekiq 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 +7 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +15 -0
- data/LICENSE +21 -0
- data/Rakefile +14 -0
- data/kuby-sidekiq.gemspec +20 -0
- data/lib/kuby/sidekiq.rb +4 -0
- data/lib/kuby/sidekiq/plugin.rb +191 -0
- data/lib/kuby/sidekiq/version.rb +5 -0
- metadata +78 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ddd1db54a92a99303ce2a394f0f5599b1c4b779201108818db0212f4d7a1f331
|
4
|
+
data.tar.gz: 96a74cb456fe1a79c4ce22ce48edf1292c0f06728601f451723686f79107fd02
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b74a8fe95168dea2a3cbe33acd3f12d7f9303856c8a576316f8da217a70c71aa8872612b5f49d06d7a9ee5a5b6168701037914c370e57bc304a0e239994f1c6d
|
7
|
+
data.tar.gz: 8b756dc1b800a4f7aef1559440bb89e781c20237ce15843860e593942182fbd1a8eb504624075925ada43f67f61debd48e1b48c37c7060d4c05dd19728ff3b0f
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Cameron Dutro
|
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/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubygems/package_task'
|
4
|
+
|
5
|
+
require 'kuby/sidekiq'
|
6
|
+
|
7
|
+
Bundler::GemHelper.install_tasks
|
8
|
+
|
9
|
+
task default: :spec
|
10
|
+
|
11
|
+
desc 'Run specs'
|
12
|
+
RSpec::Core::RakeTask.new do |t|
|
13
|
+
t.pattern = './spec/**/*_spec.rb'
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), 'lib')
|
2
|
+
require 'kuby/sidekiq/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'kuby-sidekiq'
|
6
|
+
s.version = ::Kuby::Sidekiq::VERSION
|
7
|
+
s.authors = ['Cameron Dutro']
|
8
|
+
s.email = ['camertron@gmail.com']
|
9
|
+
s.homepage = 'http://github.com/getkuby/kuby-sidekiq'
|
10
|
+
|
11
|
+
s.description = s.summary = 'Sidekiq plugin for Kuby.'
|
12
|
+
|
13
|
+
s.platform = Gem::Platform::RUBY
|
14
|
+
|
15
|
+
s.add_dependency 'kuby-kube-db', '~> 0.4'
|
16
|
+
s.add_dependency 'kube-dsl', '~> 0.3'
|
17
|
+
|
18
|
+
s.require_path = 'lib'
|
19
|
+
s.files = Dir['{lib,spec}/**/*', 'Gemfile', 'LICENSE', 'CHANGELOG.md', 'README.md', 'Rakefile', 'kuby-sidekiq.gemspec']
|
20
|
+
end
|
data/lib/kuby/sidekiq.rb
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
3
|
+
module Kuby
|
4
|
+
module Sidekiq
|
5
|
+
class Plugin < ::Kuby::Kubernetes::Plugin
|
6
|
+
extend ::KubeDSL::ValueFields
|
7
|
+
|
8
|
+
ROLE = 'worker'.freeze
|
9
|
+
|
10
|
+
value_fields :replicas
|
11
|
+
|
12
|
+
def url
|
13
|
+
@url ||= "redis://#{redis.metadata.name}:6379/0"
|
14
|
+
end
|
15
|
+
|
16
|
+
def after_initialize
|
17
|
+
@replicas = 1
|
18
|
+
end
|
19
|
+
|
20
|
+
def after_configuration
|
21
|
+
return unless rails_app
|
22
|
+
|
23
|
+
deployment.spec.template.spec.container(:worker).merge!(
|
24
|
+
rails_app.deployment.spec.template.spec.container(:web), fields: [:env_from]
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def before_deploy(manifest)
|
29
|
+
image_with_tag = "#{docker.metadata.image_url}:#{kubernetes.tag}"
|
30
|
+
|
31
|
+
deployment do
|
32
|
+
spec do
|
33
|
+
template do
|
34
|
+
spec do
|
35
|
+
container(:worker) do
|
36
|
+
image image_with_tag
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def resources
|
45
|
+
@resources ||= [
|
46
|
+
service_account,
|
47
|
+
deployment,
|
48
|
+
redis
|
49
|
+
]
|
50
|
+
end
|
51
|
+
|
52
|
+
def service_account(&block)
|
53
|
+
context = self
|
54
|
+
|
55
|
+
@service_account ||= KubeDSL.service_account do
|
56
|
+
metadata do
|
57
|
+
name "#{context.selector_app}-sidekiq-sa"
|
58
|
+
namespace context.namespace.metadata.name
|
59
|
+
|
60
|
+
labels do
|
61
|
+
add :app, context.selector_app
|
62
|
+
add :role, ROLE
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
@service_account.instance_eval(&block) if block
|
68
|
+
@service_account
|
69
|
+
end
|
70
|
+
|
71
|
+
def deployment(&block)
|
72
|
+
context = self
|
73
|
+
|
74
|
+
@deployment ||= KubeDSL.deployment do
|
75
|
+
metadata do
|
76
|
+
name "#{context.selector_app}-sidekiq-#{ROLE}"
|
77
|
+
namespace context.namespace.metadata.name
|
78
|
+
|
79
|
+
labels do
|
80
|
+
add :app, context.selector_app
|
81
|
+
add :role, ROLE
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
spec do
|
86
|
+
replicas context.replicas
|
87
|
+
|
88
|
+
selector do
|
89
|
+
match_labels do
|
90
|
+
add :app, context.selector_app
|
91
|
+
add :role, ROLE
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
strategy do
|
96
|
+
type 'RollingUpdate'
|
97
|
+
|
98
|
+
rolling_update do
|
99
|
+
max_surge '25%'
|
100
|
+
max_unavailable 0
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
template do
|
105
|
+
metadata do
|
106
|
+
labels do
|
107
|
+
add :app, context.selector_app
|
108
|
+
add :role, ROLE
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
spec do
|
113
|
+
container(:worker) do
|
114
|
+
name "#{context.selector_app}-sidekiq-#{ROLE}"
|
115
|
+
image_pull_policy 'IfNotPresent'
|
116
|
+
command %w(bundle exec sidekiq)
|
117
|
+
end
|
118
|
+
|
119
|
+
image_pull_secret do
|
120
|
+
name context.kubernetes.registry_secret.metadata.name
|
121
|
+
end
|
122
|
+
|
123
|
+
restart_policy 'Always'
|
124
|
+
service_account_name context.service_account.metadata.name
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
@deployment.instance_eval(&block) if block
|
131
|
+
@deployment
|
132
|
+
end
|
133
|
+
|
134
|
+
def redis(&block)
|
135
|
+
context = self
|
136
|
+
|
137
|
+
@redis ||= Kuby::KubeDB.redis do
|
138
|
+
api_version 'kubedb.com/v1alpha1'
|
139
|
+
|
140
|
+
metadata do
|
141
|
+
name "#{context.selector_app}-sidekiq-redis"
|
142
|
+
namespace context.kubernetes.namespace.metadata.name
|
143
|
+
end
|
144
|
+
|
145
|
+
spec do
|
146
|
+
version '5.0.3-v1'
|
147
|
+
storage_type 'Durable'
|
148
|
+
|
149
|
+
storage do
|
150
|
+
storage_class_name context.storage_class_name
|
151
|
+
access_modes ['ReadWriteOnce']
|
152
|
+
|
153
|
+
resources do
|
154
|
+
requests do
|
155
|
+
add :storage, '1Gi'
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
@redis.instance_eval(&block) if block
|
163
|
+
@redis
|
164
|
+
end
|
165
|
+
|
166
|
+
def storage_class_name
|
167
|
+
kubernetes.provider.storage_class_name
|
168
|
+
end
|
169
|
+
|
170
|
+
def kubernetes
|
171
|
+
definition.kubernetes
|
172
|
+
end
|
173
|
+
|
174
|
+
def docker
|
175
|
+
definition.docker
|
176
|
+
end
|
177
|
+
|
178
|
+
def selector_app
|
179
|
+
kubernetes.selector_app
|
180
|
+
end
|
181
|
+
|
182
|
+
def namespace
|
183
|
+
kubernetes.namespace
|
184
|
+
end
|
185
|
+
|
186
|
+
def rails_app
|
187
|
+
kubernetes.plugin(:rails_app)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kuby-sidekiq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Cameron Dutro
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-06-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: kuby-kube-db
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: kube-dsl
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.3'
|
41
|
+
description: Sidekiq plugin for Kuby.
|
42
|
+
email:
|
43
|
+
- camertron@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- CHANGELOG.md
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE
|
51
|
+
- Rakefile
|
52
|
+
- kuby-sidekiq.gemspec
|
53
|
+
- lib/kuby/sidekiq.rb
|
54
|
+
- lib/kuby/sidekiq/plugin.rb
|
55
|
+
- lib/kuby/sidekiq/version.rb
|
56
|
+
homepage: http://github.com/getkuby/kuby-sidekiq
|
57
|
+
licenses: []
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubygems_version: 3.1.4
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: Sidekiq plugin for Kuby.
|
78
|
+
test_files: []
|