Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not merge - traefik persistent volume #4

Closed
wants to merge 12 commits into from
7 changes: 7 additions & 0 deletions src/_nebari/stages/kubernetes_ingress/template/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,11 @@ module "kubernetes-ingress" {
load-balancer-annotations = var.load-balancer-annotations
load-balancer-ip = var.load-balancer-ip
additional-arguments = var.additional-arguments

access_modes = var.access_modes
pvc_name = var.pvc_name
pv_name = var.pv_name
path = var.path


}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ locals {
"--entrypoints.minio.http.tls.certResolver=letsencrypt",
"--certificatesresolvers.letsencrypt.acme.tlschallenge",
"--certificatesresolvers.letsencrypt.acme.email=${var.acme-email}",
"--certificatesresolvers.letsencrypt.acme.storage=acme.json",
"--certificatesresolvers.letsencrypt.acme.storage=/tmp/acme-certificates/acme.json",
"--certificatesresolvers.letsencrypt.acme.caserver=${var.acme-server}",
]
self-signed = local.default_cert
Expand Down Expand Up @@ -171,6 +171,46 @@ resource "kubernetes_service" "traefik_internal" {
}
}




resource "kubernetes_persistent_volume_claim" "persistent_volume_claim" {
metadata {
name = "${var.pvc_name}-traefik-ingress"
namespace = var.namespace
}
spec {
access_modes = ["ReadWriteMany"]
storage_class_name="standard"
resources {
requests = {
storage = "5Gi"
}
}
volume_name = "${kubernetes_persistent_volume.traefik_persistent_volume.metadata.0.name}"
}
}

resource "kubernetes_persistent_volume" "traefik_persistent_volume" {
metadata {
name = "${var.pv_name}-traefik-ingress"
}
spec {
capacity = {
storage = "10Gi"
}
storage_class_name="standard"
access_modes = ["ReadWriteMany"]

persistent_volume_source {
host_path {
path = var.path
}
}
}
}


resource "kubernetes_deployment" "main" {
metadata {
name = "${var.name}-traefik-ingress"
Expand Down Expand Up @@ -214,7 +254,10 @@ resource "kubernetes_deployment" "main" {
container {
image = "${var.traefik-image.image}:${var.traefik-image.tag}"
name = var.name

volume_mount {
mount_path = var.path
name = "data"
}
security_context {
capabilities {
drop = ["ALL"]
Expand Down Expand Up @@ -326,6 +369,12 @@ resource "kubernetes_deployment" "main" {
success_threshold = 1
}
}
volume {
name = "data"
persistent_volume_claim {
claim_name = kubernetes_persistent_volume_claim.persistent_volume_claim.metadata.0.name
}
}
}
}
}
Expand All @@ -348,3 +397,5 @@ resource "kubernetes_manifest" "tlsstore_default" {
}
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ output "endpoint" {
// handles the case when ingress is empty list
value = length(local.ingress) == 0 ? null : local.ingress.0
}


#
#output "traefik_certs_pvc_name" {
# value = kubernetes_persistent_volume_claim.traefik_certs_claim.metadata.0.name
#}
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,23 @@ variable "additional-arguments" {
type = list(string)
default = []
}



variable "access_modes" {
type = list(string)
default = ["ReadWriteOnce"]
}
variable "pvc_name"{
type = string
default = "persistent-volume-claim"
}

variable "pv_name"{
type = string
default = "traefik-persistent-volume"
}
variable "path" {
type = string
default = "/tmp/acme-certificates"
}
1 change: 1 addition & 0 deletions src/_nebari/stages/kubernetes_ingress/template/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ output "load_balancer_address" {
description = "traefik load balancer address"
value = module.kubernetes-ingress.endpoint
}

24 changes: 24 additions & 0 deletions src/_nebari/stages/kubernetes_ingress/template/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,27 @@ variable "additional-arguments" {
type = list(string)
default = []
}


variable "storage_size" {
type = string
default = "1Gi"
}

variable "access_modes" {
type = list(string)
default = ["ReadWriteOnce"]
}
variable "pvc_name"{
type = string
default = "persistent-volume-claim"
}

variable "pv_name"{
type = string
default = "traefik-persistent-volume"
}
variable "path" {
type = string
default = "/tmp/acme-certificates"
}
Loading