Migrate attic database to kubernetes
This commit is contained in:
parent
93f0aa7fde
commit
964f76af14
4 changed files with 122 additions and 49 deletions
|
@ -1,8 +1,8 @@
|
|||
{ pkgs, ... }: {
|
||||
kubernetes.resources =
|
||||
let
|
||||
atticdSettings = {
|
||||
database.url = "ref+sops://secrets/sops.yaml#atticd/databaseURL";
|
||||
atticSettings = {
|
||||
database.url = "ref+sops://secrets/sops.yaml#attic/databaseURL";
|
||||
|
||||
storage = {
|
||||
type = "local";
|
||||
|
@ -34,74 +34,146 @@
|
|||
max-size = 256 * 1024; # 256 KiB
|
||||
};
|
||||
};
|
||||
generatedConfig = (pkgs.formats.toml { }).generate "atticd.toml" atticdSettings;
|
||||
generatedConfig = (pkgs.formats.toml { }).generate "attic.toml" atticSettings;
|
||||
in
|
||||
{
|
||||
configMaps = {
|
||||
atticd-env.data.ATTIC_SERVER_TOKEN_HS256_SECRET_BASE64 = "ref+sops://secrets/sops.yaml#atticd/jwtToken";
|
||||
atticd-config.data.config = builtins.readFile generatedConfig;
|
||||
attic-env.data.ATTIC_SERVER_TOKEN_HS256_SECRET_BASE64 = "ref+sops://secrets/sops.yaml#attic/jwtToken";
|
||||
attic-config.data.config = builtins.readFile generatedConfig;
|
||||
|
||||
attic-db-env.data = {
|
||||
POSTGRES_DB = "attic";
|
||||
POSTGRES_USER = "attic";
|
||||
POSTGRES_PASSWORD = "ref+sops://secrets/sops.yaml#/attic/databasePassword";
|
||||
PGDATA = "/pgdata/data";
|
||||
};
|
||||
};
|
||||
|
||||
deployments.atticd = {
|
||||
metadata.labels.app = "atticd";
|
||||
deployments = {
|
||||
attic = {
|
||||
metadata.labels = {
|
||||
app = "attic";
|
||||
component = "website";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels.app = "atticd";
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "attic";
|
||||
component = "website";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels.app = "atticd";
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "attic";
|
||||
component = "website";
|
||||
};
|
||||
|
||||
spec = {
|
||||
containers.atticd = {
|
||||
image = "git.kun.is/home/atticd:fd910d91c2143295e959d2c903e9ea25cf94ba27";
|
||||
envFrom = [{ configMapRef.name = "atticd-env"; }];
|
||||
ports.web.containerPort = 8080;
|
||||
args = [ "-f" "/etc/atticd/config.toml" ];
|
||||
spec = {
|
||||
containers.attic = {
|
||||
image = "git.kun.is/home/atticd:fd910d91c2143295e959d2c903e9ea25cf94ba27";
|
||||
envFrom = [{ configMapRef.name = "attic-env"; }];
|
||||
ports.web.containerPort = 8080;
|
||||
args = [ "-f" "/etc/atticd/config.toml" ];
|
||||
|
||||
volumeMounts = [
|
||||
{
|
||||
volumeMounts = [
|
||||
{
|
||||
name = "data";
|
||||
mountPath = "/var/lib/atticd/storage";
|
||||
}
|
||||
{
|
||||
name = "config";
|
||||
mountPath = "/etc/atticd/config.toml";
|
||||
subPath = "config";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
volumes = {
|
||||
data.persistentVolumeClaim.claimName = "attic";
|
||||
config.configMap.name = "attic-config";
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 0;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
attic-db = {
|
||||
metadata.labels = {
|
||||
app = "attic";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
spec = {
|
||||
selector.matchLabels = {
|
||||
app = "attic";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
template = {
|
||||
metadata.labels = {
|
||||
app = "attic";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
spec = {
|
||||
containers.postgres = {
|
||||
image = "postgres:15";
|
||||
imagePullPolicy = "IfNotPresent";
|
||||
ports.postgres.containerPort = 5432;
|
||||
envFrom = [{ configMapRef.name = "attic-db-env"; }];
|
||||
|
||||
volumeMounts = [{
|
||||
name = "data";
|
||||
mountPath = "/var/lib/atticd/storage";
|
||||
}
|
||||
{
|
||||
name = "config";
|
||||
mountPath = "/etc/atticd/config.toml";
|
||||
subPath = "config";
|
||||
}
|
||||
];
|
||||
};
|
||||
mountPath = "/pgdata";
|
||||
}];
|
||||
};
|
||||
|
||||
volumes = {
|
||||
data.persistentVolumeClaim.claimName = "attic";
|
||||
config.configMap.name = "atticd-config";
|
||||
};
|
||||
|
||||
securityContext = {
|
||||
fsGroup = 0;
|
||||
fsGroupChangePolicy = "OnRootMismatch";
|
||||
volumes.data.persistentVolumeClaim.claimName = "attic-db";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.atticd.spec = {
|
||||
selector.app = "atticd";
|
||||
services = {
|
||||
attic.spec = {
|
||||
selector = {
|
||||
app = "attic";
|
||||
component = "website";
|
||||
};
|
||||
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
ports.web = {
|
||||
port = 80;
|
||||
targetPort = "web";
|
||||
};
|
||||
};
|
||||
|
||||
attic-db.spec = {
|
||||
selector = {
|
||||
app = "attic";
|
||||
component = "database";
|
||||
};
|
||||
|
||||
ports.postgres = {
|
||||
port = 5432;
|
||||
targetPort = "postgres";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
lab = {
|
||||
ingresses.atticd = {
|
||||
ingresses.attic = {
|
||||
host = "attic.kun.is";
|
||||
entrypoint = "localsecure";
|
||||
|
||||
service = {
|
||||
name = "atticd";
|
||||
name = "attic";
|
||||
portName = "web";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
sonarr.storage = "150Mi";
|
||||
bazarr.storage = "25Mi";
|
||||
attic.storage = "15Gi";
|
||||
attic-db.storage = "150Mi";
|
||||
};
|
||||
|
||||
nfsVolumes = {
|
||||
|
|
Reference in a new issue