Skip to content

Commit 8ea899a

Browse files
authored
Merge pull request #6079 from fabriziopandini/improve-deploy_observability-for-Tilt
🌱 improve deploy_observability for Tilt
2 parents 7985c24 + b6efec5 commit 8ea899a

File tree

7 files changed

+44
-29
lines changed

7 files changed

+44
-29
lines changed

Tiltfile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,17 @@ def deploy_provider_crds():
322322
)
323323

324324
def deploy_observability():
325-
k8s_yaml(read_file("./.tiltbuild/yaml/observability.tools.yaml"))
325+
if "promtail" in settings.get("deploy_observability", []):
326+
k8s_yaml(read_file("./.tiltbuild/yaml/promtail.observability.yaml"), allow_duplicates = True)
327+
k8s_resource(workload = "promtail", extra_pod_selectors = [{"app": "promtail"}], labels = ["observability"], resource_deps = ["loki"])
326328

327-
k8s_resource(workload = "promtail", extra_pod_selectors = [{"app": "promtail"}], labels = ["observability"])
328-
k8s_resource(workload = "loki", extra_pod_selectors = [{"app": "loki"}], labels = ["observability"])
329-
k8s_resource(workload = "grafana", port_forwards = "3000", extra_pod_selectors = [{"app": "grafana"}], labels = ["observability"])
329+
if "loki" in settings.get("deploy_observability", []):
330+
k8s_yaml(read_file("./.tiltbuild/yaml/loki.observability.yaml"), allow_duplicates = True)
331+
k8s_resource(workload = "loki", extra_pod_selectors = [{"app": "loki"}], labels = ["observability"])
332+
333+
if "grafana" in settings.get("deploy_observability", []):
334+
k8s_yaml(read_file("./.tiltbuild/yaml/grafana.observability.yaml"), allow_duplicates = True)
335+
k8s_resource(workload = "grafana", port_forwards = "3000", extra_pod_selectors = [{"app": "grafana"}], labels = ["observability"])
330336

331337
def prepare_all():
332338
allow_k8s_arg = ""
@@ -345,8 +351,8 @@ def prepare_all():
345351
# Note: we are creating clusterctl CRDs using kustomize (vs using clusterctl) because we want to create
346352
# a dependency between these resources and provider resources.
347353
kustomize_build_arg = "--kustomize-builds clusterctl.crd:./cmd/clusterctl/config/crd/ "
348-
if settings.get("deploy_observability"):
349-
kustomize_build_arg = kustomize_build_arg + "--kustomize-builds observability.tools:./hack/observability/ "
354+
for tool in settings.get("deploy_observability", []):
355+
kustomize_build_arg = kustomize_build_arg + "--kustomize-builds {tool}.observability:./hack/observability/{tool}/ ".format(tool = tool)
350356
providers_arg = ""
351357
for name in get_providers():
352358
p = providers.get(name)
@@ -382,7 +388,6 @@ prepare_all()
382388

383389
deploy_provider_crds()
384390

385-
if settings.get("deploy_observability"):
386-
deploy_observability()
391+
deploy_observability()
387392

388393
enable_providers()

docs/book/src/developer/tilt.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ for more details.
6666
**kustomize_substitutions** (Map{String: String}, default={}): An optional map of substitutions for `${}`-style placeholders in the
6767
provider's yaml.
6868
69-
**deploy_observability** (Bool, default=false): If set to true, it will instrall grafana, loki and promtail in the dev
70-
cluster. Grafana UI will be accessible via a link in the tilt console.
69+
**deploy_observability** ([string], default=[]): If set, installs on the dev cluster one of more observability
70+
tools. Supported values are `grafana`, `loki` and/or `promtail` (Note: the UI for `grafana` will be accessible via a link in the tilt console).
7171
Important! This feature requires the `helm` command to be available in the user's path.
7272

7373
**debug** (Map{string: Map} default{}): A map of named configurations for the provider. The key is the name of the provider.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
resources:
2+
- ../namespace.yaml
3+
4+
helmCharts:
5+
- name: grafana
6+
repo: https://grafana.github.io/helm-charts
7+
releaseName: grafana
8+
namespace: observability
9+
valuesFile: values.yaml

hack/observability/kustomization.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
resources:
2+
- ../namespace.yaml
3+
4+
helmCharts:
5+
- name: loki
6+
repo: https://grafana.github.io/helm-charts
7+
releaseName: loki
8+
namespace: observability
9+
valuesFile: values.yaml
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
resources:
2+
- ../namespace.yaml
3+
4+
helmCharts:
5+
- name: promtail
6+
repo: https://grafana.github.io/helm-charts
7+
releaseName: promtail
8+
namespace: observability
9+
valuesFile: values.yaml

hack/tools/tilt-prepare/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,8 @@ func kustomizeTask(path, out string) taskFunction {
355355
path,
356356
// enable helm to enable helmChartInflationGenerator.
357357
"--enable-helm",
358+
// to allow picking up resource files from a different folder.
359+
"--load-restrictor=LoadRestrictionsNone",
358360
)
359361

360362
var stdout, stderr bytes.Buffer

0 commit comments

Comments
 (0)