Browse Source

Merge "Add prometheus-monitoring namespace"

tags/8.0.0.0rc1
Zuul 7 months ago
parent
commit
62a143c1c1

+ 20
- 0
magnum/drivers/common/templates/kubernetes/fragments/enable-prometheus-monitoring.sh View File

@@ -280,6 +280,19 @@ EOF
280 280
 )
281 281
 writeFile $prometheusService_file "$prometheusService_content"
282 282
 
283
+# Write the file for prometheus-monitoring namespace
284
+prometheusNamespace_file=/srv/magnum/kubernetes/monitoring/prometheusNamespace.yaml
285
+prometheusNamespace_content=$(cat <<EOF
286
+apiVersion: v1
287
+kind: Namespace
288
+metadata:
289
+  labels:
290
+    name: prometheus-monitoring
291
+  name: prometheus-monitoring
292
+EOF
293
+)
294
+writeFile $prometheusNamespace_file "$prometheusNamespace_content"
295
+
283 296
 grafanaService_file=/srv/magnum/kubernetes/monitoring/grafanaService.yaml
284 297
 grafanaService_content=$(cat <<EOF
285 298
 apiVersion: v1
@@ -375,6 +388,13 @@ do
375 388
     sleep 5
376 389
 done
377 390
 
391
+# Check if prometheus-monitoring namespace exist already before creating the namespace
392
+kubectl get namespace prometheus-monitoring
393
+if [ "$?" != "0" ] && \
394
+        [ -f "'''${PROMETHEUS_MON_BASE_DIR}'''/prometheusNamespace.yaml" ]; then
395
+    kubectl create -f  '''${PROMETHEUS_MON_BASE_DIR}'''/prometheusNamespace.yaml
396
+fi
397
+
378 398
 # Check if all resources exist already before creating them
379 399
 # Check if configmap Prometheus exists
380 400
 kubectl get configmap prometheus -n prometheus-monitoring

Loading…
Cancel
Save