refactor: Convert configmaps containing secrets to secrets

closes #85
This commit is contained in:
Pim Kunis 2024-08-04 14:59:11 +02:00
parent 2c0a60097a
commit 5432d93f85
4 changed files with 35 additions and 13 deletions

View file

@ -40,10 +40,12 @@
generatedConfig = (pkgs.formats.toml { }).generate "attic.toml" atticSettings;
in
{
configMaps.config.data.config = builtins.readFile generatedConfig;
secrets = {
server.stringData.token = "ref+sops://secrets/kubernetes.yaml#attic/jwtToken";
server.stringData = {
token = "ref+sops://secrets/kubernetes.yaml#attic/jwtToken";
config = builtins.readFile generatedConfig;
};
database.stringData.password = "ref+sops://secrets/kubernetes.yaml#/attic/databasePassword";
};
@ -54,6 +56,15 @@
component = "website";
};
strategy = {
type = "RollingUpdate";
rollingUpdate = {
maxSurge = 0;
maxUnavailable = 1;
};
};
template = {
metadata.labels = {
app = "attic";
@ -86,7 +97,7 @@
volumes = {
data.persistentVolumeClaim.claimName = "data";
config.configMap.name = "config";
config.secret.secretName = "server";
};
securityContext = {

View file

@ -1,10 +1,6 @@
{ lib, myLib, ... }: {
kubernetes.resources = {
configMaps = {
config.data = {
config = lib.generators.toINI { } (import ./config.nix);
};
};
secrets.forgejo.stringData.config = lib.generators.toINI { } (import ./config.nix);
deployments.server.spec = {
selector.matchLabels.app = "forgejo";
@ -55,7 +51,7 @@
volumes = {
data.persistentVolumeClaim.claimName = "data";
config.configMap.name = "config";
config.secret.secretName = "forgejo";
};
};
};

View file

@ -7,6 +7,7 @@
secrets.hedgedoc.stringData = {
databaseURL = "ref+sops://secrets/kubernetes.yaml#/hedgedoc/databaseURL";
sessionSecret = "ref+sops://secrets/kubernetes.yaml#/hedgedoc/sessionSecret";
databasePassword = "ref+sops://secrets/kubernetes.yaml#/hedgedoc/databasePassword";
};
deployments = {
@ -94,8 +95,12 @@
env = {
POSTGRES_DB.value = "hedgedoc";
POSTGRES_USER.value = "hedgedoc";
POSTGRES_PASSWORD.value = "ref+sops://secrets/kubernetes.yaml#/hedgedoc/databasePassword";
PGDATA.value = "/pgdata/data";
POSTGRES_PASSWORD.valueFrom.secretKeyRef = {
name = "hedgedoc";
key = "databasePassword";
};
};
volumeMounts = [{

View file

@ -1,5 +1,7 @@
{ myLib, ... }: {
kubernetes.resources = {
secrets.immich.stringData.databasePassword = "ref+sops://secrets/kubernetes.yaml#/immich/databasePassword";
deployments = {
immich.spec = {
selector.matchLabels = {
@ -37,9 +39,13 @@
REDIS_HOSTNAME.value = "redis.immich.svc.cluster.local";
DB_HOSTNAME.value = "postgres.immich.svc.cluster.local";
DB_USERNAME.value = "postgres";
DB_PASSWORD.value = "ref+sops://secrets/kubernetes.yaml#/immich/databasePassword";
DB_DATABASE_NAME.value = "immich";
IMMICH_MACHINE_LEARNING_URL.value = "http://ml.immich.svc.cluster.local";
DB_PASSWORD.valueFrom.secretKeyRef = {
name = "immich";
key = "databasePassword";
};
};
volumeMounts = [{
@ -155,11 +161,15 @@
securityContext.runAsGroup = 999;
env = {
POSTGRES_PASSWORD.value = "ref+sops://secrets/kubernetes.yaml#/immich/databasePassword";
POSTGRES_USER.value = "postgres";
POSTGRES_DB.value = "immich";
POSTGRES_INITDB_ARGS.value = "--data-checksums";
PGDATA.value = "/pgdata/data";
POSTGRES_PASSWORD.valueFrom.secretKeyRef = {
name = "immich";
key = "databasePassword";
};
};
volumeMounts = [{