Merge pull request 'loki, prometheus, promtail should connect via wireguard' (#200) from loki-prometheus-via-wireguard into main

Reviewed-on: pub-solar/infra#200
Reviewed-by: Hendrik Sokolowski <hensoko@noreply.git.pub.solar>
Reviewed-by: b12f <b12f@noreply.git.pub.solar>
This commit is contained in:
teutat3s 2024-06-05 00:04:40 +00:00
commit 10ed117dfe
Signed by: pub.solar gitea
GPG key ID: F0332B04B7054873
11 changed files with 83 additions and 169 deletions

View file

@ -1,17 +0,0 @@
# Unlocking the root partition on boot
After a reboot, the encrypted ZFS pool will have to be unlocked. This is done by accessing the server via SSH with user `root` on port 2222.
Nachtigall:
```
ssh root@138.201.80.102 -p2222
```
Metronom:
```
ssh root@49.13.236.167 -p2222
```
After connecting, paste the crypt passphrase you can find in the shared keepass. This will disconnect the SSH session right away and the server will keep booting into stage 2.

View file

@ -0,0 +1,20 @@
# Unlocking the ZFS pool on boot
After a reboot, the encrypted ZFS pool will have to be unlocked. This is done by
accessing the server via SSH as user `root` on port 2222.
Nachtigall:
```
ssh root@nachtigall.pub.solar -p2222
```
Metronom:
```
ssh root@metronom.pub.solar -p2222
```
After connecting, paste the encryption passphrase you can find in the shared
keepass. This will disconnect the SSH session immediately and the server will
continue to boot into stage 2.

View file

@ -28,8 +28,14 @@
networking.firewall.interfaces.wg-ssh.allowedTCPPorts = [ 22 ]; networking.firewall.interfaces.wg-ssh.allowedTCPPorts = [ 22 ];
networking.hosts = { networking.hosts = {
"10.7.6.1" = [ "nachtigall.${config.pub-solar-os.networking.domain}" ]; "10.7.6.1" = [ "nachtigall.wg.${config.pub-solar-os.networking.domain}" ];
"10.7.6.2" = [ "flora-6.${config.pub-solar-os.networking.domain}" ]; "10.7.6.2" = [ "flora-6.wg.${config.pub-solar-os.networking.domain}" ];
"10.7.6.3" = [ "metronom.wg.${config.pub-solar-os.networking.domain}" ];
"10.7.6.4" = [ "tankstelle.wg.${config.pub-solar-os.networking.domain}" ];
"fd00:fae:fae:fae:fae:1::" = [ "nachtigall.wg.${config.pub-solar-os.networking.domain}" ];
"fd00:fae:fae:fae:fae:2::" = [ "flora-6.wg.${config.pub-solar-os.networking.domain}" ];
"fd00:fae:fae:fae:fae:3::" = [ "metronom.wg.${config.pub-solar-os.networking.domain}" ];
"fd00:fae:fae:fae:fae:4::" = [ "tankstelle.wg.${config.pub-solar-os.networking.domain}" ];
}; };
services.openssh = { services.openssh = {

View file

@ -6,19 +6,9 @@
... ...
}: }:
{ {
services.caddy.virtualHosts = { # Only expose loki port via wireguard interface
"flora-6.${config.pub-solar-os.networking.domain}" = { networking.firewall.interfaces.wg-ssh.allowedTCPPorts = [ 3100 ];
logFormat = lib.mkForce ''
output discard
'';
extraConfig = ''
basicauth * {
${config.pub-solar-os.authentication.robot.username} $2a$14$mmIAy/Ezm6YGohUtXa2mWeW6Bcw1MQXPhrRbz14jAD2iUu3oob/t.
}
reverse_proxy :${toString config.services.loki.configuration.server.http_listen_port}
'';
};
};
# source: https://gist.github.com/rickhull/895b0cb38fdd537c1078a858cf15d63e # source: https://gist.github.com/rickhull/895b0cb38fdd537c1078a858cf15d63e
# https://grafana.com/docs/loki/latest/configure/examples/#1-local-configuration-exampleyaml # https://grafana.com/docs/loki/latest/configure/examples/#1-local-configuration-exampleyaml
services.loki = { services.loki = {
@ -28,7 +18,8 @@
auth_enabled = false; auth_enabled = false;
common = { common = {
ring = { ring = {
instance_addr = "127.0.0.1"; instance_interface_names = [ "wg-ssh" ];
instance_enable_ipv6 = true;
kvstore = { kvstore = {
store = "inmemory"; store = "inmemory";
}; };
@ -81,7 +72,7 @@
}; };
clients = [ clients = [
{ {
url = "http://127.0.0.1:${toString config.services.loki.configuration.server.http_listen_port}/loki/api/v1/push"; url = "http://flora-6.wg.pub.solar:${toString config.services.loki.configuration.server.http_listen_port}/loki/api/v1/push";
} }
]; ];
scrape_configs = [ scrape_configs = [

View file

@ -14,16 +14,12 @@ let
synapseMetricsPort = "${toString listenerWithMetrics.port}"; synapseMetricsPort = "${toString listenerWithMetrics.port}";
in in
{ {
age.secrets.nachtigall-metrics-nginx-basic-auth = {
file = "${flake.self}/secrets/nachtigall-metrics-nginx-basic-auth.age";
mode = "600";
owner = "nginx";
};
services.nginx.virtualHosts = { services.nginx.virtualHosts = {
"nachtigall.${config.pub-solar-os.networking.domain}" = { "nachtigall.wg.${config.pub-solar-os.networking.domain}" = {
enableACME = true; listenAddresses = [
addSSL = true; "10.7.6.1"
basicAuthFile = "${config.age.secrets.nachtigall-metrics-nginx-basic-auth.path}"; "[fd00:fae:fae:fae:fae:1::]"
];
locations."/metrics" = { locations."/metrics" = {
proxyPass = "http://127.0.0.1:${toString (config.services.prometheus.exporters.node.port)}"; proxyPass = "http://127.0.0.1:${toString (config.services.prometheus.exporters.node.port)}";
}; };

View file

@ -6,11 +6,6 @@
... ...
}: }:
{ {
age.secrets.nachtigall-metrics-prometheus-basic-auth-password = {
file = "${flake.self}/secrets/nachtigall-metrics-prometheus-basic-auth-password.age";
mode = "600";
owner = "prometheus";
};
age.secrets.alertmanager-envfile = { age.secrets.alertmanager-envfile = {
file = "${flake.self}/secrets/alertmanager-envfile.age"; file = "${flake.self}/secrets/alertmanager-envfile.age";
mode = "600"; mode = "600";
@ -44,7 +39,7 @@
}; };
scrapeConfigs = [ scrapeConfigs = [
{ {
job_name = "node-exporter-http"; job_name = "node-exporter";
static_configs = [ static_configs = [
{ {
targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ]; targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" ];
@ -52,19 +47,8 @@
instance = "flora-6"; instance = "flora-6";
}; };
} }
];
}
{ {
job_name = "node-exporter-https"; targets = [ "nachtigall.wg.${config.pub-solar-os.networking.domain}" ];
scheme = "https";
metrics_path = "/metrics";
basic_auth = {
username = "hakkonaut";
password_file = "${config.age.secrets.nachtigall-metrics-prometheus-basic-auth-password.path}";
};
static_configs = [
{
targets = [ "nachtigall.${config.pub-solar-os.networking.domain}" ];
labels = { labels = {
instance = "nachtigall"; instance = "nachtigall";
}; };
@ -73,15 +57,10 @@
} }
{ {
job_name = "matrix-synapse"; job_name = "matrix-synapse";
scheme = "https";
metrics_path = "/_synapse/metrics"; metrics_path = "/_synapse/metrics";
basic_auth = {
username = "hakkonaut";
password_file = "${config.age.secrets.nachtigall-metrics-prometheus-basic-auth-password.path}";
};
static_configs = [ static_configs = [
{ {
targets = [ "nachtigall.${config.pub-solar-os.networking.domain}" ]; targets = [ "nachtigall.wg.${config.pub-solar-os.networking.domain}" ];
labels = { labels = {
instance = "nachtigall"; instance = "nachtigall";
}; };

View file

@ -6,12 +6,6 @@
... ...
}: }:
{ {
age.secrets.nachtigall-metrics-prometheus-basic-auth-password = {
file = "${flake.self}/secrets/nachtigall-metrics-prometheus-basic-auth-password.age";
mode = "600";
owner = "promtail";
};
services.promtail = { services.promtail = {
enable = true; enable = true;
configuration = { configuration = {
@ -24,11 +18,7 @@
}; };
clients = [ clients = [
{ {
url = "https://flora-6.${config.pub-solar-os.networking.domain}/loki/api/v1/push"; url = "http://flora-6.wg.pub.solar:${toString flake.self.nixosConfigurations.flora-6.config.services.loki.configuration.server.http_listen_port}/loki/api/v1/push";
basic_auth = {
username = "hakkonaut";
password_file = "${config.age.secrets.nachtigall-metrics-prometheus-basic-auth-password.path}";
};
} }
]; ];
scrape_configs = [ scrape_configs = [

View file

@ -1,43 +0,0 @@
age-encryption.org/v1
-> ssh-ed25519 iDKjwg iFrOyGN0zSpptFEy3mRmzFH/SpqvmQZRhMHaOvHggSc
HRTI1y0eUK0nAWO0Q/YVNYOyLU0OwY9KH0a3elGk1fs
-> ssh-ed25519 uYcDNw ojnoOpd7HElVjSlgSxrS53yz5ecb0ZZbZ4ZRa/C4vjc
YoBa3whKDyeOsdXFdzUJAIElTL/8o1blYlltNsvWCjs
-> ssh-rsa f5THog
j2mjjmsw8yj5gd6B6hHNiJrP2IICrupcaHcuPZHID5Bq9WbXcFlU9bsvLVtneBbD
YyGgpgUzejokeRT8EKieQSzcRCt99qVSO0cJWlvtVM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k
O9V5q98TG6UKFQJooUrVfX/Icab5UPYONvSH7mKa/pA
-> ssh-ed25519 +3V2lQ NxpGLFMboFSAztflSWw+NFjByFfkBL/IG4r/hFvMjkQ
0uWTKEG3TAsNsrPcooLsrINmDTWKlVIx1/OAL2rlcgc
--- VrkwgHMM0SXQKvH6I1oz35B391zF9QHysr3AZxGTpxw
M°°<>l0<6C>â!wÏú™Þ+ ­B¼<s¤à`ÚEÂ*_<>Û„ÂݘÒ1þÁó¥Jâ¡[¥?ì¾Î|»‹

View file

@ -70,9 +70,6 @@ in
"grafana-smtp-password.age".publicKeys = flora6Keys ++ adminKeys; "grafana-smtp-password.age".publicKeys = flora6Keys ++ adminKeys;
"alertmanager-envfile.age".publicKeys = flora6Keys ++ adminKeys; "alertmanager-envfile.age".publicKeys = flora6Keys ++ adminKeys;
"nachtigall-metrics-nginx-basic-auth.age".publicKeys = nachtigallKeys ++ adminKeys;
"nachtigall-metrics-prometheus-basic-auth-password.age".publicKeys =
flora6Keys ++ nachtigallKeys ++ adminKeys;
"obs-portal-env.age".publicKeys = nachtigallKeys ++ adminKeys; "obs-portal-env.age".publicKeys = nachtigallKeys ++ adminKeys;
"obs-portal-database-env.age".publicKeys = nachtigallKeys ++ adminKeys; "obs-portal-database-env.age".publicKeys = nachtigallKeys ++ adminKeys;

View file

@ -4,6 +4,46 @@ resource "namecheap_domain_records" "pub-solar" {
mode = "OVERWRITE" mode = "OVERWRITE"
email_type = "MX" email_type = "MX"
record {
hostname = "nachtigall.wg"
type = "A"
address = "10.7.6.1"
}
record {
hostname = "flora-6.wg"
type = "A"
address = "10.7.6.2"
}
record {
hostname = "metronom.wg"
type = "A"
address = "10.7.6.3"
}
record {
hostname = "tankstelle.wg"
type = "A"
address = "10.7.6.4"
}
record {
hostname = "nachtigall.wg"
type = "AAAA"
address = "fd00:fae:fae:fae:fae:1::"
}
record {
hostname = "flora-6.wg"
type = "AAAA"
address = "fd00:fae:fae:fae:fae:2::"
}
record {
hostname = "metronom.wg"
type = "AAAA"
address = "fd00:fae:fae:fae:fae:3::"
}
record {
hostname = "tankstelle.wg"
type = "AAAA"
address = "fd00:fae:fae:fae:fae:4::"
}
record { record {
hostname = "flora-6" hostname = "flora-6"
type = "A" type = "A"