mkit 0.6.1 → 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: 0dab845891b079ffbf0f696676c1c3b6e25e583c02a09570582571976f8ce40d
4
- data.tar.gz: 59e3174e0e09347c2e40a7f7096cfd3c9f9575a588d210c0d7dd71ccfcadf206
3
+ metadata.gz: 49770b23e6d2af3c26a6b8e32291ad24b60e56f6e6fee0f308e3c96fd54f9591
4
+ data.tar.gz: 2fe4f45739fd054f2399f4d1544b0d2bd736a5cc656ffad79da24a97b24e489d
5
5
  SHA512:
6
- metadata.gz: a447023289277ea09120233ec72cb3b5a2de96077ee012b30fd369e21c338b487a898217d367dba7b8a86499a940944dee60ecdecbced737c00b70358e3141f4
7
- data.tar.gz: b33b3276ad887b3939d2898b2d09c0a8a807a62856b761969f50e675c2e01fcd2f48abc1a49259dea60e4d12df563b0b73d4d4852880bb0e4abf2e539714074f
6
+ metadata.gz: c35ab575b4bac80ea1291802c1ee09260529eea8d348b51b22adcd582789f1a902e7f6c1350e3b538b16064dbcaeece6afb80623565e0757f2905f8ffe9ddfa3
7
+ data.tar.gz: 5a76b2d8f36eb02815674b1b0af00c8508e8f6dec4f978156e58c8587f01a846ce9bb7c3865887b7452ae2c5232fd10758cde62e800b4104410458234e7cf915
data/README.md CHANGED
@@ -7,7 +7,7 @@ It's also a frontend for `docker`, providing an easier way for your services to
7
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
 
@@ -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.1"
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'
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.1
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-27 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
@@ -316,7 +316,7 @@ email:
316
316
  - valexsantos@gmail.com
317
317
  executables:
318
318
  - mkitd
319
- - mkitc
319
+ - mkit
320
320
  extensions: []
321
321
  extra_rdoc_files: []
322
322
  files:
@@ -327,7 +327,7 @@ files:
327
327
  - LICENSE
328
328
  - README.md
329
329
  - Rakefile
330
- - bin/mkitc
330
+ - bin/mkit
331
331
  - bin/mkitd
332
332
  - config/database.yml
333
333
  - config/mkit_config.yml
@@ -386,6 +386,7 @@ files:
386
386
  - lib/mkit/workers/pod_worker.rb
387
387
  - lib/mkit/workers/service_worker.rb
388
388
  - lib/mkit/workers/worker_manager.rb
389
+ - mkit
389
390
  - mkit.gemspec
390
391
  - mkitd
391
392
  - samples/apps/kafka-cluster.yml