Browse Source

Merge pull request #5808 from zgalor/stateful_set

Switch to stateful set in prometheus
Scott Dodson 7 years ago
parent
commit
641445638b

+ 0 - 2
roles/openshift_prometheus/README.md

@@ -17,8 +17,6 @@ For default values, see [`defaults/main.yaml`](defaults/main.yaml).
 - `openshift_prometheus_namespace`: project (i.e. namespace) where the components will be
   deployed.
 
-- `openshift_prometheus_replicas`: The number of replicas for prometheus deployment.
-
 - `openshift_prometheus_node_selector`: Selector for the nodes prometheus will be deployed on.
 
 - `openshift_prometheus_image_<COMPONENT>`: specify image for the component 

+ 2 - 3
roles/openshift_prometheus/defaults/main.yaml

@@ -4,14 +4,13 @@ openshift_prometheus_state: present
 
 openshift_prometheus_namespace: prometheus
 
-openshift_prometheus_replicas: 1
 openshift_prometheus_node_selector: {"region":"infra"}
 
 # images
 openshift_prometheus_image_proxy: "openshift/oauth-proxy:v1.0.0"
-openshift_prometheus_image_prometheus: "openshift/prometheus:v2.0.0-dev"
+openshift_prometheus_image_prometheus: "openshift/prometheus:v2.0.0-dev.3"
 openshift_prometheus_image_alertmanager: "openshift/prometheus-alertmanager:v0.9.1"
-openshift_prometheus_image_alertbuffer: "openshift/prometheus-alert-buffer:v0.0.1"
+openshift_prometheus_image_alertbuffer: "openshift/prometheus-alert-buffer:v0.0.2"
 
 # additional prometheus rules file
 openshift_prometheus_additional_rules_file: null

+ 6 - 6
roles/openshift_prometheus/tasks/install_prometheus.yaml

@@ -145,21 +145,21 @@
     volume_capacity: "{{ openshift_prometheus_alertbuffer_pvc_size }}"
     selector: "{{ openshift_prometheus_alertbuffer_pvc_pv_selector }}"
 
-# create prometheus deployment
-- name: Set prometheus deployment template
+# create prometheus stateful set
+- name: Set prometheus template
   template:
-    src: prometheus_deployment.j2
+    src: prometheus.j2
     dest: "{{ tempdir }}/templates/prometheus.yaml"
   vars:
     namespace: "{{ openshift_prometheus_namespace }}"
-    prom_replicas: "{{ openshift_prometheus_replicas }}"
+#    prom_replicas: "{{ openshift_prometheus_replicas }}"
 
-- name: Set prometheus deployment
+- name: Set prometheus stateful set
   oc_obj:
     state: "{{ state }}"
     name: "prometheus"
     namespace: "{{ openshift_prometheus_namespace }}"
-    kind: deployment
+    kind: statefulset
     files:
       - "{{ tempdir }}/templates/prometheus.yaml"
     delete_after: true

+ 10 - 3
roles/openshift_prometheus/templates/prometheus_deployment.j2

@@ -1,12 +1,14 @@
-apiVersion: extensions/v1beta1
-kind: Deployment
+apiVersion: apps/v1beta1
+kind: StatefulSet
 metadata:
   name: prometheus
   namespace: {{ namespace }}
   labels:
     app: prometheus
 spec:
-  replicas: {{ prom_replicas|default(1) }}
+  updateStrategy:
+    type: RollingUpdate
+  podManagementPolicy: Parallel
   selector:
     provider: openshift
     matchLabels:
@@ -60,6 +62,8 @@ spec:
         - -tls-key=/etc/tls/private/tls.key
         - -client-secret-file=/var/run/secrets/kubernetes.io/serviceaccount/token
         - -cookie-secret-file=/etc/proxy/secrets/session_secret
+        - -openshift-ca=/etc/pki/tls/cert.pem
+        - -openshift-ca=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
         - -skip-auth-regex=^/metrics
         volumeMounts:
         - mountPath: /etc/tls/private
@@ -72,6 +76,7 @@ spec:
       - name: prometheus
         args:
         - --storage.tsdb.retention=6h
+        - --storage.tsdb.min-block-duration=2m
         - --config.file=/etc/prometheus/prometheus.yml
         - --web.listen-address=localhost:9090
         image: "{{ openshift_prometheus_image_prometheus }}"
@@ -133,6 +138,8 @@ spec:
         - -tls-key=/etc/tls/private/tls.key
         - -client-secret-file=/var/run/secrets/kubernetes.io/serviceaccount/token
         - -cookie-secret-file=/etc/proxy/secrets/session_secret
+        - -openshift-ca=/etc/pki/tls/cert.pem
+        - -openshift-ca=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
         volumeMounts:
         - mountPath: /etc/tls/private
           name: alerts-tls