feat(prometheus): conditional copy of new configuration from configmap avoiding accid...
[osm/devops.git] / installers / docker / osm_pods / prometheus.yaml
index cdfd94d..93cd20a 100644 (file)
@@ -53,7 +53,7 @@ data:
     # Here it's Prometheus itself.
     scrape_configs:
       # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
-      - job_name: 'prometheus'
+      - job_name: 'mon_exporter'
 
         # metrics_path defaults to '/metrics'
         # scheme defaults to 'http'.
@@ -81,21 +81,36 @@ spec:
       labels:
         app: prometheus
     spec:
+      initContainers:
+      - name: prometheus-init-config
+        image: busybox
+        command: ["/bin/sh", "-c"]
+        args: ['if [ ! -f "/etc/prometheus/prometheus.yml" ]; then cp /etc/prometheus_init/prometheus.yml /etc/prometheus; fi']
+        volumeMounts:
+          - name: prom-config
+            mountPath: /etc/prometheus
+          - name: init-prom-config
+            mountPath: /etc/prometheus_init
       containers:
       - name: prometheus
         image: prom/prometheus:v2.4.3
+        args:
+        - --config.file=/etc/prometheus/prometheus.yml
+        - --web.enable-lifecycle
         ports:
         - containerPort: 9090
           protocol: TCP
         volumeMounts:
         - name: prom-config
-          mountPath: /etc/prometheus/
+          mountPath: /etc/prometheus
         - name: prom-db
           mountPath: /prometheus
       volumes:
-      - configMap:
-          defaultMode: 420
-          name: prom
-        name: prom-config
       - emptyDir: {}
         name: prom-db
+      - name: prom-config
+        hostPath:
+          path: /var/lib/osm/prometheus
+      - name: init-prom-config
+        configMap:
+          name: prom