Browse Source

set replicas to current value so not to disrupt current pods (#13)

Jeff Cantrill 8 years ago
parent
commit
b097d9f595

+ 20 - 0
roles/openshift_metrics/tasks/install_hawkular.yaml

@@ -1,8 +1,27 @@
 ---
+- shell: >
+    {{ openshift.common.client_binary }} -n {{ openshift_metrics_project }}
+    --config={{ mktemp.stdout }}/admin.kubeconfig
+    get rc hawkular-metrics --template=\{\{.spec.replicas\}\} || echo 0
+  register: hawkular_metrics_replica_count
+  changed_when: false
+
 - name: generate hawkular-metrics replication controller
   template:
     src: hawkular_metrics_rc.j2
     dest: "{{ mktemp.stdout }}/templates/hawkular_metrics_rc.yaml"
+  vars:
+     replica_count: "{{hawkular_metrics_replica_count.stdout}}"
+
+- shell: >
+    {{ openshift.common.client_binary }} -n {{ openshift_metrics_project }}
+    --config={{ mktemp.stdout }}/admin.kubeconfig
+    get rc hawkular-cassandra-{{node}} --template=\{\{.spec.replicas\}\} || echo 0
+  vars:
+    node: "{{ item }}"
+  register: cassandra_replica_count
+  changed_when: false
+  with_sequence: count={{ openshift_metrics_cassandra_replicas }}
 
 - name: generate hawkular-cassandra replication controllers
   template:
@@ -11,6 +30,7 @@
   vars:
     node: "{{ item }}"
     master: "{{ (item == '1')|string|lower }}"
+    replica_count: "{{cassandra_replica_count.results[item|int - 1].stdout}}"
   with_sequence: count={{ openshift_metrics_cassandra_replicas }}
 
 - name: generate hawkular-cassandra persistent volume claims

+ 9 - 0
roles/openshift_metrics/tasks/install_heapster.yaml

@@ -1,3 +1,12 @@
 ---
+- shell: >
+    {{ openshift.common.client_binary }} -n {{ openshift_metrics_project }}
+    --config={{ mktemp.stdout }}/admin.kubeconfig
+    get rc heapster --template=\{\{.spec.replicas\}\} || echo 0
+  register: heapster_replica_count
+  changed_when: false
+
 - name: Generate heapster replication controller
   template: src=heapster.j2 dest={{mktemp.stdout}}/templates/metrics-heapster-rc.yaml
+  vars:
+    replica_count: "{{heapster_replica_count.stdout}}"

+ 1 - 1
roles/openshift_metrics/templates/hawkular_cassandra_rc.j2

@@ -9,7 +9,7 @@ metadata:
 spec:
   selector:
     name: hawkular-cassandra-{{ node }}
-  replicas: 0
+  replicas: {{replica_count}}
   template:
     version: v1
     metadata:

+ 1 - 1
roles/openshift_metrics/templates/hawkular_metrics_rc.j2

@@ -8,7 +8,7 @@ metadata:
 spec:
   selector:
     name: hawkular-metrics
-  replicas: 0
+  replicas: {{replica_count}}
   template:
     version: v1
     metadata:

+ 1 - 1
roles/openshift_metrics/templates/heapster.j2

@@ -8,7 +8,7 @@ metadata:
 spec:
   selector:
     name: heapster
-  replicas: 0
+  replicas: {{replica_count}}
   template:
     version: v1
     metadata: