mkit 0.6.0 → 0.6.2

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: ca554f25f295a7403d5f0d654663d466430a361c8aa2629961f1710579e62506
4
- data.tar.gz: d670fcc4523810439d73244276766a8e5ff70f2b8a052b292941014a11e7ca3b
3
+ metadata.gz: 49770b23e6d2af3c26a6b8e32291ad24b60e56f6e6fee0f308e3c96fd54f9591
4
+ data.tar.gz: 2fe4f45739fd054f2399f4d1544b0d2bd736a5cc656ffad79da24a97b24e489d
5
5
  SHA512:
6
- metadata.gz: 825f5736fe72ce3bec3aab11f5edfa75b286a6e08ff4e6dc44be37c6d11a034e84a0910fca6ce78cb05ead4483ec228c368a749a301793396ddfc55043fc5bf9
7
- data.tar.gz: 5b0c25f145e1c5ec19d8242d8e613c6746fc3ea25f4f1df0f39dc434ee43e56d480b399075230154d547abad466555f884077f1a1fff08590005645a762b3279
6
+ metadata.gz: c35ab575b4bac80ea1291802c1ee09260529eea8d348b51b22adcd582789f1a902e7f6c1350e3b538b16064dbcaeece6afb80623565e0757f2905f8ffe9ddfa3
7
+ data.tar.gz: 5a76b2d8f36eb02815674b1b0af00c8508e8f6dec4f978156e58c8587f01a846ce9bb7c3865887b7452ae2c5232fd10758cde62e800b4104410458234e7cf915
data/README.md CHANGED
@@ -4,10 +4,10 @@ This is micro kubernetes(tm) on Ruby(tm), a simple tool to deploy containers to
4
4
 
5
5
  It's also a frontend for `docker`, providing an easier way for your services to be locally available, without the need to care about local `ports` availability.
6
6
 
7
- It contains an internal DNS and uses HAProxy for routing/balancing/fail-over for Pods access.
7
+ It contains an internal DNS and uses HAProxy as ingress for Pod access.
8
8
  The database is a simple sqlite3 db and the server is a Sinatra based application.
9
9
 
10
- A client is also included to access the API, e.g. `mkitc ps`.
10
+ A client is also included to access the API, e.g. `mkit ps`.
11
11
 
12
12
  The daemon is responsible for HAProxy pods routing configuration. It also provides the cluster DNS and manages the internal host interface and the docker instances.
13
13
 
@@ -18,7 +18,7 @@ The daemon is responsible for HAProxy pods routing configuration. It also provid
18
18
  * Docker
19
19
  * Linux (iproute2 package)
20
20
 
21
- **Note:** in order to have **ssl support**, you must install `openssl-dev` package (e.g. `libssl-dev` on Ubuntu) prior to install MKIt gem.
21
+ **Note:** in order to have **ssl support**, you must install `openssl-dev` package (e.g. `libssl-dev` on Ubuntu) prior to install MKIt gem, due to `eventmachine` gem native extensions.
22
22
 
23
23
  ## Install
24
24
 
@@ -102,22 +102,22 @@ mkit:
102
102
 
103
103
  ### Client configuration
104
104
 
105
- On `mkitc` first call, default configuration will be copied to `$HOME/.mkit` with `local`default profile set.
105
+ On `mkit` first call, default configuration will be copied to `$HOME/.mkit` with `local`default profile set.
106
106
 
107
- You must call `mkitc init` to initialize client configuration.
107
+ You must call `mkit init` to initialize client configuration.
108
108
 
109
109
  Client identification key (`my_id`) will be generated, printed out to console and saved to the client's configuration file.
110
110
 
111
- You may edit the local configuration file to add more servers and change active profile with `$mkitc profile set <profile_name>`, e.g. `$mkitc profile set server_2`
111
+ You may edit the local configuration file to add more servers and change active profile with `$mkit profile set <profile_name>`, e.g. `$mkit profile set server_2`
112
112
 
113
113
  ```
114
114
  # ~/.mkit/mkitc_config.yml
115
115
  mkit:
116
116
  local:
117
117
  server.uri: https://localhost:4567
118
- server_2: # you can add more servers. change the client active profile with mkitc profile command
118
+ server_2: # you can add more servers. change the client active profile with mkit profile command
119
119
  server.uri: https://192.168.29.232:4567
120
- my_id: unique_id # this id is generated running mkitc init
120
+ my_id: unique_id # this id is generated running mkit init
121
121
  ```
122
122
 
123
123
  ### Service
@@ -174,10 +174,10 @@ There's also samples for [systemd](samples/systemd) and [daemontools](samples/da
174
174
 
175
175
  A client is provided to interact with MKIt server.
176
176
 
177
- Run `mkitc help` for a list of current supported commands.
177
+ Run `mkit help` for a list of current supported commands.
178
178
 
179
179
  ```
180
- Usage: mkitc <command> [options]
180
+ Usage: mkit <command> [options]
181
181
 
182
182
  Micro k8s on Ruby - a simple tool to mimic a (very) minimalistic k8 cluster
183
183
 
@@ -197,13 +197,13 @@ version prints mkit server version
197
197
  proxy haproxy status and control
198
198
  profile mkit client configuration profile
199
199
 
200
- Run 'mkitc help <command>' for specific command information.
200
+ Run 'mkit help <command>' for specific command information.
201
201
  ```
202
202
 
203
203
  Example:
204
204
 
205
205
  ```
206
- $ mkitc ps
206
+ $ mkit ps
207
207
  +----+-------+---------------+-------------------+--------------+---------+
208
208
  | id | name | addr | ports | pods | status |
209
209
  +----+-------+---------------+-------------------+--------------+---------+
@@ -214,7 +214,7 @@ $ mkitc ps
214
214
  The service `mongo` is available on IP `10.210.198.10:27017`
215
215
  The service `nexus` is available on IP `10.210.198.11:80` and on port `443` with ssl.
216
216
 
217
- **Note:** Don't forget to call `mkitc init` to initialize client configuration and to add the `client-id`
217
+ **Note:** Don't forget to call `mkit init` to initialize client configuration and to add the `client-id`
218
218
  to the server authorized clients list.
219
219
 
220
220
  ## Development
@@ -224,6 +224,13 @@ to the server authorized clients list.
224
224
  * console
225
225
  * `rake console`
226
226
 
227
+ # Contributing
228
+ * Fork it
229
+ * Create your feature branch (git checkout -b my-new-feature)
230
+ * Commit your changes (git commit -am 'Add some feature')
231
+ * Push to the branch (git push origin my-new-feature)
232
+ * Create new Pull Request
233
+
227
234
  # Thanks
228
235
 
229
236
  For my kids. :)
data/bin/{mkitc → mkit} RENAMED
@@ -203,7 +203,7 @@ class MKItClient
203
203
 
204
204
  @configuration = cfg['mkit'][current_profile.lstrip]
205
205
  if !init_call && cfg['my_id'].nil?
206
- raise InvalidParametersException.new("Please run 'mkitc init' to initialize mkit client.", find_command('init'))
206
+ raise InvalidParametersException.new("Please run ' mkit init' to initialize mkit client.", find_command('init'))
207
207
  end
208
208
  @my_id = cfg['my_id']
209
209
  cfg
@@ -360,16 +360,16 @@ class MKItClient
360
360
  my_cmd = cause.command
361
361
  end
362
362
  if my_cmd.nil?
363
- msg += "\nUsage: mkitc <command> [options]\n\n"
363
+ msg += "\nUsage: mkit <command> [options]\n\n"
364
364
  msg += "Micro k8s on Ruby - a simple tool to mimic a (very) minimalistic k8 cluster\n\n"
365
365
  msg += "Commands:\n\n"
366
366
  dict.each do |c|
367
367
  msg += format("%-10s %s\n", c[:cmd], c[:help])
368
368
  end
369
369
  msg += "\n"
370
- msg += "Run 'mkitc help <command>' for specific command information.\n\n"
370
+ msg += "Run ' mkit help <command>' for specific command information.\n\n"
371
371
  else
372
- msg += format("\nUsage: mkitc %s %s\n\n", my_cmd[:cmd], my_cmd[:usage].nil? ? '' : my_cmd[:usage].join(' '))
372
+ msg += format("\nUsage: mkit %s %s\n\n", my_cmd[:cmd], my_cmd[:usage].nil? ? '' : my_cmd[:usage].join(' '))
373
373
  msg += format("%s\n", my_cmd[:help])
374
374
  unless my_cmd[:options].nil?
375
375
  msg += "\nOptions:\n"
@@ -16,10 +16,9 @@ class Pod < ActiveRecord::Base
16
16
  new_ip = nil
17
17
  tries = 5
18
18
  while (new_ip.nil? && tries > 0) do
19
- instance = self.properties.to_o
20
- new_ip = instance.NetworkSettings.Networks[self.service.pods_network].IPAddress
21
- sleep(1) if new_ip.nil?
22
- tries = tries - 1
19
+ new_ip = self.instance.NetworkSettings.Networks[self.service.pods_network].IPAddress
20
+ sleep(1) if new_ip.nil?
21
+ tries = tries - 1
23
22
  end
24
23
  if self.ip != new_ip
25
24
  self.ip = new_ip
@@ -40,14 +39,8 @@ class Pod < ActiveRecord::Base
40
39
  self.dns_host.save
41
40
  end
42
41
 
43
- def properties
44
- inspect_instance(self.name)
45
- end
46
-
47
42
  def set_status_from_docker
48
- instance = self.properties
49
- if self.properties
50
- instance = instance.to_o
43
+ if self.instance
51
44
  if instance.State.Running
52
45
  self.status = MKIt::Status::RUNNING
53
46
  else
@@ -65,30 +58,31 @@ class Pod < ActiveRecord::Base
65
58
  end
66
59
 
67
60
  def start
68
- if self.pod_id.nil?
61
+ if self.instance.nil?
69
62
  docker_run = parse
70
63
  MKItLogger.info("deploying docker pod, cmd [#{docker_run}]")
71
64
  create_instance(docker_run)
72
65
  else
73
- pre_check
74
-
75
- instance = self.properties.to_o
76
66
  start_instance(self.name) unless instance.State.Running
77
67
  end
78
68
  end
79
69
 
80
70
  def stop
81
- pre_check
82
- stop_instance(self.name)
71
+ stop_instance(self.name) unless self.instance.nil? || !self.instance.State.Running
83
72
  end
84
73
 
85
- def pre_check
86
- raise MKIt::PodNotFoundException.new('no pod_name found') if self.name.nil?
87
- raise MKIt::PodNotFoundException.new("no properties found for #{self.name}") if self.properties.nil?
74
+ def instance
75
+ properties = inspect_instance(self.name)
76
+ return properties.to_o unless properties.nil?
77
+ nil
88
78
  end
89
79
 
90
80
  def clean_up
91
- remove_instance(self.name) unless self.pod_id.nil?
81
+ begin
82
+ remove_instance(self.name) unless self.instance.nil?
83
+ rescue => e
84
+ MKItLogger.warn(e)
85
+ end
92
86
  MkitJob.publish(topic: :pod_destroyed, service_id: self.service.id, data: {pod_id: self.id})
93
87
  end
94
88
  end
@@ -36,9 +36,9 @@ module MKIt
36
36
  pod.save
37
37
  pod.service.update_status!
38
38
  when :kill
39
- MKItLogger.debug(" #{type} #{action} <<NOOP / TODO>>")
39
+ pod.service.update_status!
40
40
  when :die
41
- MKItLogger.debug(" #{type} #{action} <<NOOP / TODO>>")
41
+ pod.service.update_status!
42
42
  when :stop
43
43
  pod.service.update_status!
44
44
  else
data/lib/mkit/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module MKIt
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.2"
3
3
  end
4
4
 
data/mkit ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH.unshift File.expand_path('lib')
5
+ #
6
+ ENV['SINATRA_ENV'] ||= "development"
7
+ ENV['RACK_ENV'] ||= "development"
8
+
9
+ load 'bin/mkit'
10
+
data/mkit.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|TODO|db/development.sqlite)}) }
21
21
  end
22
22
  s.executables << 'mkitd'
23
- s.executables << 'mkitc'
23
+ s.executables << 'mkit'
24
24
  s.add_runtime_dependency 'async-dns', '~> 1.3', '>= 1.3.0'
25
25
  s.add_runtime_dependency 'dry-container', '~> 0.9', '>= 0.9.0'
26
26
  s.add_runtime_dependency 'net_http_unix', '~> 0.2', '>= 0.2.2'
@@ -35,4 +35,5 @@ Gem::Specification.new do |s|
35
35
  s.add_runtime_dependency 'sqlite3', '~> 1.5', '>= 1.5.4'
36
36
  s.add_runtime_dependency 'standalone_migrations', '~> 7.1', '>= 7.1.0'
37
37
  s.add_runtime_dependency 'thin', '~> 1.8', '>= 1.8.1'
38
+ s.add_runtime_dependency 'text-table', '~> 1.2', '>= 1.2.4'
38
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasco Santos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-24 00:00:00.000000000 Z
11
+ date: 2024-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-dns
@@ -290,13 +290,33 @@ dependencies:
290
290
  - - ">="
291
291
  - !ruby/object:Gem::Version
292
292
  version: 1.8.1
293
+ - !ruby/object:Gem::Dependency
294
+ name: text-table
295
+ requirement: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - "~>"
298
+ - !ruby/object:Gem::Version
299
+ version: '1.2'
300
+ - - ">="
301
+ - !ruby/object:Gem::Version
302
+ version: 1.2.4
303
+ type: :runtime
304
+ prerelease: false
305
+ version_requirements: !ruby/object:Gem::Requirement
306
+ requirements:
307
+ - - "~>"
308
+ - !ruby/object:Gem::Version
309
+ version: '1.2'
310
+ - - ">="
311
+ - !ruby/object:Gem::Version
312
+ version: 1.2.4
293
313
  description: Micro k8s on Ruby - a simple tool to deploy containers to mimic a (very)
294
314
  minimalistic k8 cluster with a nice REST API
295
315
  email:
296
316
  - valexsantos@gmail.com
297
317
  executables:
298
318
  - mkitd
299
- - mkitc
319
+ - mkit
300
320
  extensions: []
301
321
  extra_rdoc_files: []
302
322
  files:
@@ -307,7 +327,7 @@ files:
307
327
  - LICENSE
308
328
  - README.md
309
329
  - Rakefile
310
- - bin/mkitc
330
+ - bin/mkit
311
331
  - bin/mkitd
312
332
  - config/database.yml
313
333
  - config/mkit_config.yml
@@ -366,6 +386,7 @@ files:
366
386
  - lib/mkit/workers/pod_worker.rb
367
387
  - lib/mkit/workers/service_worker.rb
368
388
  - lib/mkit/workers/worker_manager.rb
389
+ - mkit
369
390
  - mkit.gemspec
370
391
  - mkitd
371
392
  - samples/apps/kafka-cluster.yml