feat(sftpgo): add TLS support and internal certificate management
This commit is contained in:
@@ -11,7 +11,9 @@ locals {
|
|||||||
"alexpires.me" = {
|
"alexpires.me" = {
|
||||||
domain_name = "alexpires.me"
|
domain_name = "alexpires.me"
|
||||||
fqdn = ["blog.alexpires.me", "www.alexpires.me", "alexpires.me"]
|
fqdn = ["blog.alexpires.me", "www.alexpires.me", "alexpires.me"]
|
||||||
config = file("${path.module}/resources/alexpires.me.conf")
|
tls = true
|
||||||
|
issuer = "internal-ca"
|
||||||
|
custom_snippet = file("${path.module}/resources/alexpires.me.conf")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
resource "kubernetes_secret" "root_ca" {
|
||||||
|
metadata {
|
||||||
|
name = "root-ca"
|
||||||
|
namespace = "cert-manager"
|
||||||
|
}
|
||||||
|
data = {
|
||||||
|
"tls.crt" = var.root_ca_pem
|
||||||
|
"tls.key" = var.root_ca_key
|
||||||
|
}
|
||||||
|
|
||||||
|
type = "kubernetes.io/tls"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "kubernetes_manifest" "cluster_issuer" {
|
||||||
|
|
||||||
|
manifest = {
|
||||||
|
apiVersion = "cert-manager.io/v1"
|
||||||
|
kind = "ClusterIssuer"
|
||||||
|
metadata = {
|
||||||
|
name = "internal-ca"
|
||||||
|
annotations = {
|
||||||
|
"cert-manager.io/issuer-group" = "cert-manager.io"
|
||||||
|
"cert-manager.io/issuer-kind" = "Issuer"
|
||||||
|
"cert-manager.io/issuer-name" = "internal-ca"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spec = {
|
||||||
|
ca = {
|
||||||
|
secretName = "root-ca"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,46 +1,11 @@
|
|||||||
server {
|
resolver kube-dns.kube-system.svc.cluster.local valid=10s;
|
||||||
listen 8080;
|
|
||||||
server_name localhost;
|
|
||||||
root /tmp/site;
|
|
||||||
|
|
||||||
resolver kube-dns.kube-system.svc.cluster.local valid=10s;
|
location ^~ /config/dav {
|
||||||
|
proxy_pass https://web.sftpgo.svc.cluster.local/config/dav;
|
||||||
gzip on;
|
|
||||||
gzip_comp_level 9;
|
|
||||||
gzip_types
|
|
||||||
text/html
|
|
||||||
text/plain
|
|
||||||
text/css
|
|
||||||
text/js
|
|
||||||
text/xml
|
|
||||||
text/javascript
|
|
||||||
application/javascript
|
|
||||||
application/json
|
|
||||||
application/xml
|
|
||||||
application/rss+xml
|
|
||||||
image/svg+xml;
|
|
||||||
|
|
||||||
location ^~ /config/dav {
|
|
||||||
proxy_pass http://http.sftpgo.svc.cluster.local:8080/config/dav;
|
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
proxy_set_header X-Forwarded-Host $host;
|
proxy_set_header X-Forwarded-Host $host;
|
||||||
proxy_set_header X-Forwarded-Port $server_port;
|
proxy_set_header X-Forwarded-Port $server_port;
|
||||||
}
|
|
||||||
|
|
||||||
location / {
|
|
||||||
index index.html index.htm;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~* ^/([^/]+) {
|
|
||||||
index index.html index.htm;
|
|
||||||
error_page 404 = @error;
|
|
||||||
}
|
|
||||||
|
|
||||||
error_page 404 /404.html;
|
|
||||||
location @error {
|
|
||||||
try_files /$1/404.html /404.html =404;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,3 +71,14 @@ variable "sftpgo_admin_password" {
|
|||||||
sensitive = true
|
sensitive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "root_ca_pem" {
|
||||||
|
description = "Root CA PEM"
|
||||||
|
type = string
|
||||||
|
sensitive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "root_ca_key" {
|
||||||
|
description = "Root CA Key"
|
||||||
|
type = string
|
||||||
|
sensitive = true
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,3 +22,5 @@ TF_VAR_alexpires_me_email_password=$ALEXPIRES_ME_EMAIL_PASSWORD
|
|||||||
TF_VAR_mail_crypt_private_key=$DOVECOT_CRYPT_PRIVATE_KEY_FILE
|
TF_VAR_mail_crypt_private_key=$DOVECOT_CRYPT_PRIVATE_KEY_FILE
|
||||||
TF_VAR_mail_crypt_public_key=$DOVECOT_CRYPT_PUB_KEY_FILE
|
TF_VAR_mail_crypt_public_key=$DOVECOT_CRYPT_PUB_KEY_FILE
|
||||||
TF_VAR_sftpgo_admin_password=$SFTPGO_ADMIN_PASSWORD
|
TF_VAR_sftpgo_admin_password=$SFTPGO_ADMIN_PASSWORD
|
||||||
|
TF_VAR_root_ca_pem=$K8S_ROOT_CA_PEM
|
||||||
|
TF_VAR_root_ca_key=$K8S_ROOT_CA_KEY
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ resource "kubernetes_service_account" "website_service_account" {
|
|||||||
automount_service_account_token = false
|
automount_service_account_token = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
resource "kubernetes_service" "website" {
|
resource "kubernetes_service" "website" {
|
||||||
for_each = local.websites
|
for_each = local.websites
|
||||||
metadata {
|
metadata {
|
||||||
@@ -31,9 +30,18 @@ resource "kubernetes_service" "website" {
|
|||||||
}
|
}
|
||||||
spec {
|
spec {
|
||||||
port {
|
port {
|
||||||
|
name = "http"
|
||||||
port = 80
|
port = 80
|
||||||
target_port = "http"
|
target_port = "http"
|
||||||
}
|
}
|
||||||
|
dynamic "port" {
|
||||||
|
for_each = each.value.tls ? [443] : []
|
||||||
|
content {
|
||||||
|
name = "https"
|
||||||
|
port = 443
|
||||||
|
target_port = "https"
|
||||||
|
}
|
||||||
|
}
|
||||||
selector = {
|
selector = {
|
||||||
app = format("website-%s", replace(each.key, ".", "-"))
|
app = format("website-%s", replace(each.key, ".", "-"))
|
||||||
}
|
}
|
||||||
@@ -41,6 +49,29 @@ resource "kubernetes_service" "website" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "kubernetes_manifest" "internal_cert" {
|
||||||
|
for_each = {
|
||||||
|
for k, v in local.websites : k => v if v.tls == true
|
||||||
|
}
|
||||||
|
manifest = {
|
||||||
|
apiVersion = "cert-manager.io/v1"
|
||||||
|
kind = "Certificate"
|
||||||
|
metadata = {
|
||||||
|
name = format("website-%s-tls-internal", replace(each.key, ".", "-"))
|
||||||
|
namespace = kubernetes_namespace.website.metadata[0].name
|
||||||
|
}
|
||||||
|
spec = {
|
||||||
|
secretName = format("website-%s-tls-internal", replace(each.key, ".", "-"))
|
||||||
|
issuerRef = {
|
||||||
|
name = each.value.issuer
|
||||||
|
kind = "ClusterIssuer"
|
||||||
|
}
|
||||||
|
commonName = each.value.domain_name
|
||||||
|
dnsNames = each.value.fqdn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resource "kubernetes_config_map" "nginx_config" {
|
resource "kubernetes_config_map" "nginx_config" {
|
||||||
metadata {
|
metadata {
|
||||||
name = "nginx-config"
|
name = "nginx-config"
|
||||||
@@ -60,7 +91,11 @@ resource "kubernetes_config_map" "nginx_default_config" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"default.conf" = each.value.config
|
"default.conf" = coalesce(each.value.config, templatefile("${path.module}/resources/conf.d/default.conf.tpl", {
|
||||||
|
tls = each.value.tls
|
||||||
|
fqdn = each.value.domain_name
|
||||||
|
custom_snippet = each.value.custom_snippet
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,10 +105,17 @@ resource "kubernetes_ingress_v1" "website_ingress" {
|
|||||||
name = "website-ingress"
|
name = "website-ingress"
|
||||||
namespace = kubernetes_namespace.website.metadata[0].name
|
namespace = kubernetes_namespace.website.metadata[0].name
|
||||||
|
|
||||||
annotations = {
|
annotations = merge({
|
||||||
"kubernetes.io/ingress.class" = "public"
|
"kubernetes.io/ingress.class" = "public"
|
||||||
"cert-manager.io/cluster-issuer" = "letsencrypt-prod"
|
"cert-manager.io/cluster-issuer" = "letsencrypt-prod"
|
||||||
}
|
},
|
||||||
|
each.value.tls ? {
|
||||||
|
"nginx.org/ssl-services" = format("website-%s", replace(each.key, ".", "-"))
|
||||||
|
"nginx.org/ssl-redirect" = "true"
|
||||||
|
"nginx.org/redirect-to-https" = "true"
|
||||||
|
"nginx.ingress.kubernetes.io/backend-protocol" = "HTTPS"
|
||||||
|
} : {}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
spec {
|
spec {
|
||||||
tls {
|
tls {
|
||||||
@@ -90,7 +132,7 @@ resource "kubernetes_ingress_v1" "website_ingress" {
|
|||||||
service {
|
service {
|
||||||
name = format("website-%s", replace(each.key, ".", "-"))
|
name = format("website-%s", replace(each.key, ".", "-"))
|
||||||
port {
|
port {
|
||||||
number = 80
|
name = each.value.tls ? "https" : "http"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,7 +166,12 @@ resource "kubernetes_deployment" "website" {
|
|||||||
}
|
}
|
||||||
annotations = {
|
annotations = {
|
||||||
"checksum/nginx" = local.nginx_config_checksum
|
"checksum/nginx" = local.nginx_config_checksum
|
||||||
"checksum/default" = sha256(each.value.config)
|
"checksum/default" = sha256(coalesce(each.value.config, templatefile("${path.module}/resources/conf.d/default.conf.tpl", {
|
||||||
|
tls = each.value.tls
|
||||||
|
fqdn = each.value.domain_name
|
||||||
|
custom_snippet = each.value.custom_snippet
|
||||||
|
}))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spec {
|
spec {
|
||||||
@@ -175,6 +222,14 @@ resource "kubernetes_deployment" "website" {
|
|||||||
container_port = 8080
|
container_port = 8080
|
||||||
name = "http"
|
name = "http"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dynamic "port" {
|
||||||
|
for_each = each.value.tls ? [443] : []
|
||||||
|
content {
|
||||||
|
container_port = 8443
|
||||||
|
name = "https"
|
||||||
|
}
|
||||||
|
}
|
||||||
volume_mount {
|
volume_mount {
|
||||||
name = "nginx"
|
name = "nginx"
|
||||||
mount_path = "/etc/nginx/nginx.conf"
|
mount_path = "/etc/nginx/nginx.conf"
|
||||||
@@ -192,6 +247,14 @@ resource "kubernetes_deployment" "website" {
|
|||||||
mount_path = "/tmp/site"
|
mount_path = "/tmp/site"
|
||||||
read_only = true
|
read_only = true
|
||||||
}
|
}
|
||||||
|
dynamic "volume_mount" {
|
||||||
|
for_each = each.value.tls ? [443] : []
|
||||||
|
content {
|
||||||
|
name = "tls"
|
||||||
|
mount_path = "/etc/ssl/certs/private"
|
||||||
|
read_only = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
volume {
|
volume {
|
||||||
name = "nginx"
|
name = "nginx"
|
||||||
@@ -211,9 +274,27 @@ resource "kubernetes_deployment" "website" {
|
|||||||
path = format("%s/%s", local.websites_path, each.key)
|
path = format("%s/%s", local.websites_path, each.key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dynamic "volume" {
|
||||||
|
for_each = each.value.tls ? [443] : []
|
||||||
|
content {
|
||||||
|
name = "tls"
|
||||||
|
secret {
|
||||||
|
secret_name = kubernetes_manifest.internal_cert[each.key].manifest["metadata"]["name"]
|
||||||
|
items {
|
||||||
|
key = "tls.crt"
|
||||||
|
path = "tls.crt"
|
||||||
|
}
|
||||||
|
items {
|
||||||
|
key = "tls.key"
|
||||||
|
path = "tls.key"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lifecycle {
|
lifecycle {
|
||||||
ignore_changes = [spec[0].template[0].metadata[0].annotations["kubectl.kubernetes.io/restartedAt"]]
|
ignore_changes = [spec[0].template[0].metadata[0].annotations["kubectl.kubernetes.io/restartedAt"]]
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-6
@@ -1,7 +1,12 @@
|
|||||||
server {
|
server {
|
||||||
listen 8080;
|
listen 8080;
|
||||||
server_name localhost;
|
%{ if tls ~}
|
||||||
|
listen 8443 ssl;
|
||||||
|
ssl_certificate /etc/ssl/certs/private/tls.crt;
|
||||||
|
ssl_certificate_key /etc/ssl/certs/private/tls.key;
|
||||||
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
|
%{ endif ~}
|
||||||
|
server_name ${fqdn};
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_comp_level 9;
|
gzip_comp_level 9;
|
||||||
gzip_types
|
gzip_types
|
||||||
@@ -16,18 +21,17 @@ server {
|
|||||||
application/xml
|
application/xml
|
||||||
application/rss+xml
|
application/rss+xml
|
||||||
image/svg+xml;
|
image/svg+xml;
|
||||||
|
|
||||||
root /tmp/site;
|
root /tmp/site;
|
||||||
|
%{ if custom_snippet != "" ~}
|
||||||
|
${custom_snippet}
|
||||||
|
%{ endif ~}
|
||||||
location / {
|
location / {
|
||||||
index index.html index.htm;
|
index index.html index.htm;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~* ^/([^/]+) {
|
location ~* ^/([^/]+) {
|
||||||
index index.html index.htm;
|
index index.html index.htm;
|
||||||
error_page 404 = @error;
|
error_page 404 = @error;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_page 404 /404.html;
|
error_page 404 /404.html;
|
||||||
location @error {
|
location @error {
|
||||||
try_files /$1/404.html /404.html =404;
|
try_files /$1/404.html /404.html =404;
|
||||||
@@ -15,5 +15,9 @@ variable "websites" {
|
|||||||
domain_name = string
|
domain_name = string
|
||||||
fqdn = list(string)
|
fqdn = list(string)
|
||||||
config = optional(string, "")
|
config = optional(string, "")
|
||||||
|
tls = optional(bool, false)
|
||||||
|
issuer = optional(string, "internal-ca")
|
||||||
|
custom_snippet = optional(string, "")
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,70 +3,76 @@ locals {
|
|||||||
|
|
||||||
|
|
||||||
sftpgo_config = {
|
sftpgo_config = {
|
||||||
"common" : {
|
common = {
|
||||||
"defender" : {
|
defender = {
|
||||||
"enabled" : false
|
enabled = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sftpd" : {
|
sftpd = {
|
||||||
"bindings" : [
|
bindings = [
|
||||||
{
|
{
|
||||||
"port" : 0
|
port = 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"webdavd" : {
|
webdavd = {
|
||||||
"bindings" : [
|
bindings = [
|
||||||
{
|
{
|
||||||
"port" : 8081,
|
port = 8081
|
||||||
"address" : "0.0.0.0"
|
address = "0.0.0.0"
|
||||||
|
enable_https = var.tls_enabled
|
||||||
|
certificate_file = "/etc/ssl/certs/private/tls.crt"
|
||||||
|
certificate_key_file = "/etc/ssl/certs/private/tls.key"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"data_provider" : {
|
data_provider = {
|
||||||
"create_default_admin" : true,
|
create_default_admin = true
|
||||||
"backups_path" : "/var/lib/sftpgo/backup"
|
backups_path = "/var/lib/sftpgo/backup"
|
||||||
},
|
},
|
||||||
"httpd" : {
|
httpd = {
|
||||||
"bindings" : [
|
bindings = [
|
||||||
{
|
{
|
||||||
"port" : 8080,
|
port = 8080
|
||||||
"address" : "0.0.0.0",
|
address = "0.0.0.0"
|
||||||
"branding" : {
|
enable_https = var.tls_enabled
|
||||||
"web_client" : {
|
certificate_file = "/etc/ssl/certs/private/tls.crt"
|
||||||
"name" : "alexpires.me cloud",
|
certificate_key_file = "/etc/ssl/certs/private/tls.key"
|
||||||
"short_name" : "alexpires.me"
|
branding = {
|
||||||
|
web_client = {
|
||||||
|
name = "alexpires.me cloud"
|
||||||
|
short_name = "alexpires.me"
|
||||||
},
|
},
|
||||||
"web_admin" : {
|
web_admin = {
|
||||||
"name" : "alexpires.me cloud",
|
name = "alexpires.me cloud"
|
||||||
"short_name" : "alexpires.me"
|
short_name = "alexpires.me"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"web_root" : "/config/dav",
|
web_root = "/config/dav",
|
||||||
},
|
},
|
||||||
"telemetry" : {
|
telemetry = {
|
||||||
"bind_port" : 10000,
|
bind_port = 10000
|
||||||
"bind_address" : "0.0.0.0"
|
bind_address = "0.0.0.0"
|
||||||
},
|
},
|
||||||
"mfa" : {
|
mfa = {
|
||||||
"totp" : [
|
totp = [
|
||||||
{
|
{
|
||||||
"name" : "Default",
|
name = "Default",
|
||||||
"issuer" : "alexpires.me",
|
issuer = "alexpires.me"
|
||||||
"algo" : "sha1"
|
algo = "sha1"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"smtp" : {
|
smtp = {
|
||||||
"host" : var.smtp_host,
|
host = var.smtp_host,
|
||||||
"port" : var.smtp_port,
|
port = var.smtp_port,
|
||||||
"from" : var.from_email
|
from = var.from_email
|
||||||
"encryption" : 1,
|
encryption = 1,
|
||||||
"domain" : "alexpires.me"
|
domain = "alexpires.me"
|
||||||
},
|
},
|
||||||
"plugins" : []
|
plugins = []
|
||||||
}
|
}
|
||||||
|
|
||||||
config = jsonencode(local.sftpgo_config)
|
config = jsonencode(local.sftpgo_config)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ resource "kubernetes_ingress_v1" "ingress" {
|
|||||||
name = "webdav-ingress"
|
name = "webdav-ingress"
|
||||||
namespace = kubernetes_namespace.sftpgo.metadata[0].name
|
namespace = kubernetes_namespace.sftpgo.metadata[0].name
|
||||||
|
|
||||||
annotations = {
|
annotations = merge({
|
||||||
"kubernetes.io/ingress.class" = "public"
|
"kubernetes.io/ingress.class" = "public"
|
||||||
"cert-manager.io/cluster-issuer" = "letsencrypt-prod"
|
"cert-manager.io/cluster-issuer" = "letsencrypt-prod"
|
||||||
"kubernetes.io/tls-acme" = "true"
|
"kubernetes.io/tls-acme" = "true"
|
||||||
@@ -15,7 +15,15 @@ resource "kubernetes_ingress_v1" "ingress" {
|
|||||||
"nginx.ingress.kubernetes.io/proxy-request-buffering" = "on"
|
"nginx.ingress.kubernetes.io/proxy-request-buffering" = "on"
|
||||||
"nginx.ingress.kubernetes.io/proxy-buffer-size" = "32k"
|
"nginx.ingress.kubernetes.io/proxy-buffer-size" = "32k"
|
||||||
"nginx.ingress.kubernetes.io/proxy-buffers-number" = "16"
|
"nginx.ingress.kubernetes.io/proxy-buffers-number" = "16"
|
||||||
}
|
},
|
||||||
|
var.tls_enabled ? {
|
||||||
|
"nginx.org/ssl-services" = "webdav"
|
||||||
|
"nginx.org/ssl-redirect" = "true"
|
||||||
|
"nginx.org/redirect-to-https" = "true"
|
||||||
|
"nginx.ingress.kubernetes.io/backend-protocol" = "HTTPS"
|
||||||
|
} : {}
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
spec {
|
spec {
|
||||||
tls {
|
tls {
|
||||||
@@ -30,7 +38,7 @@ resource "kubernetes_ingress_v1" "ingress" {
|
|||||||
service {
|
service {
|
||||||
name = "webdav"
|
name = "webdav"
|
||||||
port {
|
port {
|
||||||
number = 8081
|
name = var.tls_enabled ? "davs" : "dav"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,27 @@ resource "kubernetes_namespace" "sftpgo" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "kubernetes_manifest" "internal_cert" {
|
||||||
|
count = var.tls_enabled ? 1 : 0
|
||||||
|
manifest = {
|
||||||
|
apiVersion = "cert-manager.io/v1"
|
||||||
|
kind = "Certificate"
|
||||||
|
metadata = {
|
||||||
|
name = "internal-cert"
|
||||||
|
namespace = kubernetes_namespace.sftpgo.metadata[0].name
|
||||||
|
}
|
||||||
|
spec = {
|
||||||
|
secretName = "internal-cert"
|
||||||
|
issuerRef = {
|
||||||
|
name = var.issuer
|
||||||
|
kind = "ClusterIssuer"
|
||||||
|
}
|
||||||
|
commonName = var.fqdn
|
||||||
|
dnsNames = [var.fqdn]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resource "kubernetes_config_map" "sftpgo" {
|
resource "kubernetes_config_map" "sftpgo" {
|
||||||
metadata {
|
metadata {
|
||||||
name = "sftpgo"
|
name = "sftpgo"
|
||||||
@@ -121,12 +142,13 @@ resource "kubernetes_deployment" "sftpgo" {
|
|||||||
}
|
}
|
||||||
port {
|
port {
|
||||||
container_port = 8081
|
container_port = 8081
|
||||||
name = "webdav"
|
name = "dav"
|
||||||
protocol = "TCP"
|
protocol = "TCP"
|
||||||
}
|
}
|
||||||
|
|
||||||
port {
|
port {
|
||||||
container_port = 8080
|
container_port = 8080
|
||||||
name = "http"
|
name = "web"
|
||||||
protocol = "TCP"
|
protocol = "TCP"
|
||||||
}
|
}
|
||||||
port {
|
port {
|
||||||
@@ -166,6 +188,14 @@ resource "kubernetes_deployment" "sftpgo" {
|
|||||||
sub_path = "credentials"
|
sub_path = "credentials"
|
||||||
read_only = true
|
read_only = true
|
||||||
}
|
}
|
||||||
|
dynamic "volume_mount" {
|
||||||
|
for_each = var.tls_enabled ? [1] : []
|
||||||
|
content {
|
||||||
|
mount_path = "/etc/ssl/certs/private"
|
||||||
|
name = "internal-cert"
|
||||||
|
read_only = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
volume {
|
volume {
|
||||||
name = "config"
|
name = "config"
|
||||||
@@ -191,6 +221,15 @@ resource "kubernetes_deployment" "sftpgo" {
|
|||||||
name = kubernetes_config_map.object_store_credentials.metadata[0].name
|
name = kubernetes_config_map.object_store_credentials.metadata[0].name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dynamic "volume" {
|
||||||
|
for_each = var.tls_enabled ? [1] : []
|
||||||
|
content {
|
||||||
|
name = "internal-cert"
|
||||||
|
secret {
|
||||||
|
secret_name = kubernetes_manifest.internal_cert[0].manifest["metadata"]["name"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,17 +245,18 @@ resource "kubernetes_service" "sftpgo_webdav" {
|
|||||||
app = "sftpgo"
|
app = "sftpgo"
|
||||||
}
|
}
|
||||||
port {
|
port {
|
||||||
|
name = var.tls_enabled ? "davs" : "dav"
|
||||||
protocol = "TCP"
|
protocol = "TCP"
|
||||||
port = 8081
|
port = var.tls_enabled ? 443 : 80
|
||||||
target_port = "webdav"
|
target_port = "dav"
|
||||||
}
|
}
|
||||||
cluster_ip = "None"
|
cluster_ip = "None"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "kubernetes_service" "sftpgo_http" {
|
resource "kubernetes_service" "sftpgo_web" {
|
||||||
metadata {
|
metadata {
|
||||||
name = "http"
|
name = "web"
|
||||||
namespace = kubernetes_namespace.sftpgo.metadata[0].name
|
namespace = kubernetes_namespace.sftpgo.metadata[0].name
|
||||||
}
|
}
|
||||||
spec {
|
spec {
|
||||||
@@ -225,9 +265,9 @@ resource "kubernetes_service" "sftpgo_http" {
|
|||||||
}
|
}
|
||||||
port {
|
port {
|
||||||
protocol = "TCP"
|
protocol = "TCP"
|
||||||
port = 8080
|
port = var.tls_enabled ? 443 : 80
|
||||||
target_port = "http"
|
target_port = "web"
|
||||||
}
|
}
|
||||||
cluster_ip = "None"
|
type = "ClusterIP"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,3 +71,16 @@ variable "fqdn" {
|
|||||||
description = "The fully qualified domain name for the Rustdesk server"
|
description = "The fully qualified domain name for the Rustdesk server"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "issuer" {
|
||||||
|
description = "The issuer for the certificate"
|
||||||
|
type = string
|
||||||
|
default = "internal-ca"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "tls_enabled" {
|
||||||
|
description = "Enable TLS for the SFTPGo server"
|
||||||
|
type = bool
|
||||||
|
default = true
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user