Skip to content

Commit

Permalink
feat: render global environment for prometheus outside tutor-env (edu…
Browse files Browse the repository at this point in the history
  • Loading branch information
mariajgrimaldi authored Aug 10, 2022
1 parent 8990e08 commit f114243
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
35 changes: 35 additions & 0 deletions drydock/manifest_builder/infrastructure/tutor_based_manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,38 @@ def relocate_env(self, src: str, dst: str) -> None:
if not os.path.exists(base_dir):
raise TutorError("[DRYDOCK] Missing extra-extensions folder")
shutil.move(base_dir, dst)


class GlobalManifests(BaseManifests):
"""Generate environment not bound to tutor env manifests."""

TEMPLATE_ROOT = "kustomized/global-stack"
TEMPLATE_TARGETS = [
f"{TEMPLATE_ROOT}/kustomization.yml",
]

def __init__(self, options: dict) -> None:
"""Initialize the class based on the `manifest_options` from the reference.
Parameters
----------
options: dict
Defines additional configuration options for the generations of the
configuration repository.
- ["output"]: Name of the directory to store the manifests.
"""
self.output_dir = options.get("output", "drydock-global-env")

def relocate_env(self, src: str, dst: str) -> None:
"""Moves the drydock rendered templates a global destination.
Parameters
----------
src: str
The initial path where the full tutor env was rendered.
dst: str
The path to save the final environment with the global manifests..
"""
base_dir = path_join(src, "env/drydock", f"{self.TEMPLATE_ROOT}")
shutil.move(base_dir, dst)
5 changes: 5 additions & 0 deletions drydock/manifest_builder/infrastructure/tutor_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,8 @@ def get_data(self) -> dict:

def get_root(self) -> str:
return self.context.obj.root


class TutorGlobalConfig(TutorExtendedConfig):
"""Drydock configuration defaults for a global environment."""
DEFAULT_TEMPLATE_SET = "kustomized/global-stack"
5 changes: 5 additions & 0 deletions drydock/templates/kustomized/global-stack/defaults.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DRYDOCK_GLOBAL_STACK_NAMESPACE: "monitoring"
DRYDOCK_PROMETHEUS_VALUES: ""
DRYDOCK_PROMETHEUS_PATCHES: ""
DRYDOCK_GLOBAL_RESOURCES: ""
DRYDOCK_PROMETHEUS_VERSION: 39.4.0
24 changes: 24 additions & 0 deletions drydock/templates/kustomized/global-stack/kustomization.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: {{ DRYDOCK_GLOBAL_STACK_NAMESPACE }}

{%- if DRYDOCK_GLOBAL_RESOURCES %}
resources:
{{ patch("drydock-global-resources") }}
{%- endif %}

helmCharts:
- name: kube-prometheus-stack
repo: https://prometheus-community.github.io/helm-charts
version: {{ DRYDOCK_PROMETHEUS_VERSION }}
releaseName: prometheus
includeCRDs: true
{%- if DRYDOCK_PROMETHEUS_VALUES %}
valuesInline:
{{ DRYDOCK_PROMETHEUS_VALUES | indent(4) }}
{%- endif %}
{{ patch("drydock-global-helm-charts") }}

patches:
{{ DRYDOCK_PROMETHEUS_PATCHES }}

0 comments on commit f114243

Please sign in to comment.