Remove init containers

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-07-06 12:20:45 +01:00
parent 48d3ba5092
commit 5c098a8aa9
19 changed files with 210 additions and 232 deletions

View File

@@ -159,38 +159,14 @@ in
};
containers = {
authelia-init = {
containerConfig = {
image = "docker-archive:${selfPkgs.docker-yq}";
volumes =
let
entrypoint = pkgs.writeTextFile {
name = "entrypoint.sh";
executable = true;
text = builtins.readFile ./init-entrypoint.sh;
};
in
[
"${volumes.authelia.ref}:/etc/authelia"
"${hmConfig.sops.templates.authelia-users.path}:/etc/authelia/users.yaml.default:ro"
"${hmConfig.sops.templates.authelia.path}:/etc/authelia/conf.d/authelia.yaml:ro"
"${entrypoint}:/entrypoint.sh:ro"
];
entrypoint = "/entrypoint.sh";
};
serviceConfig = {
Type = "oneshot";
Restart = "on-failure";
};
unitConfig.After = [ "sops-nix.service" ];
};
authelia = {
containerConfig = {
image = "docker-archive:${selfPkgs.docker-authelia}";
volumes = [ "${volumes.authelia.ref}:/etc/authelia" ];
volumes = [
"${volumes.authelia.ref}:/etc/authelia"
"${hmConfig.sops.templates.authelia-users.path}:/etc/authelia/users.yaml.default:ro"
"${hmConfig.sops.templates.authelia.path}:/etc/authelia/conf.d/authelia.yaml:ro"
];
networks = [
networks.authelia.ref
networks.traefik.ref
@@ -207,7 +183,6 @@ in
};
unitConfig.After = [
"${containers.authelia-init._serviceName}.service"
"${containers.authelia-postgresql._serviceName}.service"
"${containers.authelia-redis._serviceName}.service"
"sops-nix.service"
@@ -236,7 +211,7 @@ in
exec = [ "--save 60 1" ];
};
prometheus-init.containerConfig.volumes =
prometheus.containerConfig.volumes =
let
autheliaConfig = (pkgs.formats.yaml { }).generate "authelia.yaml" {
scrape_configs =

View File

@@ -1,10 +0,0 @@
#!/bin/sh
set -o errexit
set -o nounset
touch /etc/authelia/users.yaml
# shellcheck disable=SC2016
yq eval-all '. as $item ireduce ({}; . * $item)' /etc/authelia/users.yaml /etc/authelia/users.yaml.default -i
# shellcheck disable=SC2016
yq eval-all '. as $item ireduce ({}; . *+ $item)' /etc/authelia/conf.d/*.yaml > /etc/authelia/configuration.yaml

View File

@@ -258,7 +258,7 @@ in
unitConfig.After = [ "sops-nix.service" ];
};
authelia-init.containerConfig.volumes = [
authelia.containerConfig.volumes = [
"${hmConfig.sops.templates.authelia-gitea.path}:/etc/authelia/conf.d/gitea.yaml:ro"
];
};

View File

@@ -147,7 +147,7 @@ in
networks = [ networks.grafana.ref ];
};
authelia-init.containerConfig.volumes = [
authelia.containerConfig.volumes = [
"${hmConfig.sops.templates.authelia-grafana.path}:/etc/authelia/conf.d/grafana.yaml:ro"
];
};

View File

@@ -123,7 +123,7 @@ in
unitConfig.After = [ "sops-nix.service" ];
};
authelia-init.containerConfig.volumes = [
authelia.containerConfig.volumes = [
"${hmConfig.sops.templates.authelia-jellyfin.path}:/etc/authelia/conf.d/jellyfin.yaml:ro"
];
};

View File

@@ -222,7 +222,7 @@ in
unitConfig.After = [ "sops-nix.service" ];
};
authelia-init.containerConfig.volumes = [
authelia.containerConfig.volumes = [
"${hmConfig.sops.templates.authelia-nextcloud.path}:/etc/authelia/conf.d/nextcloud.yaml:ro"
];
};

View File

@@ -122,7 +122,7 @@ in
unitConfig.After = [ "sops-nix.service" ];
};
prometheus-init.containerConfig.volumes =
prometheus.containerConfig.volumes =
let
ntfyConfig = (pkgs.formats.yaml { }).generate "ntfy.yaml" {
scrape_configs =

View File

@@ -160,7 +160,7 @@ in
exec = [ "--save 60 1" ];
};
authelia-init.containerConfig.volumes = [
authelia.containerConfig.volumes = [
"${hmConfig.sops.templates.authelia-outline.path}:/etc/authelia/conf.d/outline.yaml:ro"
];
};

View File

@@ -80,7 +80,7 @@ in
home-manager.users.${user} =
let
inherit (hmConfig.virtualisation.quadlet) volumes containers networks;
inherit (hmConfig.virtualisation.quadlet) volumes networks;
in
{
virtualisation.quadlet = {
@@ -119,165 +119,140 @@ in
exec = [ "--collector.enable-all" ];
};
prometheus-init =
let
prometheusConfig = (pkgs.formats.yaml { }).generate "prometheus.yaml" {
global.scrape_interval = "15s";
prometheus.containerConfig = {
image = "docker-archive:${selfPkgs.docker-prometheus}";
volumes =
let
prometheusConfig = (pkgs.formats.yaml { }).generate "prometheus.yaml" {
global.scrape_interval = "15s";
scrape_configs =
let
hostname = config.networking.hostName;
jupiterVpsHostname = jupiterVpsConfig.networking.hostName;
in
[
{
job_name = "${hostname}-node-exporter";
static_configs = [
{
targets = [ "host.containers.internal:9100" ];
labels = {
app = "node-exporter";
user = "root";
inherit hostname;
};
}
{
targets = [ "prometheus-node-exporter:9100" ];
labels = {
app = "node-exporter";
inherit user hostname;
};
}
];
}
{
job_name = "${hostname}-podman-exporter";
static_configs = [
{
targets = [ "host.containers.internal:9882" ];
labels = {
app = "podman-exporter";
user = "root";
inherit hostname;
};
}
{
targets = [ "prometheus-podman-exporter:9882" ];
labels = {
app = "podman-exporter";
inherit user hostname;
};
}
];
}
{
job_name = "${hostname}-fail2ban-exporter";
static_configs = [
{
targets = [ "host.containers.internal:9191" ];
labels = {
app = "fail2ban-exporter";
user = "root";
inherit hostname;
};
}
];
}
{
job_name = "${hostname}-smartctl-exporter";
static_configs = [
{
targets = [ "host.containers.internal:9633" ];
labels = {
app = "smartctl-exporter";
user = "root";
inherit hostname;
};
}
];
}
{
job_name = "${jupiterVpsHostname}-node-exporter";
static_configs = [
{
targets = [ "10.0.0.1:9100" ];
labels = {
app = "node-exporter";
user = "root";
hostname = jupiterVpsHostname;
};
}
];
}
{
job_name = "${jupiterVpsHostname}-podman-exporter";
static_configs = [
{
targets = [ "10.0.0.1:9882" ];
labels = {
app = "podman-exporter";
user = "root";
hostname = jupiterVpsHostname;
};
}
];
}
{
job_name = "${jupiterVpsHostname}-fail2ban-exporter";
static_configs = [
{
targets = [ "10.0.0.1:9191" ];
labels = {
app = "fail2ban-exporter";
user = "root";
hostname = jupiterVpsHostname;
};
}
];
}
];
};
in
{
containerConfig = {
image = "docker-archive:${selfPkgs.docker-yq}";
volumes = [
"${volumes.prometheus-config.ref}:/etc/prometheus"
"${prometheusConfig}:/etc/prometheus/conf.d/prometheus.yaml"
];
entrypoint = "/bin/bash";
exec = [
"-c"
"yq eval-all '. as $item ireduce ({}; . *+ $item)' /etc/prometheus/conf.d/*.yaml > /etc/prometheus/prometheus.yaml"
];
};
serviceConfig = {
Type = "oneshot";
Restart = "on-failure";
};
};
prometheus = {
containerConfig = {
image = "docker-archive:${selfPkgs.docker-prometheus}";
volumes = [
scrape_configs =
let
hostname = config.networking.hostName;
jupiterVpsHostname = jupiterVpsConfig.networking.hostName;
in
[
{
job_name = "${hostname}-node-exporter";
static_configs = [
{
targets = [ "host.containers.internal:9100" ];
labels = {
app = "node-exporter";
user = "root";
inherit hostname;
};
}
{
targets = [ "prometheus-node-exporter:9100" ];
labels = {
app = "node-exporter";
inherit user hostname;
};
}
];
}
{
job_name = "${hostname}-podman-exporter";
static_configs = [
{
targets = [ "host.containers.internal:9882" ];
labels = {
app = "podman-exporter";
user = "root";
inherit hostname;
};
}
{
targets = [ "prometheus-podman-exporter:9882" ];
labels = {
app = "podman-exporter";
inherit user hostname;
};
}
];
}
{
job_name = "${hostname}-fail2ban-exporter";
static_configs = [
{
targets = [ "host.containers.internal:9191" ];
labels = {
app = "fail2ban-exporter";
user = "root";
inherit hostname;
};
}
];
}
{
job_name = "${hostname}-smartctl-exporter";
static_configs = [
{
targets = [ "host.containers.internal:9633" ];
labels = {
app = "smartctl-exporter";
user = "root";
inherit hostname;
};
}
];
}
{
job_name = "${jupiterVpsHostname}-node-exporter";
static_configs = [
{
targets = [ "10.0.0.1:9100" ];
labels = {
app = "node-exporter";
user = "root";
hostname = jupiterVpsHostname;
};
}
];
}
{
job_name = "${jupiterVpsHostname}-podman-exporter";
static_configs = [
{
targets = [ "10.0.0.1:9882" ];
labels = {
app = "podman-exporter";
user = "root";
hostname = jupiterVpsHostname;
};
}
];
}
{
job_name = "${jupiterVpsHostname}-fail2ban-exporter";
static_configs = [
{
targets = [ "10.0.0.1:9191" ];
labels = {
app = "fail2ban-exporter";
user = "root";
hostname = jupiterVpsHostname;
};
}
];
}
];
};
in
[
"${prometheusConfig}:/etc/prometheus/conf.d/prometheus.yaml"
"${volumes.prometheus-config.ref}:/etc/prometheus"
"${volumes.prometheus-data.ref}:/var/lib/prometheus"
];
networks = [
networks.prometheus.ref
networks.grafana.ref
];
exec = [
"--log.level=warn"
"--config.file=/etc/prometheus/prometheus.yaml"
"--storage.tsdb.path=/var/lib/prometheus"
"--storage.tsdb.retention.time=1y"
];
};
unitConfig.After = [ "${containers.prometheus-init._serviceName}.service" ];
networks = [
networks.prometheus.ref
networks.grafana.ref
];
exec = [
"--log.level=warn"
"--storage.tsdb.retention.time=1y"
];
};
grafana.containerConfig.volumes =

View File

@@ -122,7 +122,7 @@ in
unitConfig.After = [ "sops-nix.service" ];
};
authelia-init.containerConfig.volumes =
authelia.containerConfig.volumes =
let
config = (pkgs.formats.yaml { }).generate "shlink.yaml" {
access_control.rules = [

View File

@@ -133,7 +133,7 @@ in
};
};
authelia-init.containerConfig.volumes =
authelia.containerConfig.volumes =
let
config = (pkgs.formats.yaml { }).generate "traefik.yaml" {
access_control.rules = [
@@ -147,7 +147,7 @@ in
in
[ "${config}:/etc/authelia/conf.d/traefik.yaml:ro" ];
prometheus-init.containerConfig.volumes =
prometheus.containerConfig.volumes =
let
traefikConfig = (pkgs.formats.yaml { }).generate "traefik.yaml" {
scrape_configs =

View File

@@ -63,7 +63,7 @@ in
unitConfig.After = [ "sops-nix.service" ];
};
authelia-init.containerConfig.volumes =
authelia.containerConfig.volumes =
let
config = (pkgs.formats.yaml { }).generate "transmission.yaml" {
access_control.rules = [

View File

@@ -144,7 +144,7 @@ in
unitConfig.After = [ "sops-nix.service" ];
};
authelia-init.containerConfig.volumes = [
authelia.containerConfig.volumes = [
"${hmConfig.sops.templates.authelia-vaultwarden.path}:/etc/authelia/conf.d/vaultwarden.yaml:ro"
];
};