feat(mail): enhance mail configuration with getmail and dovecot settings

- Added getmail configuration generation using template files.
- Introduced postfix and dovecot configuration checksums for deployment.
- Created new dovecot configuration file and sieve script for email handling.
- Updated main.tf to utilize local variables for configuration management.
- Removed redundant external password hasher from main.tf.

feat(nginx): improve nginx configuration management

- Centralized nginx configuration into a local variable with checksum.
- Created separate config maps for default website configurations.
- Updated deployment to utilize new configuration structure.

feat(sftpgo): add SFTPGo application deployment

- Introduced SFTPGo with Kubernetes resources including namespace, config maps, and secrets.
- Configured SFTPGo with SMTP settings and AWS credentials.
- Implemented health checks and volume mounts for persistent storage.

refactor(seafile): remove Seafile module

- Deleted Seafile module and associated resources as part of cleanup.
This commit is contained in:
2025-05-05 00:47:36 +02:00
parent 6adbd50c6d
commit e6e85b00f7
60 changed files with 1107 additions and 604 deletions
+81
View File
@@ -0,0 +1,81 @@
locals {
data_path = "${var.persistent_folder}/sftpgo"
sftpgo_config = {
"common" : {
"defender" : {
"enabled" : false
}
},
"sftpd" : {
"bindings" : [
{
"port" : 0
}
]
},
"webdavd" : {
"bindings" : [
{
"port" : 8081,
"address" : "0.0.0.0"
}
]
},
"data_provider" : {
"create_default_admin" : true,
"backups_path" : "/var/lib/sftpgo/backup"
},
"httpd" : {
"bindings" : [
{
"port" : 8080,
"address" : "0.0.0.0",
"branding" : {
"web_client" : {
"name" : "alexpires.me cloud",
"short_name" : "alexpires.me"
},
"web_admin" : {
"name" : "alexpires.me cloud",
"short_name" : "alexpires.me"
}
}
}
],
"web_root" : "/storage",
},
"telemetry" : {
"bind_port" : 10000,
"bind_address" : "0.0.0.0"
},
"mfa" : {
"totp" : [
{
"name" : "Default",
"issuer" : "alexpires.me",
"algo" : "sha1"
}
]
},
"smtp" : {
"host" : var.smtp_host,
"port" : var.smtp_port,
"from" : var.from_email
"encryption" : 1,
"domain" : "alexpires.me"
},
"plugins" : []
}
config = jsonencode(local.sftpgo_config)
config_checksum = sha256(local.config)
credentials = templatefile("${path.module}/resources/aws.tpl", {
access_key = var.access_key
secret_key = var.secret_key
})
credentials_checksum = sha256(local.credentials)
}
+233
View File
@@ -0,0 +1,233 @@
resource "kubernetes_namespace" "sftpgo" {
metadata {
name = "sftpgo"
}
}
resource "kubernetes_config_map" "sftpgo" {
metadata {
name = "sftpgo"
namespace = kubernetes_namespace.sftpgo.metadata[0].name
}
data = {
"sftpgo.json" = local.config
}
}
resource "kubernetes_secret" "admin_credentials" {
metadata {
name = "admin-credentials"
namespace = kubernetes_namespace.sftpgo.metadata[0].name
}
data = {
admin_username = var.admin_username
admin_password = var.admin_password
smtp_username = var.smtp_username
smtp_password = var.smtp_password
}
type = "Opaque"
}
resource "kubernetes_config_map" "object_store_credentials" {
metadata {
name = "nextcloud-object-store-credentials"
namespace = kubernetes_namespace.sftpgo.metadata[0].name
}
data = {
"credentials" = local.credentials
}
}
resource "kubernetes_service_account" "sftpgo" {
metadata {
name = "sftpgo-app-sa"
namespace = kubernetes_namespace.sftpgo.metadata[0].name
}
automount_service_account_token = false
}
resource "kubernetes_deployment" "sftpgo" {
metadata {
name = "sftpgo"
namespace = kubernetes_namespace.sftpgo.metadata[0].name
}
spec {
replicas = 1
selector {
match_labels = {
app = "sftpgo"
}
}
strategy {
type = "RollingUpdate"
}
template {
metadata {
labels = {
app = "sftpgo"
}
annotations = {
"checksum/config" = local.config_checksum
"checksum/credentials" = local.credentials_checksum
}
}
spec {
service_account_name = kubernetes_service_account.sftpgo.metadata[0].name
automount_service_account_token = false
security_context {
fs_group = 1000
run_as_user = 1000
}
container {
name = "sftpgo"
image = "ghcr.io/drakkan/sftpgo:${var.tag}"
image_pull_policy = "Always"
args = ["sftpgo", "serve"]
env {
name = "SFTPGO_SMTP__USER"
value_from {
secret_key_ref {
name = kubernetes_secret.admin_credentials.metadata[0].name
key = "smtp_username"
}
}
}
env {
name = "SFTPGO_SMTP__PASSWORD"
value_from {
secret_key_ref {
name = kubernetes_secret.admin_credentials.metadata[0].name
key = "smtp_password"
}
}
}
env {
name = "SFTPGO_DEFAULT_ADMIN_USERNAME"
value_from {
secret_key_ref {
name = kubernetes_secret.admin_credentials.metadata[0].name
key = "admin_username"
}
}
}
env {
name = "SFTPGO_DEFAULT_ADMIN_PASSWORD"
value_from {
secret_key_ref {
name = kubernetes_secret.admin_credentials.metadata[0].name
key = "admin_password"
}
}
}
port {
container_port = 8081
name = "webdav"
protocol = "TCP"
}
port {
container_port = 8080
name = "http"
protocol = "TCP"
}
port {
container_port = 10000
name = "telemetry"
protocol = "TCP"
}
liveness_probe {
http_get {
path = "/healthz"
port = "telemetry"
}
}
readiness_probe {
http_get {
path = "/healthz"
port = "telemetry"
}
}
volume_mount {
mount_path = "/etc/sftpgo/sftpgo.json"
name = "config"
sub_path = "sftpgo.json"
read_only = true
}
volume_mount {
mount_path = "/var/lib/sftpgo"
name = "data"
}
volume_mount {
mount_path = "/var/lib/sftpgo/backup"
name = "backup"
}
volume_mount {
mount_path = "/var/lib/sftpgo/.aws/credentials"
name = "object-store-credentials"
sub_path = "credentials"
read_only = true
}
}
volume {
name = "config"
config_map {
name = kubernetes_config_map.sftpgo.metadata[0].name
}
}
volume {
name = "data"
host_path {
path = local.data_path
}
}
volume {
name = "backup"
host_path {
path = var.backup_folder
}
}
volume {
name = "object-store-credentials"
config_map {
name = kubernetes_config_map.object_store_credentials.metadata[0].name
}
}
}
}
}
}
resource "kubernetes_service" "sftpgo_webdav" {
metadata {
name = "webdav"
namespace = kubernetes_namespace.sftpgo.metadata[0].name
}
spec {
selector = {
app = "sftpgo"
}
port {
protocol = "TCP"
port = 8081
target_port = "webdav"
}
cluster_ip = "None"
}
}
resource "kubernetes_service" "sftpgo_http" {
metadata {
name = "http"
namespace = kubernetes_namespace.sftpgo.metadata[0].name
}
spec {
selector = {
app = "sftpgo"
}
port {
protocol = "TCP"
port = 8080
target_port = "http"
}
cluster_ip = "None"
}
}
+11
View File
@@ -0,0 +1,11 @@
output "path" {
value = local.data_path
}
output "namespace" {
value = kubernetes_namespace.sftpgo.metadata[0].name
}
output "app_name" {
value = "sftpgo"
}
+17
View File
@@ -0,0 +1,17 @@
terraform {
required_version = "~>1.8"
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = "~>2.18"
}
scaleway = {
source = "scaleway/scaleway"
version = "~>2.13"
}
random = {
source = "hashicorp/random"
version = "3.7.2"
}
}
}
@@ -0,0 +1,3 @@
[default]
aws_access_key_id=${access_key}
aws_secret_access_key=${secret_key}
@@ -0,0 +1,68 @@
variable "persistent_folder" {
description = "The path to the persistent folder"
type = string
}
variable "backup_folder" {
description = "The path to the backup folder"
type = string
}
variable "admin_username" {
description = "The admin username for SFTPGo"
type = string
sensitive = true
}
variable "admin_password" {
description = "The admin password for SFTPGo"
type = string
sensitive = true
}
variable "tag" {
description = "The version of Rustdesk to install"
type = string
default = "latest"
}
variable "smtp_host" {
description = "The SMTP relay host"
type = string
}
variable "smtp_port" {
description = "The SMTP relay port"
type = number
}
variable "smtp_username" {
description = "The SMTP relay username"
type = string
sensitive = true
}
variable "smtp_password" {
description = "The SMTP relay password"
type = string
sensitive = true
}
variable "from_email" {
description = "The email address to use as the sender"
type = string
}
variable "access_key" {
description = "The access key for the S3 compatible storage"
type = string
sensitive = true
}
variable "secret_key" {
description = "The secret key for the S3 compatible storage"
type = string
sensitive = true
}