diff --git a/drydock/manifest_builder/infrastructure/tutor_based_manifests.py b/drydock/manifest_builder/infrastructure/tutor_based_manifests.py index c28f2f36..1baad53d 100644 --- a/drydock/manifest_builder/infrastructure/tutor_based_manifests.py +++ b/drydock/manifest_builder/infrastructure/tutor_based_manifests.py @@ -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) diff --git a/drydock/manifest_builder/infrastructure/tutor_config.py b/drydock/manifest_builder/infrastructure/tutor_config.py index 2328a19f..6f49e282 100644 --- a/drydock/manifest_builder/infrastructure/tutor_config.py +++ b/drydock/manifest_builder/infrastructure/tutor_config.py @@ -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" diff --git a/drydock/templates/kustomized/global-stack/defaults.yml b/drydock/templates/kustomized/global-stack/defaults.yml new file mode 100644 index 00000000..ac5c90a9 --- /dev/null +++ b/drydock/templates/kustomized/global-stack/defaults.yml @@ -0,0 +1,5 @@ +DRYDOCK_GLOBAL_STACK_NAMESPACE: "monitoring" +DRYDOCK_PROMETHEUS_VALUES: "" +DRYDOCK_PROMETHEUS_PATCHES: "" +DRYDOCK_GLOBAL_RESOURCES: "" +DRYDOCK_PROMETHEUS_VERSION: 39.4.0 diff --git a/drydock/templates/kustomized/global-stack/kustomization.yml b/drydock/templates/kustomized/global-stack/kustomization.yml new file mode 100644 index 00000000..a34c3b24 --- /dev/null +++ b/drydock/templates/kustomized/global-stack/kustomization.yml @@ -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 }}