Skip to content

Commit a81faf2

Browse files
committed
chore(grafana): simplify the connection controller
1 parent 3c64fd1 commit a81faf2

7 files changed

Lines changed: 14 additions & 20 deletions

File tree

charts/grafana/templates/_helpers.tmpl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,19 @@ env:
1919
name: valkey-creds
2020
key: password
2121
- name: DRYCC_VALKEY_URL
22-
value: "redis://:$(DRYCC_VALKEY_PASSWORD)@drycc-valkey.{{.Release.Namespace}}.svc.{{.Values.global.clusterDomain}}:16379/0"
22+
value: "redis://:$(DRYCC_VALKEY_PASSWORD)@drycc-valkey:16379/0"
2323
{{- end }}
2424
- name: DRYCC_SERVICE_KEY
2525
valueFrom:
2626
secretKeyRef:
2727
name: controller-creds
2828
key: service-key
29+
- name: "DRYCC_CONTROLLER_URL"
30+
value: http://drycc-controller-api
2931
- name: "DRYCC_QUICKWIT_URL"
30-
value: "http://$(DRYCC_CONTROLLER_API_SERVICE_HOST):$(DRYCC_CONTROLLER_API_SERVICE_PORT)/v2/quickwit/drycc"
32+
value: "$(DRYCC_CONTROLLER_URL)/v2/quickwit/drycc"
3133
- name: "DRYCC_VICTORIAMETRICS_URL"
32-
value: "http://$(DRYCC_CONTROLLER_API_SERVICE_HOST):$(DRYCC_CONTROLLER_API_SERVICE_PORT)/v2/prometheus/drycc"
34+
value: "$(DRYCC_CONTROLLER_URL)/v2/prometheus/drycc"
3335
{{- if .Values.passport.enabled}}
3436
- name: "DRYCC_PASSPORT_URL"
3537
{{- if .Values.global.certManagerEnabled }}
@@ -72,7 +74,7 @@ env:
7274
name: database-creds
7375
key: password
7476
- name: GF_DATABASE_URL
75-
value: "postgres://$(GF_DATABASE_USER):$(GF_DATABASE_PASSWORD)@drycc-database.{{.Release.Namespace}}.svc.{{.Values.global.clusterDomain}}:5432/grafana"
77+
value: "postgres://$(GF_DATABASE_USER):$(GF_DATABASE_PASSWORD)@drycc-database:5432/grafana"
7678
{{- end }}
7779
- name: "GF_SECURITY_ADMIN_USER"
7880
valueFrom:
@@ -91,7 +93,7 @@ env:
9193
value: http://drycc-grafana.{{ .Values.global.platformDomain }}
9294
{{- end}}
9395
- name: GF_UNIFIED_ALERTING_HA_PEERS
94-
value: "drycc-grafana.{{.Release.Namespace}}.svc.{{.Values.global.clusterDomain}}:9094"
96+
value: "drycc-grafana:9094"
9597
- name: GF_UNIFIED_ALERTING_HA_ADVERTISE_ADDRESS
9698
value: "$(POD_IP):9094"
9799
{{- range $key, $value := .Values.environment }}

charts/grafana/values.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ victoriametrics:
9595
enabled: true
9696

9797
global:
98-
# A domain name consists of one or more parts.
99-
# Periods (.) are used to separate these parts.
100-
# Each part must be 1 to 63 characters in length and can contain lowercase letters, digits, and hyphens (-).
101-
# It must start and end with a lowercase letter or digit.
102-
clusterDomain: "cluster.local"
10398
# The public resolvable hostname to build your cluster with.
10499
#
105100
# This will be the hostname that is used to build endpoints such as "drycc.$HOSTNAME"

rootfs/usr/share/grafana/oauth2/datasources/prometheus.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Prometheus on Drycc",
33
"type": "prometheus",
4-
"url": "${controller_api_url}/v2/prometheus/${username}",
4+
"url": "${controller_url}/v2/prometheus/${username}",
55
"access": "proxy",
66
"isDefault": true,
77
"basicAuth": false,

rootfs/usr/share/grafana/oauth2/datasources/quickwit.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Application Logs",
33
"type": "quickwit-quickwit-datasource",
4-
"url": "${controller_api_url}/v2/quickwit/${username}",
4+
"url": "${controller_url}/v2/quickwit/${username}",
55
"access": "proxy",
66
"basicAuth": false,
77
"jsonData": {
Binary file not shown.
Binary file not shown.

rootfs/usr/share/grafana/oauth2/hook/grafana.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
from psycopg import AsyncConnection
66

77
DEFAULT_HEADERS = {"Content-Type": "application/json"}
8+
DRYCC_CONTROLLER_URL = os.environ.get('DRYCC_CONTROLLER_URL')
89
DRYCC_GRAFANA_REFRESH = os.environ.get('DRYCC_GRAFANA_REFRESH', '60s')
9-
DRYCC_CONTROLLER_API_URL = "http://{}:{}".format(
10-
os.environ.get('DRYCC_CONTROLLER_API_SERVICE_HOST'),
11-
os.environ.get('DRYCC_CONTROLLER_API_SERVICE_PORT'),
12-
)
1310
DRYCC_GRAFANA_DASHBOARD = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../")
1411

1512

@@ -106,14 +103,14 @@ async def sync_datasources(context: dict, token: dict, userinfo: dict):
106103
with open(os.path.join(datasources_path, filename)) as f:
107104
template = Template(f.read())
108105
datasource = json.loads(template.substitute(
109-
controller_api_url=DRYCC_CONTROLLER_API_URL,
106+
controller_url=DRYCC_CONTROLLER_URL,
110107
username=userinfo["preferred_username"],
111108
time_interval=DRYCC_GRAFANA_REFRESH,
112109
token=drycc_token
113110
))
114111
resp = await client.get(
115112
api_url(f"/api/datasources/name/{datasource["name"]}"), headers=headers)
116-
if resp.status_code == 200:
113+
if resp.status_code == 200:
117114
if created:
118115
datasource = resp.json()
119116
datasource["secureJsonData"] = {
@@ -166,13 +163,13 @@ async def _check_or_create_drycc_token(drycc_token, token):
166163
if drycc_token:
167164
headers = {"Authorization": f"Token {drycc_token}"}
168165
resp = await client.get(
169-
f"{DRYCC_CONTROLLER_API_URL}/v2/auth/whoami", headers=headers)
166+
f"{DRYCC_CONTROLLER_URL}/v2/auth/whoami", headers=headers)
170167
if resp.status_code in [401, 403]:
171168
created = True
172169
if created:
173170
headers = {"Authorization": f"Bearer {token["access_token"]}"}
174171
data = (await client.post(
175-
f"{DRYCC_CONTROLLER_API_URL}/v2/auth/token/?alias=grafana-datasource",
172+
f"{DRYCC_CONTROLLER_URL}/v2/auth/token/?alias=grafana-datasource",
176173
headers=headers, json=token)).json()
177174
drycc_token = data["token"]
178175
return created, drycc_token

0 commit comments

Comments
 (0)