Skip to content

Commit

Permalink
qhub-config.yaml as a secret (#905)
Browse files Browse the repository at this point in the history
* qhub-config.yaml added as a configmap

* read_only configmap

* qhubconfigyaml now a secret
  • Loading branch information
danlester authored Nov 16, 2021
1 parent a4e373d commit 1e86d99
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 9 deletions.
3 changes: 3 additions & 0 deletions qhub/render/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def patch_terraform_extensions(config):
"oauth2client": ext.get("oauth2client", False),
"logout": ext.get("logout", ""),
"jwt": False,
"qhubconfigyaml": ext.get("qhubconfigyaml", False),
}
tf_ext["envs"] = []
for env in ext.get("envs", []):
Expand Down Expand Up @@ -301,6 +302,8 @@ def render_template(output_directory, config_filename, force=False):

patch_terraform_extensions(config)

config["qhub_config_yaml_path"] = str(filename.absolute())

remove_existing_renders(
dest_repo_dir=output_directory / repo_directory,
verbosity=0,
Expand Down
1 change: 1 addition & 0 deletions qhub/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ class QHubExtension(Base):
urlslug: str
private: bool = False
oauth2client: bool = False
qhubconfigyaml: bool = False
envs: typing.Optional[typing.List[QHubExtensionEnv]]
logout: typing.Optional[str]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
module "ext-{{ ext.name }}" {
source = "./modules/kubernetes/qhubextension"

name = "qhub-ext-{{ ext.name }}"
namespace = var.environment
image = "{{ ext.image }}"
urlslug = "{{ ext.urlslug }}"
private = {{ ext.private | jsonify }}
oauth2client = {{ ext.oauth2client | jsonify }}
external-url = var.endpoint
qhub-realm-id = module.kubernetes-keycloak-config.qhub-realm-id
name = "qhub-ext-{{ ext.name }}"
namespace = var.environment
image = "{{ ext.image }}"
urlslug = "{{ ext.urlslug }}"
private = {{ ext.private | jsonify }}
oauth2client = {{ ext.oauth2client | jsonify }}
qhubconfigyaml = {{ ext.qhubconfigyaml | jsonify }}
external-url = var.endpoint
qhub-realm-id = module.kubernetes-keycloak-config.qhub-realm-id

envs = [
{%- for env in ext.envs | default([]) %}
Expand Down Expand Up @@ -41,4 +42,4 @@ resource "random_password" "qhub-ext-{{ ext.name }}-jwt-secret" {
}
{% endif %}

{%- endfor %}
{%- endfor %}
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,14 @@ module "forwardauth" {
module.kubernetes-initialization
]
}

resource "kubernetes_secret" "qhub_yaml_secret" {
metadata {
name = "qhub-config-yaml"
namespace = var.environment
}

data = {
"qhub-config.yaml" = file({{ cookiecutter.qhub_config_yaml_path | jsonify }})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,25 @@ resource "kubernetes_deployment" "qhub-extension-deployment" {
container_port = 80
}

dynamic "volume_mount" {
for_each = var.qhubconfigyaml ? [true] : []
content {
name = "qhubyamlsecret"
mount_path = "/etc/qhubyamlsecret/"
read_only = true
}
}

}

dynamic "volume" {
for_each = var.qhubconfigyaml ? [true] : []
content {
name = "qhubyamlsecret"
secret {
secret_name = "qhub-config-yaml"
}
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ variable "oauth2client" {
default = false
}

variable "qhubconfigyaml" {
description = "Mount qhub-config.yaml from configmap"
type = bool
default = false
}

variable "envs" {
description = "List of env var objects"
type = list(map(any))
Expand Down

0 comments on commit 1e86d99

Please sign in to comment.