kubernetes-health 3.12.0 → 3.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/lib/kubernetes/health/version.rb +1 -1
- data/lib/puma/kubernetes/app.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: 3f1527d74312ef1d4c77095b8ee8c87f65dee6308e6340a697cee5bcedfe40f2
|
4
|
+
data.tar.gz: 1671089c58d3f7ba73e015a830e2622b324216a21ef25e9a7dc86d1b21527aa5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4b6ad22f24f40d719ab62cf1b14d45c9e4030d899a0370e774d5deface1ebfebfe13feea5047b4c12de09cdf3b4421f05f58165bd086dbc8755f941755c3459
|
7
|
+
data.tar.gz: e35f96cbfc2a13a5c49ce2d6e98d1e9c51bdb660e81ce3990d0481a2d7e3a7793dcf349579b1994555d255e22d7f0d63b54f08194bec8d518f662090a26924f1
|
data/README.md
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# Kubernetes::Health
|
2
|
-
This gem
|
2
|
+
This gem opens a dedicated HTTP port to allow Kubernetes to monitor your Rails app while it is running migrations, Rake tasks, Sidekiq, or Puma.
|
3
3
|
|
4
4
|
# Features
|
5
5
|
- Puma and Sidekiq metrics for autoscaling.
|
6
|
-
- Prometheus and JSON metrics
|
6
|
+
- Prometheus and JSON metrics.
|
7
7
|
- add routes `/_readiness`, `/_liveness` on Rails Stack.
|
8
8
|
- add routes `/_readiness`, `/_liveness` and `/_metrics` as a puma plugin at another port to avoid problems when your app get busy. (code copied from `puma-metrics` gem).
|
9
9
|
- add routes `/_readiness` and `/_liveness` while `rake db:migrate` runs. (optional)
|
10
|
-
- add routes `/
|
10
|
+
- add routes `/_metrics` while `sidekiq` runs. (optional)
|
11
11
|
- add support to avoid parallel running of `rake db:migrate` while keep kubernetes waiting (PostgreSQL required).
|
12
12
|
- allow custom checks for `/_readiness` and `/_liveness`.
|
13
13
|
|
@@ -80,7 +80,7 @@ Rake::Task['assets:precompile'].enhance(['kubernetes_health:rack_on_rake'])
|
|
80
80
|
Rake::Task['assets:clobber'].enhance(['kubernetes_health:rack_on_rake'])
|
81
81
|
```
|
82
82
|
|
83
|
-
I do
|
83
|
+
I do recommend doing some checks to make it only enabled in the K8S environment.
|
84
84
|
The defined port at `config/puma.rb` will be used but can be overrided by `KUBERNETES_HEALTH_METRICS_PORT` env var.
|
85
85
|
|
86
86
|
## Enabling liveness/readiness routes for `sidekiq`
|
@@ -96,11 +96,11 @@ Kubernetes::Health::Config.enable_rack_on_sidekiq = true
|
|
96
96
|
The defined port at `config/puma.rb` will be used but can be overrided by `KUBERNETES_HEALTH_METRICS_PORT` env var.
|
97
97
|
|
98
98
|
### How `rake` and `sidekiq` monitoring works
|
99
|
-
It will run a
|
99
|
+
It will run a rack server for `/_readiness`, `/_liveness` and `/_metrics` for rake and `/_metrics` for Sidekiq.
|
100
100
|
The liveness route will respond using `200` but readiness `503`.
|
101
101
|
|
102
102
|
## Avoiding migrations running in parallel and making kubernetes happy.
|
103
|
-
Rails already avoid migrations running in parallel, but it
|
103
|
+
Rails already avoid migrations running in parallel, but it raises exceptions. This gem will just wait for other migrations without exit.
|
104
104
|
If you enable `rack_on_migrate` together with this, kubernetes will just wait, avoiding erros.
|
105
105
|
|
106
106
|
|
data/lib/puma/kubernetes/app.rb
CHANGED
@@ -22,7 +22,7 @@ module Puma
|
|
22
22
|
case req.path_info
|
23
23
|
when ::Kubernetes::Health::Config.route_liveness
|
24
24
|
i_am_live = ::Kubernetes::Health::Config.live_if.arity.zero? ? ::Kubernetes::Health::Config.live_if.call : ::Kubernetes::Health::Config.live_if.call(req.params)
|
25
|
-
http_code =
|
25
|
+
http_code = i_am_live ? 200 : 503
|
26
26
|
when ::Kubernetes::Health::Config.route_readiness
|
27
27
|
i_am_ready = ::Kubernetes::Health::Config.ready_if.arity.zero? ? ::Kubernetes::Health::Config.ready_if.call : ::Kubernetes::Health::Config.ready_if.call(req.params)
|
28
28
|
http_code = puma_already_started?(extended_puma_stats) && i_am_ready ? 200 : 503
|