diff --git a/Tiltfile b/Tiltfile index 32dcd46078c7..ede9c0b4fa00 100644 --- a/Tiltfile +++ b/Tiltfile @@ -322,11 +322,17 @@ def deploy_provider_crds(): ) def deploy_observability(): - k8s_yaml(read_file("./.tiltbuild/yaml/observability.tools.yaml")) + if "promtail" in settings.get("deploy_observability", []): + k8s_yaml(read_file("./.tiltbuild/yaml/promtail.observability.yaml"), allow_duplicates=True) + k8s_resource(workload = "promtail", extra_pod_selectors = [{"app": "promtail"}], labels = ["observability"], resource_deps = ["loki"]) - k8s_resource(workload = "promtail", extra_pod_selectors = [{"app": "promtail"}], labels = ["observability"]) - k8s_resource(workload = "loki", extra_pod_selectors = [{"app": "loki"}], labels = ["observability"]) - k8s_resource(workload = "grafana", port_forwards = "3000", extra_pod_selectors = [{"app": "grafana"}], labels = ["observability"]) + if "loki" in settings.get("deploy_observability", []): + k8s_yaml(read_file("./.tiltbuild/yaml/loki.observability.yaml"), allow_duplicates=True) + k8s_resource(workload = "loki", extra_pod_selectors = [{"app": "loki"}], labels = ["observability"]) + + if "grafana" in settings.get("deploy_observability", []): + k8s_yaml(read_file("./.tiltbuild/yaml/grafana.observability.yaml"), allow_duplicates=True) + k8s_resource(workload = "grafana", port_forwards = "3000", extra_pod_selectors = [{"app": "grafana"}], labels = ["observability"]) def prepare_all(): allow_k8s_arg = "" @@ -345,8 +351,8 @@ def prepare_all(): # Note: we are creating clusterctl CRDs using kustomize (vs using clusterctl) because we want to create # a dependency between these resources and provider resources. kustomize_build_arg = "--kustomize-builds clusterctl.crd:./cmd/clusterctl/config/crd/ " - if settings.get("deploy_observability"): - kustomize_build_arg = kustomize_build_arg + "--kustomize-builds observability.tools:./hack/observability/ " + for tool in settings.get("deploy_observability", []): + kustomize_build_arg = kustomize_build_arg + "--kustomize-builds {tool}.observability:./hack/observability/{tool}/ ".format(tool = tool) providers_arg = "" for name in get_providers(): p = providers.get(name) @@ -382,7 +388,6 @@ prepare_all() deploy_provider_crds() -if settings.get("deploy_observability"): - deploy_observability() +deploy_observability() enable_providers() diff --git a/docs/book/src/developer/tilt.md b/docs/book/src/developer/tilt.md index 100881d47e77..dc5c17fff8e7 100644 --- a/docs/book/src/developer/tilt.md +++ b/docs/book/src/developer/tilt.md @@ -79,8 +79,8 @@ for more details. **kustomize_substitutions** (Map{String: String}, default={}): An optional map of substitutions for `${}`-style placeholders in the provider's yaml. -**deploy_observability** (Bool, default=false): If set to true, it will instrall grafana, loki and promtail in the dev -cluster. Grafana UI will be accessible via a link in the tilt console. +**deploy_observability** ([string], default=[]): If set, it will install in the dev cluster one of more observability +tools between `grafana`, `loki` or `promtail` (Note: the UI for `grafana` will be accessible via a link in the tilt console). Important! This feature requires the `helm` command to be available in the user's path. **debug** (Map{string: Map} default{}): A map of named configurations for the provider. The key is the name of the provider. diff --git a/hack/observability/grafana/kustomization.yaml b/hack/observability/grafana/kustomization.yaml new file mode 100644 index 000000000000..efee13fe2223 --- /dev/null +++ b/hack/observability/grafana/kustomization.yaml @@ -0,0 +1,9 @@ +resources: + - ../namespace.yaml + +helmCharts: + - name: grafana + repo: https://grafana.github.io/helm-charts + releaseName: grafana + namespace: observability + valuesFile: values.yaml diff --git a/hack/observability/kustomization.yaml b/hack/observability/kustomization.yaml deleted file mode 100644 index 7d238084ea67..000000000000 --- a/hack/observability/kustomization.yaml +++ /dev/null @@ -1,19 +0,0 @@ -resources: - - namespace.yaml - -helmCharts: - - name: promtail - repo: https://grafana.github.io/helm-charts - releaseName: promtail - namespace: observability - valuesFile: ./promtail/values.yaml - - name: loki - repo: https://grafana.github.io/helm-charts - releaseName: loki - namespace: observability - valuesFile: ./loki/values.yaml - - name: grafana - repo: https://grafana.github.io/helm-charts - releaseName: grafana - namespace: observability - valuesFile: ./grafana/values.yaml diff --git a/hack/observability/loki/kustomization.yaml b/hack/observability/loki/kustomization.yaml new file mode 100644 index 000000000000..1462fa75bb7a --- /dev/null +++ b/hack/observability/loki/kustomization.yaml @@ -0,0 +1,9 @@ +resources: + - ../namespace.yaml + +helmCharts: + - name: loki + repo: https://grafana.github.io/helm-charts + releaseName: loki + namespace: observability + valuesFile: values.yaml diff --git a/hack/observability/promtail/kustomization.yaml b/hack/observability/promtail/kustomization.yaml new file mode 100644 index 000000000000..7233ed2e4d95 --- /dev/null +++ b/hack/observability/promtail/kustomization.yaml @@ -0,0 +1,9 @@ +resources: + - ../namespace.yaml + +helmCharts: + - name: promtail + repo: https://grafana.github.io/helm-charts + releaseName: promtail + namespace: observability + valuesFile: values.yaml diff --git a/hack/tools/tilt-prepare/main.go b/hack/tools/tilt-prepare/main.go index 1dfee9eba407..bcffe45732e7 100644 --- a/hack/tools/tilt-prepare/main.go +++ b/hack/tools/tilt-prepare/main.go @@ -355,6 +355,8 @@ func kustomizeTask(path, out string) taskFunction { path, // enable helm to enable helmChartInflationGenerator. "--enable-helm", + // to allow picking up resource files from a different folder. + "--load-restrictor=LoadRestrictionsNone", ) var stdout, stderr bytes.Buffer