e6e85b00f7
- 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.
234 lines
5.7 KiB
Terraform
234 lines
5.7 KiB
Terraform
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"
|
|
}
|
|
}
|