]> git-server-git.apps.pok.os.sepia.ceph.com Git - cephmetrics.git/commitdiff
ansible: Set CPU quotas on containers
authorZack Cerza <zack@redhat.com>
Fri, 4 May 2018 18:04:13 +0000 (12:04 -0600)
committerZack Cerza <zack@redhat.com>
Fri, 4 May 2018 18:04:13 +0000 (12:04 -0600)
We want to default to limiting each container to two cores. While docker
has a nicer way to do this, it isn't supported by ansible as of 2.5.2.
It's easy enough to use the slightly more awkward method, however.

Signed-off-by: Zack Cerza <zack@redhat.com>
ansible/roles/ceph-grafana/defaults/main.yml
ansible/roles/ceph-grafana/tasks/setup_container.yml
ansible/roles/ceph-prometheus/defaults/main.yml
ansible/roles/ceph-prometheus/tasks/setup_container.yml

index 570fc86a28e1406ce42f9ce54a8785df650e5164..b6649c4e13c8d734ea4d0d7accd86a36068a39ce 100644 (file)
@@ -6,6 +6,8 @@ defaults:
   update_alerts: false
   grafana:
     container_name: "grafana/grafana"
+    container_cpu_period: 100000
+    container_cpu_cores: 2
     # version currently only applies to containers
     version: 5.0.4
     datasource: Local
index d8107e2b245b0ee76b6c667a7a4a6d72c4fb3e3a..57ab0718da666634dab570d79f0fa7d0683422ce 100644 (file)
@@ -40,6 +40,8 @@
       - name: "{{ docker.network_name }}"
     keep_volumes: true
     pull: true
+    cpu_period: "{{ grafana.container_cpu_period }}"
+    cpu_quota: "{{ grafana.container_cpu_period * grafana.container_cpu_cores }}"
     env:
       GF_INSTALL_PLUGINS: "{{ grafana.plugins|join(',') }}"
 
index 6e0cbe93020f11cc2869b69e1079308ccac3f372..256d2998930ba5a95c6f095e17f406c0121ab2bf 100644 (file)
@@ -2,6 +2,8 @@
 defaults:
   prometheus:
     container_name: prom/prometheus
+    container_cpu_period: 100000
+    container_cpu_cores: 2
     version: latest
     data_dir: /var/lib/cephmetrics
     user_id: '65534'  # This is the UID used by the prom/prometheus docker image
index 228b95c5801310dc7a79197a0c39ce0d26c01fd6..17622ba58955451e45338acd350dc258d560b79d 100644 (file)
@@ -21,4 +21,8 @@
     user: "{{ prometheus.user_id }}"
     keep_volumes: true
     pull: true
+    cpu_period: "{{ prometheus.container_cpu_period }}"
+    # As of ansible-2.5.2, this module doesn't support the equivalent of the
+    # --cpus flag, so we must use period/quota for now
+    cpu_quota: "{{ prometheus.container_cpu_period * prometheus.container_cpu_cores }}"
   notify: Service handler