portainer management
This commit is contained in:
1 parent
cbba7075a7
commit
a33f1284dc
13 files changed
+182
-46
No files matched your search
@@ -1 +1 @@
|
||||
0D0C7C270FF7DD6600BBC42B9282088EC96C8C08
|
||||
0D0C7C270FF7DD6600BBC42B9282088EC96C8C09
|
||||
@@ -0,0 +1,26 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEXzCCAkegAwIBAgIUDQx8Jw/33WYAu8QrkoIIjslsjAkwDQYJKoZIhvcNAQEL
|
||||
BQAwFjEUMBIGA1UEAwwLU2t5ZyBMYWIgQ0EwHhcNMjYwOTIyMTg1NzQyWhcNMjgx
|
||||
MjI1MTg1NzQyWjAhMR8wHQYDVQQDDBZwb3J0YWluZXIuYXBwLmludGVybmFsMIIB
|
||||
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqpePKTVYh0XfTxa9/UQmVRut
|
||||
oSUCYJdsBD7V1FfkiLDdUef9shoISyQ/JUR8KDLiyrCeImq71sIa2V8+CuZ5lgUx
|
||||
7+tKzq+1nRQpXDpj1mSbqTVjjOD/BCBCN4XVfNNKdCmc4bi/pPOPD52ZtkZvlk98
|
||||
/j/SkWkqMoKMi82fq0s5NDEf4AogwhxhCDDM9bnK/3tNCSAtnHzYEj3hYHEX7s9m
|
||||
MKvjZ30CofqJvzD0pcx3HzJXqDNj4EKmdn7fTS7IGzVEHtcydI7F8G71+BY+recs
|
||||
y84KxSzOK8YBjcOdJh01QemMRigefmrcMNamHXnxh1MnuLQL87QAgabbcBacCwID
|
||||
AQABo4GZMIGWMAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgWgMBMGA1UdJQQM
|
||||
MAoGCCsGAQUFBwMBMCEGA1UdEQQaMBiCFnBvcnRhaW5lci5hcHAuaW50ZXJuYWww
|
||||
HQYDVR0OBBYEFF2IEkWyZktX5uJAHtdfzPCV161dMB8GA1UdIwQYMBaAFMr8tqeF
|
||||
YL21we0UJHQv8wK6JEOCMA0GCSqGSIb3DQEBCwUAA4ICAQA69Tlj+bHUBQAhHfBW
|
||||
0ApKj7cnWIzhSd6cbLpE9UDSLL/Lj5PZh5CXlnocyXhE3BZGqJkehTUOvYHtIory
|
||||
HkjmDq822ob9tm844J5GYNxxxBPvgZgLr6eiW4R/0fdwZmshXejaEq3uG94Z0eWO
|
||||
MASRWRZDH4CsckY5f2VEzOnCI8hFZWtd/IUnYVU0IsWHmdzajJgR9SBpapEEQoAv
|
||||
LwQ7/Yac0m2sp59lde0nX9uHhqb8gFBYwtHY1A9niPA8pR+pRwjhtWuAOPSKKWwJ
|
||||
D6+ILOu+p5tZLQo3H2Sl0OFSpOs4p794vcpxk32jsWmGs3vR0efdxjPGBvYp9joT
|
||||
9CrzuWnjyKor/lG3I3SCPKX/nFFpTrzw7URzEUIvERiZa7WgCjehPKmChhcdvd7f
|
||||
RzEKwWbtrdDKsZSxOcfZ5vPfo/ejNkINovmXCPhL/10dyEbtjBwAImQBUg6DD8yC
|
||||
6cKb4A+zmNNcnAHSDeqfg3rWWUHd/K7nblg7mU/pg490GuhhTkRflbwSF3HlAxJq
|
||||
k/00QH9H+CS/RT3aNnoG1H6f5H8+7FEqgTXmVuNHBuTVL1IRGRiyJooCIv4P2C8E
|
||||
EoJTG+bUrUPbVlZI5MlCYnM2WU33Sz9NIg0XAWibXsIZzih7L6zP2R0X9f9yt8PL
|
||||
HkNyNXVHJkFgB6ipfii2fll36g==
|
||||
-----END CERTIFICATE-----
|
||||
+4
-19
@@ -35,27 +35,12 @@
|
||||
networkDrives.enable = true;
|
||||
};
|
||||
|
||||
# Portainer Agent
|
||||
# Portainer Edge Agent
|
||||
age.secrets.portainer-agent-bigbox1.file = ../secrets/portainer-agent-bigbox1.age;
|
||||
skyg.nixos.common.container-services.portainer-agent = {
|
||||
skyg.nixos.server.portainer = {
|
||||
enable = true;
|
||||
autoUpdate.enable = true;
|
||||
services.agent = {
|
||||
image = "portainer/agent:2.45.0";
|
||||
volumes = [
|
||||
"/var/run/docker.sock:/var/run/docker.sock"
|
||||
"/var/lib/docker/volumes:/var/lib/docker/volumes"
|
||||
"portainer_agent_data:/data"
|
||||
];
|
||||
environmentFiles = [ config.age.secrets.portainer-agent-bigbox1.path ];
|
||||
environment = {
|
||||
EDGE_INSECURE_POLL = "1";
|
||||
EDGE = "1";
|
||||
};
|
||||
};
|
||||
volumes.portainer_agent_data = {
|
||||
name = "portainer_data";
|
||||
};
|
||||
mode = "agent";
|
||||
agent.edgeKeySecretName = "portainer-agent-bigbox1";
|
||||
};
|
||||
|
||||
# Jellyfin container service group
|
||||
|
||||
@@ -455,6 +455,14 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
# Portainer Edge Agent
|
||||
age.secrets.portainer-agent-minipc1.file = ../secrets/portainer-agent-minipc1.age;
|
||||
skyg.nixos.server.portainer = {
|
||||
enable = true;
|
||||
mode = "agent";
|
||||
agent.edgeKeySecretName = "portainer-agent-minipc1";
|
||||
};
|
||||
|
||||
# Buzz management CLI.
|
||||
environment.systemPackages = [ buzz-manage ];
|
||||
|
||||
|
||||
+8
-20
@@ -75,28 +75,16 @@ in
|
||||
networks.lan = config.skyg.nixos.common.containers.networks.ipvlanLab.compose;
|
||||
};
|
||||
|
||||
# Portainer Service
|
||||
skyg.nixos.common.container-services.portainer = {
|
||||
# Portainer Server
|
||||
age.secrets.portainer-tls-key.file = ../secrets/portainer-tls-key.age;
|
||||
skyg.nixos.server.portainer = {
|
||||
enable = true;
|
||||
autoUpdate.enable = true;
|
||||
services.portainer = {
|
||||
image = "portainer/portainer-ce:lts";
|
||||
volumes = [
|
||||
"/var/run/docker.sock:/var/run/docker.sock"
|
||||
"portainer_data:/data"
|
||||
];
|
||||
ports = [
|
||||
"9443:9443"
|
||||
"8000:8000"
|
||||
];
|
||||
# networks = staticIp "10.0.101.5";
|
||||
mode = "server";
|
||||
server.tls = {
|
||||
enable = true;
|
||||
cert = builtins.readFile ../configs/pki/portainer.app.internal.crt;
|
||||
keySecretName = "portainer-tls-key";
|
||||
};
|
||||
volumes = {
|
||||
portainer_data = {
|
||||
name = "portainer_data";
|
||||
};
|
||||
};
|
||||
# networks = macvlanNetwork;
|
||||
};
|
||||
|
||||
age.secrets.stack1.file = ../secrets/stack1.age;
|
||||
|
||||
@@ -48,12 +48,6 @@ in
|
||||
enableGnomeKeyring = true;
|
||||
fprintAuth = true;
|
||||
u2fAuth = true;
|
||||
text = lib.mkDefault ''
|
||||
auth include login
|
||||
account include login
|
||||
password include login
|
||||
session include login
|
||||
'';
|
||||
};
|
||||
security.pam.services.login.enableGnomeKeyring = true;
|
||||
security.polkit.enable = true;
|
||||
|
||||
@@ -17,6 +17,7 @@ server/
|
||||
├── dns/ # Local DNS resolver, certbot, local CA
|
||||
├── k3s/ # Single-binary K3s cluster role
|
||||
├── k8s/ # Full upstream Kubernetes (master/node)
|
||||
├── portainer.nix # skyg.nixos.server.portainer — Portainer server or Edge agent
|
||||
└── services/ # Self-hosted apps (jellyfin, audiobookshelf, comfyui, ds4, colibri, ai…)
|
||||
```
|
||||
|
||||
@@ -43,6 +44,7 @@ skyg.server.dns.* → dns/
|
||||
skyg.nixos.server.k3s.* → k3s/
|
||||
skyg.nixos.server.k8s.* → k8s/
|
||||
skyg.nixos.server.services.* → services/
|
||||
skyg.nixos.server.portainer.* → portainer.nix
|
||||
```
|
||||
|
||||
## Conventions
|
||||
|
||||
@@ -10,5 +10,6 @@
|
||||
./services
|
||||
./timers.nix
|
||||
./dns
|
||||
./portainer.nix
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.skyg.nixos.server.portainer;
|
||||
in
|
||||
{
|
||||
options.skyg.nixos.server.portainer = {
|
||||
enable = mkEnableOption "Portainer container management UI";
|
||||
|
||||
mode = mkOption {
|
||||
type = types.enum [ "server" "agent" ];
|
||||
default = "agent";
|
||||
description = ''
|
||||
Whether to run the Portainer server (management UI) or an Edge agent.
|
||||
'';
|
||||
};
|
||||
|
||||
server = {
|
||||
ip = mkOption {
|
||||
type = types.str;
|
||||
default = "10.0.101.241";
|
||||
description = "Static IP on the ipvlan lab network for the server container.";
|
||||
};
|
||||
|
||||
dnsName = mkOption {
|
||||
type = types.str;
|
||||
default = "portainer";
|
||||
description = ''
|
||||
Internal DNS name for the server. The app.internal suffix is added
|
||||
automatically by the DNS module.
|
||||
'';
|
||||
};
|
||||
|
||||
tls = {
|
||||
enable = mkEnableOption "TLS with a lab CA certificate for the Portainer server";
|
||||
|
||||
cert = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
Content of the TLS certificate in PEM format. Set to the output of
|
||||
builtins.readFile on the lab CA leaf cert committed in configs/pki/.
|
||||
Run `skyg ca issue <domain> --for <host>` first to create it.
|
||||
Example: builtins.readFile ../../configs/pki/portainer.app.internal.crt
|
||||
'';
|
||||
};
|
||||
|
||||
keySecretName = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
Name of the age secret containing the TLS private key.
|
||||
Created by `skyg ca issue <domain> --for <host>`.
|
||||
The corresponding age.secrets.<name>.file must be declared
|
||||
in the host file.
|
||||
Example: "portainer-tls-key"
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
agent = {
|
||||
edgeKeySecretName = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
Name of the age secret (without the secrets/ prefix or .age suffix)
|
||||
containing the EDGE_KEY for this agent. The corresponding
|
||||
age.secrets.<name>.file must be declared in the host file.
|
||||
Example: "portainer-agent-minipc1"
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
skyg.nixos.common.container-services.portainer =
|
||||
if cfg.mode == "server"
|
||||
then {
|
||||
enable = true;
|
||||
autoUpdate.enable = true;
|
||||
services.portainer = {
|
||||
image = "portainer/portainer-ce:lts";
|
||||
volumes =
|
||||
[ "/var/run/docker.sock:/var/run/docker.sock" "portainer_data:/data" ]
|
||||
++ lib.optional (cfg.server.tls.enable && cfg.server.tls.keySecretName != null)
|
||||
"${config.age.secrets.${cfg.server.tls.keySecretName}.path}:/certs/key.pem:ro";
|
||||
networks.lan.ipv4_address = cfg.server.ip;
|
||||
dns.names = [ cfg.server.dnsName ];
|
||||
}
|
||||
// lib.optionalAttrs cfg.server.tls.enable {
|
||||
files."/certs/cert.pem" = cfg.server.tls.cert;
|
||||
environment = {
|
||||
PORTAINER_HTTP_ENABLED = "true";
|
||||
PORTAINER_SSL = "true";
|
||||
PORTAINER_SSLCERT = "/certs/cert.pem";
|
||||
PORTAINER_SSLKEY = "/certs/key.pem";
|
||||
PORTAINER_TUNNEL_PORT = "8000";
|
||||
};
|
||||
};
|
||||
volumes.portainer_data = {
|
||||
name = "portainer_data";
|
||||
};
|
||||
networks.lan = config.skyg.nixos.common.containers.networks.ipvlanLab.compose;
|
||||
}
|
||||
else {
|
||||
enable = true;
|
||||
autoUpdate.enable = true;
|
||||
services.agent = {
|
||||
image = "portainer/agent:2.45.0";
|
||||
volumes = [
|
||||
"/var/run/docker.sock:/var/run/docker.sock"
|
||||
"/var/lib/docker/volumes:/var/lib/docker/volumes"
|
||||
"portainer_agent_data:/data"
|
||||
];
|
||||
environmentFiles = lib.optional (cfg.agent.edgeKeySecretName != null)
|
||||
config.age.secrets.${cfg.agent.edgeKeySecretName}.path;
|
||||
environment = {
|
||||
EDGE_INSECURE_POLL = "1";
|
||||
EDGE = "1";
|
||||
};
|
||||
};
|
||||
volumes.portainer_agent_data = {
|
||||
name = "portainer_data";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -37,6 +37,8 @@ in
|
||||
|
||||
# portainer agent envs
|
||||
"secrets/portainer-agent-bigbox1.age".publicKeys = [ ari bigbox1 ];
|
||||
"secrets/portainer-agent-minipc1.age".publicKeys = [ ari minipc1 ];
|
||||
"secrets/lab-ca-key.age".publicKeys = [ ari ];
|
||||
"secrets/buzz-tls-key.age".publicKeys = [ ari minipc1 ];
|
||||
"secrets/portainer-tls-key.age".publicKeys = [ ari minipc2 ];
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user