Skip to content

Commit

Permalink
Set cluster domain from helm values
Browse files Browse the repository at this point in the history
  • Loading branch information
yahya-hrln committed Oct 31, 2023
1 parent 7964bdd commit dff1800
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions helm/robusta/templates/runner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ spec:
value: {{ .Values.runner.certificate }}
- name: IMAGE_REGISTRY
value: {{ .Values.image.registry }}
- name: CLUSTER_DOMAIN
value: {{ .Values.global.clusterDomain }}
{{- if kindIs "string" .Values.runner.additional_env_vars }}
{{- fail "The `additional_env_vars` string value is deprecated. Change the `additional_env_vars` value to an array" -}}
{{- end }}
Expand Down
5 changes: 4 additions & 1 deletion helm/robusta/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ sinksConfig: []
clusterName: ""
clusterZone: ""

global:
clusterDomain: "cluster.local"

automountServiceAccountToken: true

# see https://docs.robusta.dev/master/user-guide/configuration.html#global-config and https://docs.robusta.dev/master/configuration/additional-settings.html#global-config
Expand Down Expand Up @@ -540,7 +543,7 @@ kube-prometheus-stack:
- name: 'null'
- name: 'robusta'
webhook_configs:
- url: 'http://robusta-runner.{{ .Release.Namespace }}/api/alerts'
- url: 'http://robusta-runner.{{ .Release.Namespace }}.svc.{{ .Values.global.clusterDomain }}/api/alerts'
send_resolved: true
alertmanagerSpec:
resources:
Expand Down
1 change: 1 addition & 0 deletions src/robusta/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
)
from robusta.core.model.env_vars import (
ALERT_BUILDER_WORKERS,
CLUSTER_DOMAIN,
CLUSTER_STATUS_PERIOD_SEC,
CUSTOM_PLAYBOOKS_ROOT,
DEFAULT_PLAYBOOKS_PIP_INSTALL,
Expand Down
2 changes: 2 additions & 0 deletions src/robusta/core/model/env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@ def load_bool(env_var, default: bool):
PROMETHEUS_ERROR_LOG_PERIOD_SEC = int(os.environ.get("DISCOVERY_MAX_BATCHES", 14400))

IMAGE_REGISTRY = os.environ.get("IMAGE_REGISTRY", "us-central1-docker.pkg.dev/genuine-flight-317411/devel")

CLUSTER_DOMAIN = os.environ.get("CLUSTER_DOMAIN", "cluster.local")
4 changes: 3 additions & 1 deletion src/robusta/utils/service_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from kubernetes.client import V1ServiceList
from kubernetes.client.models.v1_service import V1Service

from robusta.core.model.env_vars import CLUSTER_DOMAIN


def find_service_url(label_selector):
"""
Expand All @@ -18,6 +20,6 @@ def find_service_url(label_selector):
name = svc.metadata.name
namespace = svc.metadata.namespace
port = svc.spec.ports[0].port
url = f"http://{name}.{namespace}:{port}"
url = f"http://{name}.{namespace}.svc.{CLUSTER_DOMAIN}:{port}"
logging.info(f"discovered service with label-selector: `{label_selector}` at url: `{url}`")
return url

0 comments on commit dff1800

Please sign in to comment.