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

fix forward auth when using custom cert #2479

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/_nebari/stages/kubernetes_services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ class KubernetesServicesInputVars(schema.Base):
node_groups: Dict[str, Dict[str, str]]
jupyterhub_logout_redirect_url: str = Field(alias="jupyterhub-logout-redirect-url")
forwardauth_middleware_name: str = _forwardauth_middleware_name
cert_secret_name: Optional[str] = None


def _split_docker_image_name(image_name):
Expand Down Expand Up @@ -491,6 +492,11 @@ def input_vars(self, stage_outputs: Dict[str, Dict[str, Any]]):
realm_id=realm_id,
node_groups=stage_outputs["stages/02-infrastructure"]["node_selectors"],
jupyterhub_logout_redirect_url=final_logout_uri,
cert_secret_name=(
self.config.certificate.secret_name
if self.config.certificate.type == "existing"
else None
),
)

conda_store_vars = CondaStoreInputVars(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ module "forwardauth" {

node-group = var.node_groups.general
forwardauth_middleware_name = var.forwardauth_middleware_name
cert_secret_name = var.cert_secret_name
}

variable "forwardauth_middleware_name" {
description = "Name of the traefik forward auth middleware"
type = string
}

variable "cert_secret_name" {
description = "Name of the secret containing the certificate"
type = string
}

output "forward-auth-middleware" {
description = "middleware name for use with forward auth"
value = module.forwardauth.forward-auth-middleware
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,19 @@ resource "kubernetes_deployment" "forwardauth-deployment" {
node_selector = {
"${var.node-group.key}" = var.node-group.value
}

dynamic "volume" {
for_each = var.cert_secret_name == null ? [] : [1]
content {
name = "cert-volume"
secret {
secret_name = var.cert_secret_name
items {
key = "tls.crt"
path = "tls.crt"
}
}
}
}
container {
# image = "thomseddon/traefik-forward-auth:2.2.0"
# Use PR #159 https://github.com/thomseddon/traefik-forward-auth/pull/159
Expand Down Expand Up @@ -125,10 +137,26 @@ resource "kubernetes_deployment" "forwardauth-deployment" {
value = var.external-url
}

dynamic "env" {
for_each = var.cert_secret_name == null ? [] : [1]
content {
name = "SSL_CERT_FILE"
value = "/config/tls.crt"
}
}

port {
container_port = 4181
}

dynamic "volume_mount" {
for_each = var.cert_secret_name == null ? [] : [1]
content {
name = "cert-volume"
mount_path = "/config"
read_only = true
}
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ variable "forwardauth_middleware_name" {
description = "Name of the traefik forward auth middleware"
type = string
}

variable "cert_secret_name" {
description = "Name of the secret containing the certificate"
type = string
}
Loading