@yunuseon/kayra 0.22.1 → 0.22.2
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.
- package/ansible/playbooks/platform.yml +2 -0
- package/ansible/roles/monitor/tasks/main.yml +2 -1
- package/ansible/roles/monitor/templates/docker-compose.yml.j2 +19 -0
- package/compose/authelia/configuration.yml +5 -0
- package/hosts.conf +3 -0
- package/package.json +1 -1
- package/scripts/local/monitor-endpoints.sh +4 -2
- package/scripts/local/verify.sh +9 -3
- package/terraform/modules/platform-dns/main.tf +7 -2
- package/terraform/modules/platform-dns/tests/fleet/servers/watching/server.yml +6 -0
- package/terraform/modules/platform-dns/tests/fleet/servers/watching/vars.yml +2 -0
- package/terraform/modules/platform-dns/tests/platform-dns.tftest.hcl +15 -0
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
# monitor_endpoints and monitor_hosts) plus monitor.extra, and alerting through
|
|
6
6
|
# the notifier's ntfy after three failures, again once it has recovered.
|
|
7
7
|
# Watched names are pinned to their servers' addresses (extra_hosts), so home
|
|
8
|
-
# names resolve through the tunnel from the edge as they do at home.
|
|
8
|
+
# names resolve through the tunnel from the edge as they do at home. On a
|
|
9
|
+
# platform server (monitor_page) its page is status.<domain>, behind the login.
|
|
9
10
|
# =============================================================================
|
|
10
11
|
|
|
11
12
|
- name: Check the monitor has a notifier and its tokens
|
|
@@ -9,9 +9,28 @@ services:
|
|
|
9
9
|
volumes:
|
|
10
10
|
- ./config:/config:ro
|
|
11
11
|
mem_limit: 128m
|
|
12
|
+
{% if monitor_page | default(false) %}
|
|
13
|
+
# status.<domain>, for staff only: Traefik reaches it on platform-internal.
|
|
14
|
+
networks: [default, platform-internal]
|
|
15
|
+
labels:
|
|
16
|
+
- "traefik.enable=true"
|
|
17
|
+
- "traefik.docker.network=platform-internal"
|
|
18
|
+
- "traefik.http.routers.status.rule=Host(`status.{{ domain }}`)"
|
|
19
|
+
- "traefik.http.routers.status.entrypoints=websecure"
|
|
20
|
+
- "traefik.http.routers.status.tls.certresolver=le"
|
|
21
|
+
- "traefik.http.routers.status.middlewares=authelia@file"
|
|
22
|
+
- "traefik.http.services.status.loadbalancer.server.port=8080"
|
|
23
|
+
{% endif %}
|
|
12
24
|
{% if monitor_hosts | length > 0 %}
|
|
13
25
|
extra_hosts:
|
|
14
26
|
{% for host, address in monitor_hosts | dictsort %}
|
|
15
27
|
- "{{ host }}:{{ address }}"
|
|
16
28
|
{% endfor %}
|
|
17
29
|
{% endif %}
|
|
30
|
+
{% if monitor_page | default(false) %}
|
|
31
|
+
|
|
32
|
+
networks:
|
|
33
|
+
platform-internal:
|
|
34
|
+
name: platform-internal
|
|
35
|
+
external: true
|
|
36
|
+
{% endif %}
|
|
@@ -94,6 +94,11 @@ access_control:
|
|
|
94
94
|
policy: '{{ env "AUTH_POLICY" }}'
|
|
95
95
|
subject:
|
|
96
96
|
- 'group:admin'
|
|
97
|
+
# The monitor's page, where the server runs one.
|
|
98
|
+
- domain: 'status.{{ env "DOMAIN" }}'
|
|
99
|
+
policy: '{{ env "AUTH_POLICY" }}'
|
|
100
|
+
subject:
|
|
101
|
+
- 'group:admin'
|
|
97
102
|
|
|
98
103
|
session:
|
|
99
104
|
name: 'authelia_session'
|
package/hosts.conf
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# Platform subdomains to add to /etc/hosts and to the mkcert SAN list.
|
|
2
2
|
# App subdomains live in each app's app.yml; apps may not claim these.
|
|
3
3
|
# One subdomain per line. Read by scripts/local/setup-hosts.sh and scripts/local/certs.sh.
|
|
4
|
+
# status is routed only where the server runs a monitor (monitor in vars.yml);
|
|
5
|
+
# verify and the monitors expect it only there.
|
|
4
6
|
deploy
|
|
5
7
|
auth
|
|
6
8
|
traefik
|
|
9
|
+
status
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yunuseon/kayra",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.2",
|
|
4
4
|
"description": "A self-hosted app platform and the CLI that runs it: Traefik, Authelia, a registry, rootless BuildKit and a small deployer per server, set up with OpenTofu and Ansible.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Yunus Öztürk",
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
# monitor-endpoints.sh <server> — what the server's monitor (Gatus, the
|
|
4
4
|
# monitor role) checks, from the same sources as verify.sh: for each server in
|
|
5
5
|
# its vars.yml's monitor.watch,
|
|
6
|
-
# platform: auth.<domain> answers; the platform's pages (hosts.conf
|
|
7
|
-
# browser to the login; every app route answers, not 5xx;
|
|
6
|
+
# platform: auth.<domain> answers; the platform's pages (hosts.conf, status
|
|
7
|
+
# where it runs a monitor) send a browser to the login; every app route answers, not 5xx;
|
|
8
8
|
# deploy.<domain>/health is 200 (monitor_health_tokens.<server>)
|
|
9
9
|
# edge: every edge_routes name answers, not 5xx
|
|
10
10
|
# nas: nothing of its own: its stacks are monitor.extra
|
|
@@ -50,7 +50,9 @@ watched() {
|
|
|
50
50
|
case "$kind" in
|
|
51
51
|
platform)
|
|
52
52
|
endpoint "auth.${domain}" "$server" "https://auth.${domain}/" false false '[STATUS] == 200' "$cert"
|
|
53
|
+
monitored="$( [ -f "${dir}/vars.yml" ] && yq -r '.monitor != null' "${dir}/vars.yml" || echo false)"
|
|
53
54
|
awk '!/^[[:space:]]*(#|$)/ {print $1}' "${KAYRA_ROOT}/hosts.conf" | while IFS= read -r sub; do
|
|
55
|
+
[ "$sub" != status ] || [ "$monitored" = true ] || continue
|
|
54
56
|
[ "$sub" = auth ] || endpoint "${sub}.${domain}" "$server" "https://${sub}.${domain}/" false false '[STATUS] == 302' "$cert"
|
|
55
57
|
done
|
|
56
58
|
endpoint "deploy.${domain}/health" "$server" "https://deploy.${domain}/health" false true '[STATUS] == 200'
|
package/scripts/local/verify.sh
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
#
|
|
6
6
|
# From here, the way the world reaches it (each name pinned to the server's
|
|
7
7
|
# address, so neither DNS nor /etc/hosts has to be in place yet):
|
|
8
|
-
# - auth.<domain> answers; the platform's own pages (hosts.conf
|
|
9
|
-
# browser to the login, not a 403 from rules
|
|
8
|
+
# - auth.<domain> answers; the platform's own pages (hosts.conf; status only
|
|
9
|
+
# where a monitor runs) send a browser to the login, not a 403 from rules
|
|
10
|
+
# Authelia never loaded
|
|
10
11
|
# - every certificate is a real one (Let's Encrypt or mkcert), never
|
|
11
12
|
# Traefik's default
|
|
12
13
|
# - an unsigned webhook is refused (with webhooks: false, /hook is not
|
|
@@ -87,8 +88,13 @@ check() {
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
check "auth.${domain} answers" "auth.${domain}" GET answers
|
|
91
|
+
monitored="$( [ -f "${dir}/vars.yml" ] && yq -r '.monitor != null' "${dir}/vars.yml" || echo false)"
|
|
90
92
|
while IFS= read -r sub; do
|
|
91
|
-
|
|
93
|
+
case "$sub" in
|
|
94
|
+
auth) ;;
|
|
95
|
+
status) [ "$monitored" != true ] || check "${sub}.${domain} sends a browser to the login" "${sub}.${domain}" GET to_login ;;
|
|
96
|
+
*) check "${sub}.${domain} sends a browser to the login" "${sub}.${domain}" GET to_login ;;
|
|
97
|
+
esac
|
|
92
98
|
done < <(awk '!/^[[:space:]]*(#|$)/ {print $1}' "${KAYRA_ROOT}/hosts.conf")
|
|
93
99
|
|
|
94
100
|
first_app="$(head -1 <<< "$registered_wanted")"
|
|
@@ -28,9 +28,14 @@ locals {
|
|
|
28
28
|
}
|
|
29
29
|
uncloned = [for name, manifest in local.manifests : name if !fileexists(manifest)]
|
|
30
30
|
|
|
31
|
+
# status only where the server runs a monitor, which serves it.
|
|
32
|
+
vars_file = "${var.fleet_root}/servers/${var.server}/vars.yml"
|
|
33
|
+
monitored = fileexists(local.vars_file) ? try(yamldecode(file(local.vars_file)).monitor, null) != null : false
|
|
31
34
|
platform_subdomains = [
|
|
32
|
-
for
|
|
33
|
-
|
|
35
|
+
for sub in [
|
|
36
|
+
for line in split("\n", file("${path.module}/../../../hosts.conf")) :
|
|
37
|
+
split(" ", trimspace(line))[0] if trimspace(line) != "" && !startswith(trimspace(line), "#")
|
|
38
|
+
] : sub if sub != "status" || local.monitored
|
|
34
39
|
]
|
|
35
40
|
app_subdomains = flatten([
|
|
36
41
|
for name, manifest in local.manifests :
|
|
@@ -62,3 +62,18 @@ run "app_not_cloned" {
|
|
|
62
62
|
|
|
63
63
|
expect_failures = [hcloud_zone_rrset.a]
|
|
64
64
|
}
|
|
65
|
+
|
|
66
|
+
# A server running a monitor serves its page, status.<domain>, too.
|
|
67
|
+
run "monitor_page" {
|
|
68
|
+
command = plan
|
|
69
|
+
|
|
70
|
+
variables {
|
|
71
|
+
server = "watching"
|
|
72
|
+
zone = "example.com"
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
assert {
|
|
76
|
+
condition = contains(output.hosts, "status.example.com")
|
|
77
|
+
error_message = "status should be a host where the server runs a monitor"
|
|
78
|
+
}
|
|
79
|
+
}
|