kubernetes-health 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -12
- data/lib/kubernetes/health/config.rb +0 -9
- data/lib/kubernetes/health/rack_on_migrate.rake +4 -8
- data/lib/kubernetes/health/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d1704a677ece777beeb57a3e9ad5f7db63afd78bbf00a58161aa3353aeb8a59
|
4
|
+
data.tar.gz: 73dc70adb7d1019e0b3c9c9fc0a4b2456feb655118f88216050f464a221c9003
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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`
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|