Skip to content

Commit dfc87fc

Browse files
authored
[grafana] encode azure monitor in grafana yaml (#14106)
I've already deployed to the cluster to test. Unless master deploys, you can see it here: https://grafana.azure.hail.is/datasources/edit/kgzY5Io7k I also fixed the grafana Makefile.
1 parent caea515 commit dfc87fc

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

config.mk

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ endif
1010

1111
DOMAIN = $(eval DOMAIN := $$(shell kubectl -n $(NAMESPACE) get secret global-config --template={{.data.domain}} | base64 --decode))$(DOMAIN)
1212
CLOUD = $(eval CLOUD := $$(shell kubectl -n $(NAMESPACE) get secret global-config --template={{.data.cloud}} | base64 --decode))$(CLOUD)
13+
AZURE_SUBSCRIPTION_ID = $(eval AZURE_SUBSCRIPTION_ID := $$(shell kubectl -n $(NAMESPACE) get secret global-config --template={{.data.azure_subscription_id}} | base64 --decode))$(AZURE_SUBSCRIPTION_ID)
1314

1415
ifeq ($(NAMESPACE),default)
1516
SCOPE = deploy

grafana/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ include ../config.mk
55
CLOUD := $(shell kubectl get secret global-config --template={{.data.cloud}} | base64 --decode)
66

77
build:
8-
$(MAKE) -C .. hail-ubuntu-image
8+
$(MAKE) -C .. pushed-private-hail-ubuntu-image
99

1010
deploy: build
1111
! [ -z $(NAMESPACE) ] # call this like: make deploy NAMESPACE=default
12-
python3 ../ci/jinja2_render.py '{"deploy":$(DEPLOY),"global": {"cloud": "$(CLOUD)", "domain": "$(DOMAIN)", "docker_prefix":"$(DOCKER_PREFIX)"},"default_ns":{"name":"$(NAMESPACE)"},"hail_ubuntu_image":{"image":"'$$(cat ../hail-ubuntu-image)'"}}' deployment.yaml deployment.yaml.out
12+
python3 ../ci/jinja2_render.py '{"deploy":$(DEPLOY),"global": {"cloud": "$(CLOUD)", "domain": "$(DOMAIN)", "docker_prefix":"$(DOCKER_PREFIX)","azure_subscription_id":"$(AZURE_SUBSCRIPTION_ID)"},"default_ns":{"name":"$(NAMESPACE)"},"hail_ubuntu_image":{"image":"'$$(cat ../pushed-private-hail-ubuntu-image)'"}}' deployment.yaml deployment.yaml.out
1313
kubectl -n $(NAMESPACE) apply -f deployment.yaml.out

grafana/deployment.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ spec:
155155
- name: grafana-envoy-sidecar-config
156156
configMap:
157157
name: grafana-envoy-sidecar-config
158+
- name: grafana-gsa-key
159+
secret:
160+
secretName: grafana-gsa-key
158161
initContainers:
159162
- name: setup-tokens
160163
image: {{ hail_ubuntu_image.image }}
@@ -165,6 +168,20 @@ spec:
165168
name: grafana-tokens
166169
- mountPath: /grafana-shared
167170
name: grafana-shared
171+
- name: setup-grafana-gsa-key
172+
image: {{ hail_ubuntu_image.image }}
173+
command: ["/bin/bash"]
174+
args:
175+
- "-c"
176+
- |
177+
jq -r '.tenant' /grafana-gsa-key/key.json > /grafana-shared/tenant-id
178+
jq -r '.appId' /grafana-gsa-key/key.json > /grafana-shared/app-id
179+
jq -r '.password' /grafana-gsa-key/key.json > /grafana-shared/client-secret
180+
volumeMounts:
181+
- mountPath: /grafana-gsa-key
182+
name: grafana-gsa-key
183+
- mountPath: /grafana-shared
184+
name: grafana-shared
168185
containers:
169186
- name: grafana
170187
image: {{ global.docker_prefix }}/grafana/grafana:9.1.4
@@ -284,6 +301,19 @@ data:
284301
authenticationType: gce
285302
defaultProject: $GCP_PROJECT
286303
editable: true
304+
{% elif global.cloud == "azure" %}
305+
- name: Azure Monitor
306+
type: grafana-azure-monitor-datasource
307+
access: proxy
308+
jsonData:
309+
azureAuthType: clientsecret
310+
cloudName: azuremonitor
311+
tenantId: $__file{/grafana-shared/tenant-id}
312+
clientId: $__file{/grafana-shared/app-id}
313+
subscriptionId: {{ global.azure_subscription_id }}
314+
secureJsonData:
315+
clientSecret: $__file{/grafana-shared/client-secret}
316+
version: 1
287317
{% endif %}
288318
- name: Prometheus
289319
type: prometheus

0 commit comments

Comments
 (0)