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

Add Argo Workflow Admission controller #1741

Merged
merged 36 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
76f7588
add admission_controller
Adam-D-Lewis Apr 15, 2023
180fb96
remove unneeded variable and output
Adam-D-Lewis Apr 17, 2023
95e6fae
only mount subPaths which user has permission to access in initContai…
Adam-D-Lewis Apr 17, 2023
9ed82a3
add KEYCLOAK_URL env var
Adam-D-Lewis Apr 19, 2023
a7ed6ad
rename
Adam-D-Lewis Apr 21, 2023
87330d6
[pre-commit.ci] Apply automatic pre-commit fixes
pre-commit-ci[bot] Apr 21, 2023
4314318
format changes
Adam-D-Lewis Apr 24, 2023
7e1ce41
format changes
Adam-D-Lewis Apr 24, 2023
57fddbc
fix bug in mounting home dir
Adam-D-Lewis Apr 24, 2023
98a4188
Merge branch 'develop' into admission-controller
Adam-D-Lewis Apr 24, 2023
fb0e941
Merge branch 'develop' into mutating-wfac
Adam-D-Lewis Apr 26, 2023
c922cfa
update
Adam-D-Lewis Apr 26, 2023
5dcb3a9
update
Adam-D-Lewis Apr 26, 2023
3784aaa
Merge branch 'develop' into admission-controller
Adam-D-Lewis Apr 26, 2023
5cb1f4a
comment out mut
Adam-D-Lewis Apr 26, 2023
f1a2482
Merge branch 'develop' into admission-controller
Adam-D-Lewis Apr 27, 2023
0214f60
refactor code
Adam-D-Lewis May 1, 2023
24e49aa
Merge branch 'develop' into admission-controller
Adam-D-Lewis May 1, 2023
914ab34
Merge branch 'develop' into mutating-wfac
Adam-D-Lewis May 1, 2023
426f135
Merge branch 'develop' into admission-controller
Adam-D-Lewis May 1, 2023
ac12a9c
Merge branch 'mutating-wfac' into admission-controller
Adam-D-Lewis May 1, 2023
58332ea
remove debugging command
Adam-D-Lewis May 3, 2023
be0df36
update nebari-worfklow-controller image
Adam-D-Lewis May 3, 2023
75f3070
add tag for nebari-workflow-controller image
Adam-D-Lewis May 3, 2023
9a40ab3
update
Adam-D-Lewis May 8, 2023
b4f98c2
add cronworkflows
Adam-D-Lewis May 8, 2023
d887dca
merge develop
Adam-D-Lewis May 8, 2023
ed2ad1b
make nebari workflow controller able to be disabled
Adam-D-Lewis May 9, 2023
a3ed9e7
update image
Adam-D-Lewis May 9, 2023
fdfea35
remove sleep command
Adam-D-Lewis May 9, 2023
c22189b
use the prod image
Adam-D-Lewis May 9, 2023
1f71110
update nwc image
Adam-D-Lewis May 12, 2023
4707057
add nwc image_tag to schema
Adam-D-Lewis May 12, 2023
bcd6092
remove comments
Adam-D-Lewis May 12, 2023
735a4c3
update image tag
Adam-D-Lewis May 12, 2023
0685969
Merge branch 'develop' into admission-controller
Adam-D-Lewis May 22, 2023
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
2 changes: 2 additions & 0 deletions nebari/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@

DEFAULT_CONDA_STORE_IMAGE_TAG = "v0.4.14"

DEFAULT_NEBARI_WORKFLOW_CONTROLLER_IMAGE_TAG = "update_nwc-05c3b99-20230512"

LATEST_SUPPORTED_PYTHON_VERSION = "3.10"
2 changes: 1 addition & 1 deletion nebari/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def guided_install(
provision_07_kubernetes_services(stage_outputs, config, disable_checks)
provision_08_nebari_tf_extensions(stage_outputs, config, disable_checks)

print("Nebari deployed successfully")
print("Nebari deployed successfully")

print("Services:")
for service_name, service in stage_outputs["stages/07-kubernetes-services"][
Expand Down
6 changes: 6 additions & 0 deletions nebari/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,15 @@ class HelmExtension(Base):
# ============== Argo-Workflows =========


class NebariWorkflowController(Base):
enabled: bool
image_tag: typing.Optional[str]


class ArgoWorkflows(Base):
enabled: bool
overrides: typing.Optional[typing.Dict]
nebari_workflow_controller: typing.Optional[NebariWorkflowController]


# ============== kbatch =============
Expand Down
13 changes: 13 additions & 0 deletions nebari/stages/input_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from nebari.constants import (
DEFAULT_CONDA_STORE_IMAGE_TAG,
DEFAULT_GKE_RELEASE_CHANNEL,
DEFAULT_NEBARI_WORKFLOW_CONTROLLER_IMAGE_TAG,
DEFAULT_TRAEFIK_IMAGE_TAG,
)

Expand Down Expand Up @@ -349,6 +350,18 @@ def stage_07_kubernetes_services(stage_outputs, config):
"argo-workflows-overrides": [
json.dumps(config.get("argo_workflows", {}).get("overrides", {}))
],
"nebari-workflow-controller": config["argo_workflows"]
.get("nebari_workflow_controller", {})
.get("enabled", True),
"keycloak-read-only-user-credentials": stage_outputs[
"stages/06-kubernetes-keycloak-configuration"
]["keycloak-read-only-user-credentials"]["value"],
"workflow-controller-image-tag": config.get("argo_workflows", {})
.get("nebari_workflow_controller", {})
.get(
"image_tag",
DEFAULT_NEBARI_WORKFLOW_CONTROLLER_IMAGE_TAG,
),
# kbatch
"kbatch-enabled": config["kbatch"]["enabled"],
# prefect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ resource "helm_release" "keycloak" {
})
], var.overrides)

set {
set_sensitive {
name = "nebari_bot_password"
value = var.nebari-bot-password
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,34 @@ resource "keycloak_default_groups" "default" {
]
}

data "keycloak_realm" "master" {
realm = "master"
}

resource "random_password" "keycloak-view-only-user-password" {
length = 32
special = false
}

resource "keycloak_user" "read-only-user" {
realm_id = data.keycloak_realm.master.id
username = "read-only-user"
initial_password {
value = random_password.keycloak-view-only-user-password.result
temporary = false
}
}

resource "keycloak_user_roles" "user_roles" {
realm_id = data.keycloak_realm.master.id
user_id = keycloak_user.read-only-user.id

role_ids = [
data.keycloak_role.view-users.id,
]
exhaustive = true
}

# needed for keycloak monitoring to function
resource "keycloak_realm_events" "realm_events" {
realm_id = keycloak_realm.main.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,14 @@ output "realm_id" {
description = "Realm id used for nebari resources"
value = keycloak_realm.main.id
}

output "keycloak-read-only-user-credentials" {
description = "Credentials for user that can read users/groups, but not modify them"
sensitive = true
value = {
username = keycloak_user.read-only-user.username
password = random_password.keycloak-view-only-user-password.result
client_id = "admin-cli"
realm = data.keycloak_realm.master.realm
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ data "keycloak_role" "manage-users" {
name = "manage-users"
}

data "keycloak_openid_client" "nebari-realm" {
depends_on = [
keycloak_realm.main,
]
realm_id = data.keycloak_realm.master.id
client_id = "${var.realm}-realm"
}

data "keycloak_role" "view-users" {
realm_id = data.keycloak_realm.master.id
client_id = data.keycloak_openid_client.nebari-realm.id
name = "view-users"
}


data "keycloak_role" "query-users" {
realm_id = keycloak_realm.main.id
client_id = data.keycloak_openid_client.realm_management.id
Expand Down
25 changes: 23 additions & 2 deletions nebari/template/stages/07-kubernetes-services/argo-workflows.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ variable "argo-workflows-overrides" {
default = []
}

variable "nebari-workflow-controller" {
description = "Nebari Workflow Controller enabled"
type = bool
default = true
}


variable "keycloak-read-only-user-credentials" {
description = "Keycloak password for nebari-bot"
type = map(string)
default = {}
}

variable "workflow-controller-image-tag" {
description = "Image tag for nebari-workflow-controller"
type = string
}


# ====================== RESOURCES =======================
module "argo-workflows" {
Expand All @@ -21,6 +39,9 @@ module "argo-workflows" {
external-url = var.endpoint
realm_id = var.realm_id

node-group = var.node_groups.general
overrides = var.argo-workflows-overrides
node-group = var.node_groups.general
overrides = var.argo-workflows-overrides
keycloak-read-only-user-credentials = var.keycloak-read-only-user-credentials
workflow-controller-image-tag = var.workflow-controller-image-tag
nebari-workflow-controller = var.nebari-workflow-controller
}
Loading