kubernetes-health 2.0.2 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22eea741faba4096ddf070dc1135d466472913f5352db08a0e1a0e56e5199d21
4
- data.tar.gz: 651e2e4a0057eec8cc7bc582767015c34ff90d0cbaf6e35f8993be2639801fc7
3
+ metadata.gz: 8d1704a677ece777beeb57a3e9ad5f7db63afd78bbf00a58161aa3353aeb8a59
4
+ data.tar.gz: 73dc70adb7d1019e0b3c9c9fc0a4b2456feb655118f88216050f464a221c9003
5
5
  SHA512:
6
- metadata.gz: d30a41632feaf497f2a1f1e144c661642f5a4dae8db114a484bef3651ec90134c652c8b0bbb1ccf1b2c8d27be603d4c38962f9ee557816d4568f5b353bdd853c
7
- data.tar.gz: f1fa8dce9a80c68895050c66ce9be88cd6e412f1bbedf8352d7072c396763f2716d32ceead9bee742262cadbc3cf9780721bca89c47f31a1707253efc522ee07
6
+ metadata.gz: 8e534c0c28212798cc15a7311b4a6d0b7b6e04721c573abaf34442becaabea4d451a2ca80af3f7fcf1081305a500df48ae9360db3ea39e73e87a9d473754cc53
7
+ data.tar.gz: cb924de9d60c20f32d27d14c4e30a60e5992932e6a8c204be03fbfc1c0ec4c95f5af8827e45632ff12093532ab993c78d7b63a380994fac28ec094f974dcc2a7
data/README.md CHANGED
@@ -28,30 +28,25 @@ or add in your `application.rb`.
28
28
  Kubernetes::Health::Config.enable_rack_on_migrate = true
29
29
  ```
30
30
 
31
- If you need customize http rotating codes:
32
-
33
- ```
34
- # default: [200, 503]
35
- Kubernetes::Health::Config.rack_on_migrate_rotate_http_codes = [200, 503]
36
- ```
37
-
38
31
  In Kubernetes you need to configure your deployment `readinessProbe` like this:
39
32
 
40
33
  ```
34
+ livenessProbe:
35
+ httpGet:
36
+ path: /_liveness
37
+ port: 80
38
+ initialDelaySeconds: 10
39
+ timeoutSeconds: 5
41
40
  readinessProbe:
42
41
  httpGet:
43
42
  path: /_readiness
44
43
  port: 80
45
44
  initialDelaySeconds: 10
46
45
  timeoutSeconds: 5
47
- failureThreshold: 3
48
- successThreshold: 3
49
46
  ```
50
47
 
51
48
  ### How `rake db:migrate` monitoring works
52
- It will run a RACK server for `/_readiness` and `/_liveness` routes while a `rake db:migrate` runs and it will return `200` and `503` HTTP CODES alternately avoiding to reach `failureThreshold` or `successThreshold`.
53
-
54
- The `failureThreshold` and `successThreshold` values must to greater than `2` forcing kubernetes to wait.
49
+ It will run a RACK server for `/_readiness` and `/_liveness` routes while a `rake db:migrate` is running.
55
50
 
56
51
  ## Customizing checks
57
52
 
@@ -4,7 +4,6 @@ module Kubernetes
4
4
  @@live_if = lambda { true }
5
5
  @@ready_if = lambda { true }
6
6
  @@enable_rack_on_migrate = ActiveRecord::Type::Boolean.new.cast(ENV['KUBERNETES_HEALTH_ENABLE_RACK_ON_MIGRATE']) || false
7
- @@rack_on_migrate_rotate_http_codes = [503, 200]
8
7
  @@route_liveness = '/_liveness'
9
8
  @@route_readiness = '/_readiness'
10
9
 
@@ -16,14 +15,6 @@ module Kubernetes
16
15
  @@enable_rack_on_migrate = value
17
16
  end
18
17
 
19
- def self.rack_on_migrate_rotate_http_codes
20
- @@rack_on_migrate_rotate_http_codes
21
- end
22
-
23
- def self.rack_on_migrate_rotate_http_codes=(value)
24
- @@rack_on_migrate_rotate_http_codes = value
25
- end
26
-
27
18
  def self.route_liveness
28
19
  @@route_liveness
29
20
  end
@@ -2,16 +2,12 @@ namespace :kubernetes_health do
2
2
  task :before_migrate do
3
3
  Thread.new {
4
4
  require 'rack'
5
- @counter=0
6
5
  Rack::Handler.default.run ->(env) {
7
6
  req = Rack::Request.new(env)
8
- readiness = req.path_info == "#{Kubernetes::Health::Config.route_readiness}"
9
- liveness = req.path_info == "#{Kubernetes::Health::Config.route_liveness}"
10
- if readiness
11
- @counter=@counter+1
12
- http_codes = Kubernetes::Health::Config.rack_on_migrate_rotate_http_codes
13
- http_code = http_codes[(@counter % http_codes.size)]
14
- elsif liveness
7
+ case req.path_info
8
+ when Kubernetes::Health::Config.route_readiness
9
+ http_code = 503
10
+ when Kubernetes::Health::Config.route_liveness
15
11
  http_code = 200
16
12
  else
17
13
  http_code = 404
@@ -1,5 +1,5 @@
1
1
  module Kubernetes
2
2
  module Health
3
- VERSION = "2.0.2"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kubernetes-health
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wagner Caixeta