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

Feature/tf modules extensions #1

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
46 changes: 8 additions & 38 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# docs
.nox
_build

# setuptools scm
nebari/_version.py
# git
.github

# ignore terraform state
.terraform
Expand All @@ -13,37 +9,11 @@ terraform.tfstate.backup

# python
__pycache__
build/
*.egg
*.egg-info/
dist/
env/

# IntelliJ
.idea/

# nix
result
shell.nix
.envrc
build.nix
.direnv

# ignore deploments
do-jupyterhub
jupyterhub-aws
gcp-jupyterhub
quansight-terraform-modules
config.yaml
data*

# modules - removed this because .terraform folder is in .gitignore of deployments,
# this should cover imported modules while not gitignoring our new direct 'modules' folder.

# ignore nebari files
# nebari
nebari-config.yaml

.vscode/
.pytest_cache

/.ruff_cache
config
/stages/
tests/
tmp/
.DS_Store
4 changes: 4 additions & 0 deletions nebari/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# file generated by setuptools_scm
# don't change, don't track in version control
__version__ = version = '2023.1.1'
__version_tuple__ = version_tuple = (2023, 1, 1)
10 changes: 10 additions & 0 deletions nebari/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,15 @@ class NebariExtension(Base):
logout: typing.Optional[str]
envs: typing.Optional[typing.List[NebariExtensionEnv]]

class TerraformModuleExtention(Base):
name: str
source: str
version: typing.Optional[str]
# kubeconfig_filename: str
# namespace: str
# endpoint: str
# nebari_realm_id: str
configuration: typing.Optional[typing.Dict]

class Ingress(Base):
terraform_overrides: typing.Any
Expand Down Expand Up @@ -563,6 +572,7 @@ class Main(Base):
terraform_state: typing.Optional[TerraformState]
certificate: Certificate
helm_extensions: typing.Optional[typing.List[HelmExtension]]
tf_modules_extensions: typing.Optional[typing.List[TerraformModuleExtention]]
prefect: typing.Optional[Prefect]
cdsdashboards: CDSDashboards
security: Security
Expand Down
32 changes: 32 additions & 0 deletions nebari/stages/input_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,38 @@ def stage_07_kubernetes_services(stage_outputs, config):


def stage_08_nebari_tf_extensions(stage_outputs, config):


if config.get('tf_modules_extensions') :
tf_modules_extensions = {
"module": {}
}
for extension in config.get('tf_modules_extensions', []):
if "version" in extension:
tf_modules_extensions['module'][extension['name']] = {
"version": extension['version'],
}
tf_modules_extensions['module'][extension['name']] = {
"source": extension['source'],
"kubernetes_config_path": os.path.join(tempfile.gettempdir(), "NEBARI_KUBECONFIG"),
"namespace": config["namespace"],
"endpoint": config["domain"],
"nebari_realm_id": stage_outputs["stages/06-kubernetes-keycloak-configuration"][
"realm_id"
]["value"],
}
if "configuration" in extension:
for key, value in extension['configuration'].items():
tf_modules_extensions['module'][extension['name']][key] = value
else :
tf_modules_extensions = {}

filename = "stages/08-nebari-tf-extensions/tf-modules-extensions.tf.json"
if os.path.exists(filename):
os.remove(filename)
with open(filename, "w") as file:
file.write(json.dumps(tf_modules_extensions, indent=4))

return {
"environment": config["namespace"],
"endpoint": config["domain"],
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ local_scheme = "node-and-timestamp"


### Project ###
#dynamic = ["version"]
[project]
name = "nebari"
dynamic = ["version"]
version = "2023.1.1"
description = "A Jupyter and Dask-powered open source data science platform."
readme = "README.md"
requires-python = ">=3.8"
Expand Down Expand Up @@ -65,6 +66,7 @@ dependencies = [
"rich==13.2.0",
"ruamel.yaml==0.17.21",
"typer==0.7.0",
"pyyaml==6.0",
]

[project.optional-dependencies]
Expand Down