This commit is contained in:
2024-01-26 19:51:37 +01:00
parent 62c01ee414
commit 6a83465591
2 changed files with 219 additions and 144 deletions

View File

@@ -1,27 +1,74 @@
locals { locals {
annotations = { annotations = {
"vynil.solidite.fr/meta" = var.component "vynil.solidite.fr/meta" = var.component
"vynil.solidite.fr/name" = "${var.namespace}-auth" "vynil.solidite.fr/name" = var.namespace
"vynil.solidite.fr/domain" = var.domain_name }
"vynil.solidite.fr/issuer" = var.issuer annotations_default = {
"vynil.solidite.fr/ingress" = var.ingress_class "default.vynil.solidite.fr/sso_vynil" = var.sso_vynil
"default.vynil.solidite.fr/domain_name" = var.domain_name
"default.vynil.solidite.fr/timezone" = var.timezone
"default.vynil.solidite.fr/language" = var.language
"default.vynil.solidite.fr/domain" = var.domain
"default.vynil.solidite.fr/issuer" = var.issuer
"default.vynil.solidite.fr/ingress_class" = var.ingress_class
"default.vynil.solidite.fr/app_group" = var.app_group
"default.vynil.solidite.fr/backups.enable" = var.backups.enable
"default.vynil.solidite.fr/backups.use_barman" = var.backups.use_barman
"default.vynil.solidite.fr/backups.endpoint" = var.backups.endpoint
"default.vynil.solidite.fr/backups.secret_name" = var.backups.secret_name
"default.vynil.solidite.fr/backups.key_id_key" = var.backups.key_id_key
"default.vynil.solidite.fr/backups.secret_key" = var.backups.secret_key
"default.vynil.solidite.fr/backups.restic_key" = var.backups.restic_key
"default.vynil.solidite.fr/storage.volume.accessMode" = var.storage.volume.accessMode
"default.vynil.solidite.fr/storage.volume.class" = var.storage.volume.class
} }
global = { global = {
"domain" = var.namespace "sso_vynil" = var.sso_vynil
"domain_name" = var.domain_name "domain_name" = var.domain_name
"timezone" = var.timezone
"language" = var.language
"domain" = var.domain
"issuer" = var.issuer "issuer" = var.issuer
"ingress_class" = var.ingress_class "ingress_class" = var.ingress_class
"backups" = var.backups "app_group" = var.app_group
} }
authentik = { for k, v in var.authentik : k => v if k!="enable" } global-backups = {
authentik-ldap = { for k, v in var.authentik-ldap : k => v if k!="enable" } "enable" = var.backups.enable
authentik-forward = { for k, v in var.authentik-forward : k => v if k!="enable" } "use_barman" = var.backups.use_barman
"endpoint" = var.backups.endpoint
"secret_name" = var.backups.secret_name
"key_id_key" = var.backups.key_id_key
"secret_key" = var.backups.secret_key
"restic_key" = var.backups.restic_key
}
global-volume = {
"accessMode" = var.storage.volume.accessMode
"class" = var.storage.volume.class
}
authentik = merge(local.global,{ for k, v in var.authentik : k => v if !contains(["enable","storage","backups"],k) },{
backups = merge(lookup(var.authentik, "backups", {}), local.global-backups)
storage = merge({ for k, v in lookup(var.authentik, "storage", {}) : k => v if !contains(["volume"],k) }, {
volume = merge(lookup(lookup(var.authentik, "storage", {}), "volume", {}), local.global-volume)
})
})
authentik-ldap = merge(local.global,{ for k, v in var.authentik-ldap : k => v if !contains(["enable","storage","backups"],k) },{
backups = merge(lookup(var.authentik-ldap, "backups", {}), local.global-backups)
storage = merge({ for k, v in lookup(var.authentik-ldap, "storage", {}) : k => v if !contains(["volume"],k) }, {
volume = merge(lookup(lookup(var.authentik-ldap, "storage", {}), "volume", {}), local.global-volume)
})
})
authentik-forward = merge(local.global,{ for k, v in var.authentik-forward : k => v if !contains(["enable","storage","backups"],k) },{
backups = merge(lookup(var.authentik-forward, "backups", {}), local.global-backups)
storage = merge({ for k, v in lookup(var.authentik-forward, "storage", {}) : k => v if !contains(["volume"],k) }, {
volume = merge(lookup(lookup(var.authentik-forward, "storage", {}), "volume", {}), local.global-volume)
})
})
} }
resource "kubernetes_namespace_v1" "auth-ns" { resource "kubernetes_namespace_v1" "auth-ns" {
count = var.authentik.enable || var.authentik-ldap.enable || var.authentik-forward.enable ? 1 : 0 count = var.authentik.enable || var.authentik-ldap.enable || var.authentik-forward.enable ? 1 : 0
metadata { metadata {
annotations = local.annotations annotations = merge(local.annotations, local.annotations_default)
labels = merge(local.common-labels, local.annotations) labels = merge(local.common-labels, local.annotations)
name = "${var.namespace}-auth" name = "${var.namespace}-auth"
} }
@@ -41,7 +88,7 @@ resource "kubectl_manifest" "authentik" {
distrib: "${var.distributions.domain}" distrib: "${var.distributions.domain}"
category: "share" category: "share"
component: "authentik" component: "authentik"
options: ${jsonencode(merge(local.global, local.authentik))} options: ${jsonencode(local.authentik)}
EOF EOF
} }
@@ -59,7 +106,7 @@ resource "kubectl_manifest" "authentik-ldap" {
distrib: "${var.distributions.domain}" distrib: "${var.distributions.domain}"
category: "share" category: "share"
component: "authentik-ldap" component: "authentik-ldap"
options: ${jsonencode(merge(local.global, local.authentik-ldap))} options: ${jsonencode(local.authentik-ldap)}
EOF EOF
} }
@@ -77,6 +124,6 @@ resource "kubectl_manifest" "authentik-forward" {
distrib: "${var.distributions.domain}" distrib: "${var.distributions.domain}"
category: "share" category: "share"
component: "authentik-forward" component: "authentik-forward"
options: ${jsonencode(merge(local.global, local.authentik-forward))} options: ${jsonencode(local.authentik-forward)}
EOF EOF
} }

View File

@@ -6,6 +6,101 @@ metadata:
name: domain-auth name: domain-auth
description: null description: null
options: options:
fournisseurs:
default:
apps: []
divisions: []
enable: false
examples:
- apps: []
divisions: []
enable: false
properties:
apps:
default: []
items:
type: string
type: array
divisions:
default: []
items:
properties:
apps:
items:
type: string
type: array
name:
type: string
teams:
items:
type: object
type: array
type: object
type: array
enable:
default: false
type: boolean
type: object
app_group:
default: infra
examples:
- infra
type: string
sso_vynil:
default: true
examples:
- true
type: boolean
timezone:
default: Europe/Paris
examples:
- Europe/Paris
type: string
backups:
default:
enable: false
endpoint: ''
key_id_key: s3-id
restic_key: bck-password
secret_key: s3-secret
secret_name: backup-settings
use_barman: false
examples:
- enable: false
endpoint: ''
key_id_key: s3-id
restic_key: bck-password
secret_key: s3-secret
secret_name: backup-settings
use_barman: false
properties:
enable:
default: false
type: boolean
endpoint:
default: ''
type: string
key_id_key:
default: s3-id
type: string
restic_key:
default: bck-password
type: string
secret_key:
default: s3-secret
type: string
secret_name:
default: backup-settings
type: string
use_barman:
default: false
type: boolean
type: object
issuer:
default: letsencrypt-prod
examples:
- letsencrypt-prod
type: string
authentik: authentik:
default: default:
enable: true enable: true
@@ -16,106 +111,6 @@ options:
default: true default: true
type: boolean type: boolean
type: object type: object
distributions:
default:
core: core
domain: domain
examples:
- core: core
domain: domain
properties:
core:
default: core
type: string
domain:
default: domain
type: string
type: object
backups:
default:
enable: false
endpoint: ''
key-id-key: s3-id
secret-key: s3-secret
secret-name: backup-settings
examples:
- enable: false
endpoint: ''
key-id-key: s3-id
secret-key: s3-secret
secret-name: backup-settings
properties:
enable:
default: false
type: boolean
endpoint:
default: ''
type: string
key-id-key:
default: s3-id
type: string
secret-key:
default: s3-secret
type: string
secret-name:
default: backup-settings
type: string
type: object
ingress_class:
default: traefik
examples:
- traefik
type: string
domain_name:
default: your_company.com
examples:
- your_company.com
type: string
issuer:
default: letsencrypt-prod
examples:
- letsencrypt-prod
type: string
domain:
default: your-company
examples:
- your-company
type: string
storage-classes:
default:
BlockReadWriteMany: ''
BlockReadWriteOnce: ''
FilesystemReadWriteMany: ''
FilesystemReadWriteOnce: ''
examples:
- BlockReadWriteMany: ''
BlockReadWriteOnce: ''
FilesystemReadWriteMany: ''
FilesystemReadWriteOnce: ''
properties:
BlockReadWriteMany:
default: ''
type: string
BlockReadWriteOnce:
default: ''
type: string
FilesystemReadWriteMany:
default: ''
type: string
FilesystemReadWriteOnce:
default: ''
type: string
type: object
authentik-ldap:
default:
enable: false
examples:
- enable: false
properties:
enable:
default: false
type: boolean
type: object
authentik-forward: authentik-forward:
default: default:
enable: false enable: false
@@ -161,41 +156,21 @@ options:
default: true default: true
type: boolean type: boolean
type: object type: object
fournisseurs: authentik-ldap:
default: default:
apps: []
divisions: []
enable: false enable: false
examples: examples:
- apps: [] - enable: false
divisions: []
enable: false
properties: properties:
apps:
default: []
items:
type: string
type: array
divisions:
default: []
items:
properties:
apps:
items:
type: string
type: array
name:
type: string
teams:
items:
type: object
type: array
type: object
type: array
enable: enable:
default: false default: false
type: boolean type: boolean
type: object type: object
domain:
default: your-company
examples:
- your-company
type: string
clients: clients:
default: default:
apps: [] apps: []
@@ -231,6 +206,59 @@ options:
default: false default: false
type: boolean type: boolean
type: object type: object
domain_name:
default: your-company.com
examples:
- your-company.com
type: string
ingress_class:
default: traefik
examples:
- traefik
type: string
language:
default: fr_FR
examples:
- fr_FR
type: string
storage:
default:
volume:
accessMode: ReadWriteOnce
class: ''
examples:
- volume:
accessMode: ReadWriteOnce
class: ''
properties:
volume:
default:
accessMode: ReadWriteOnce
class: ''
properties:
accessMode:
default: ReadWriteOnce
type: string
class:
default: ''
type: string
type: object
type: object
distributions:
default:
core: core
domain: domain
examples:
- core: core
domain: domain
properties:
core:
default: core
type: string
domain:
default: domain
type: string
type: object
dependencies: [] dependencies: []
providers: providers:
kubernetes: true kubernetes: true