Compare commits

...

8 Commits

Author SHA1 Message Date
bb7f309b34
v0.1.3
All checks were successful
Gitea Actions Demo / lint (push) Successful in 22s
Gitea Actions Demo / test (push) Successful in 14s
Gitea Actions Demo / docker (push) Successful in 2m8s
2025-04-02 21:07:52 -05:00
9b2d2f9522
enable Kubernetes HPA in Helm chart 2025-04-02 21:06:11 -05:00
a30c6d7cb8
reorder routes 2025-04-02 21:01:45 -05:00
20c34f3c76
move uptime route to root, /uptime 2025-04-02 21:01:18 -05:00
dc9b8b7cc7
move /livez control routes under /api 2025-04-02 21:00:16 -05:00
149b42825f
log kubernaut version number that is compatible with Puma 2025-04-02 20:59:10 -05:00
2285def168
s/sleep/sleepy/g 2025-04-02 20:58:20 -05:00
a83fa30cd4
quiet logger for /livez and /readyz 2025-04-02 20:57:13 -05:00
4 changed files with 22 additions and 20 deletions

34
app.rb
View File

@ -2,6 +2,7 @@ require "bundler/setup"
require "sinatra"
require "sinatra/cookies"
require "sinatra/multi_route"
require "sinatra/quiet_logger"
require "time"
require "fileutils"
require "json"
@ -20,7 +21,7 @@ $LOAD_PATH.unshift File.dirname(__FILE__) + "/lib"
require "config"
VERSION = "0.1.2"
VERSION = "0.1.3"
CHUNK_SIZE = 1024**2
SESSION_SECRET_HEX_LENGTH = 64
@ -52,9 +53,12 @@ DURATION_PARTS = [
config = Config.new
set :quiet_logger_prefixes, %w[livez readyz]
set :session_secret, config.session_secret.unwrap
set :public_folder, __dir__ + "/static"
register Sinatra::QuietLogger
module Sinatra
module RequestHeadersHelper
def req_headers
@ -164,7 +168,7 @@ class Sleep
include State
def initialize
@file = "/dev/shm/sleep"
@file = "/dev/shm/sleepy"
end
def asleep?
@ -232,9 +236,7 @@ end
enable :sessions
on_start do
puts "#{NAME} #{VERSION} staring, per aspera ad astra"
end
puts "#{NAME} #{VERSION} staring, per aspera ad astra"
configure do
mime_type :json, "application/json"
@ -309,31 +311,31 @@ get "/headers", provides: "json" do
jsonify h, pretty:
end
get "/livez" do
error 503 unless Health.instance.healthy?
return Health.instance.to_json if request.env["HTTP_ACCEPT"] == "application/json"
Health.instance.to_s
end
get "/livez/uptime" do
get "/uptime", provides: "json" do
tt = TickTock.new
x = {started_at: tt.started_at, seconds: tt.uptime.to_i, human: human_time(tt.uptime.to_i)}
jsonify x
end
post "/livez/toggle" do
post "/api/livez/toggle" do
Health.instance.toggle
"ok\n"
end
post "/livez/sleep" do
post "/api/livez/sleep" do
Sleep.instance.toggle
"ok\n"
end
get "/livez" do
error 503 unless Health.instance.healthy?
return Health.instance.to_json if request.env["HTTP_ACCEPT"] == "application/json"
Health.instance.to_s
end
get "/readyz" do
error 503 unless Ready.instance.ready?

View File

@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.2
version: 0.1.3
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.1.2"
appVersion: "0.1.3"

View File

@ -97,7 +97,7 @@ readinessProbe:
# This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/
autoscaling:
enabled: false
enabled: true
minReplicas: 2
maxReplicas: 100
targetCPUUtilizationPercentage: 80

View File

@ -16,7 +16,7 @@ spec:
spec:
containers:
- name: kubernaut
image: git.kill0.net/ryanc/kubernaut:0.1.2
image: git.kill0.net/ryanc/kubernaut:0.1.3
imagePullPolicy: Always
ports:
- name: sinatra-web