2025-05-11 20:17:35 +02:00
|
|
|
resource "kubernetes_secret" "getmail_config" {
|
2025-05-05 19:56:43 +02:00
|
|
|
metadata {
|
|
|
|
|
name = "getmail-config"
|
|
|
|
|
namespace = kubernetes_namespace.mail.metadata[0].name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data = local.getmail_config
|
2025-05-11 20:17:35 +02:00
|
|
|
type = "Opaque"
|
2025-05-05 19:56:43 +02:00
|
|
|
}
|
|
|
|
|
|
2025-10-06 23:36:50 +02:00
|
|
|
resource "kubernetes_config_map_v1" "getmail_runner" {
|
|
|
|
|
metadata {
|
|
|
|
|
name = "getmail-runner"
|
|
|
|
|
namespace = kubernetes_namespace.mail.metadata[0].name
|
|
|
|
|
}
|
|
|
|
|
data = {
|
|
|
|
|
"runner.py" = local.getmail_runner_script
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "kubernetes_deployment_v1" "fetch_emails" {
|
2025-05-05 19:56:43 +02:00
|
|
|
metadata {
|
|
|
|
|
namespace = kubernetes_namespace.mail.metadata[0].name
|
|
|
|
|
name = "fetch-emails"
|
2025-10-06 23:36:50 +02:00
|
|
|
labels = {
|
|
|
|
|
app = "fetch-emails"
|
|
|
|
|
}
|
2025-05-05 19:56:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spec {
|
2025-10-06 23:36:50 +02:00
|
|
|
replicas = 1
|
|
|
|
|
selector {
|
|
|
|
|
match_labels = {
|
|
|
|
|
app = "fetch-emails"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
template {
|
2025-05-05 19:56:43 +02:00
|
|
|
metadata {
|
2025-10-06 23:36:50 +02:00
|
|
|
labels = {
|
|
|
|
|
app = "fetch-emails"
|
|
|
|
|
}
|
|
|
|
|
annotations = {
|
|
|
|
|
"checksum/runner-script" = local.checksum_getmail_runner_script
|
|
|
|
|
}
|
2025-05-05 19:56:43 +02:00
|
|
|
}
|
|
|
|
|
spec {
|
2025-10-06 23:36:50 +02:00
|
|
|
container {
|
|
|
|
|
name = "getmail"
|
|
|
|
|
image = "a13labs/getmail6:${var.getmail_tag}"
|
|
|
|
|
command = ["python3", "/runner/runner.py"]
|
|
|
|
|
env {
|
|
|
|
|
name = "FETCH_INTERVAL_SECONDS"
|
|
|
|
|
value = local.getmail_fetch_interval_seconds
|
2025-05-05 19:56:43 +02:00
|
|
|
}
|
|
|
|
|
|
2025-10-06 23:36:50 +02:00
|
|
|
volume_mount {
|
|
|
|
|
name = "getmail-config"
|
|
|
|
|
mount_path = "/getmail"
|
|
|
|
|
read_only = true
|
|
|
|
|
}
|
|
|
|
|
volume_mount {
|
|
|
|
|
name = "getmail-cache"
|
|
|
|
|
mount_path = "/var/getmail"
|
|
|
|
|
}
|
|
|
|
|
volume_mount {
|
|
|
|
|
name = "runner-script"
|
|
|
|
|
mount_path = "/runner"
|
|
|
|
|
read_only = true
|
|
|
|
|
}
|
|
|
|
|
volume_mount {
|
|
|
|
|
name = "tmp"
|
|
|
|
|
mount_path = "/tmp"
|
|
|
|
|
}
|
2025-05-05 19:56:43 +02:00
|
|
|
|
2025-10-06 23:36:50 +02:00
|
|
|
security_context {
|
|
|
|
|
run_as_user = 1000
|
|
|
|
|
run_as_group = 1000
|
|
|
|
|
read_only_root_filesystem = true
|
|
|
|
|
}
|
2025-05-05 19:56:43 +02:00
|
|
|
|
2025-10-06 23:36:50 +02:00
|
|
|
# Basic liveness (process must still be running)
|
|
|
|
|
liveness_probe {
|
|
|
|
|
exec {
|
|
|
|
|
command = ["bash", "-c", "pgrep -f runner.py > /dev/null"]
|
2025-05-05 19:56:43 +02:00
|
|
|
}
|
2025-10-06 23:36:50 +02:00
|
|
|
initial_delay_seconds = 30
|
|
|
|
|
period_seconds = 30
|
|
|
|
|
}
|
2025-05-05 19:56:43 +02:00
|
|
|
|
2025-10-06 23:36:50 +02:00
|
|
|
resources {
|
|
|
|
|
requests = {
|
|
|
|
|
cpu = "20m"
|
|
|
|
|
memory = "64Mi"
|
|
|
|
|
}
|
|
|
|
|
limits = {
|
|
|
|
|
cpu = "200m"
|
|
|
|
|
memory = "256Mi"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-05-11 20:17:35 +02:00
|
|
|
|
2025-10-06 23:36:50 +02:00
|
|
|
volume {
|
|
|
|
|
name = "getmail-config"
|
|
|
|
|
secret {
|
|
|
|
|
secret_name = kubernetes_secret.getmail_config.metadata[0].name
|
|
|
|
|
dynamic "items" {
|
|
|
|
|
for_each = local.getmail_jobs
|
|
|
|
|
content {
|
|
|
|
|
key = "getmailrc_${items.value.name}"
|
|
|
|
|
path = "getmailrc_${items.value.name}"
|
2025-05-05 19:56:43 +02:00
|
|
|
}
|
|
|
|
|
}
|
2025-10-06 23:36:50 +02:00
|
|
|
}
|
|
|
|
|
}
|
2025-05-05 19:56:43 +02:00
|
|
|
|
2025-10-06 23:36:50 +02:00
|
|
|
volume {
|
|
|
|
|
name = "getmail-cache"
|
|
|
|
|
host_path {
|
|
|
|
|
path = local.getmail_path
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
volume {
|
|
|
|
|
name = "runner-script"
|
|
|
|
|
config_map {
|
|
|
|
|
name = kubernetes_config_map_v1.getmail_runner.metadata[0].name
|
|
|
|
|
items {
|
|
|
|
|
key = "runner.py"
|
|
|
|
|
path = "runner.py"
|
2025-05-05 19:56:43 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-06 23:36:50 +02:00
|
|
|
volume {
|
|
|
|
|
name = "tmp"
|
|
|
|
|
empty_dir {}
|
|
|
|
|
}
|
2025-05-05 19:56:43 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|