]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
container: introduce resource limitation for containers 1859/head
authorSébastien Han <seb@redhat.com>
Wed, 6 Sep 2017 08:53:30 +0000 (10:53 +0200)
committerSébastien Han <seb@redhat.com>
Wed, 6 Sep 2017 12:52:21 +0000 (14:52 +0200)
This can be controlled via 2 options:

* ceph_$DAEMON_docker_memory_limit
* ceph_$DAEMON_docker_cpu_limit

All daemons default to 1GB for memory and 1 CPU by default.
Recommendations from:
https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/2/html/red_hat_ceph_storage_hardware_guide/minimum_recommendations

Signed-off-by: Sébastien Han <seb@redhat.com>
19 files changed:
group_vars/mdss.yml.sample
group_vars/mgrs.yml.sample
group_vars/mons.yml.sample
group_vars/osds.yml.sample
group_vars/rbd-mirrors.yml.sample
group_vars/rgws.yml.sample
roles/ceph-docker-common/tasks/main.yml
roles/ceph-mds/defaults/main.yml
roles/ceph-mds/templates/ceph-mds.service.j2
roles/ceph-mgr/defaults/main.yml
roles/ceph-mgr/templates/ceph-mgr.service.j2
roles/ceph-mon/defaults/main.yml
roles/ceph-mon/templates/ceph-mon.service.j2
roles/ceph-osd/defaults/main.yml
roles/ceph-osd/templates/ceph-osd-run.sh.j2
roles/ceph-rbd-mirror/defaults/main.yml
roles/ceph-rbd-mirror/templates/ceph-rbd-mirror.service.j2
roles/ceph-rgw/defaults/main.yml
roles/ceph-rgw/templates/ceph-radosgw.service.j2

index aced2742d1cb116b63f6dbbaef1698fb3dcc1729..4dbf4e795acedf41a2bcf5a7748183a88d3521c1 100644 (file)
@@ -25,6 +25,13 @@ dummy:
 # DOCKER #
 ##########
 
+# Resource limitation
+# For the whole list of limits you can apply see: docs.docker.com/engine/admin/resource_constraints
+# Default values are based from: https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/2/html/red_hat_ceph_storage_hardware_guide/minimum_recommendations
+# These options can be passed using the 'ceph_mds_docker_extra_env' variable.
+#ceph_mds_docker_memory_limit: 1g
+#ceph_mds_docker_cpu_limit: 1
+
 #ceph_mds_docker_extra_env: -e CLUSTER={{ cluster }} -e MDS_NAME={{ ansible_hostname }}
 #ceph_config_keys: [] # DON'T TOUCH ME
 
index 0422383dc36eb2e46515436817ef8186c3cff0f9..d82d3b0674c15d3f1c00b9d631f778947cc4fd7e 100644 (file)
@@ -11,6 +11,13 @@ dummy:
 # DOCKER #
 ##########
 
+# Resource limitation
+# For the whole list of limits you can apply see: docs.docker.com/engine/admin/resource_constraints
+# Default values are based from: https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/2/html/red_hat_ceph_storage_hardware_guide/minimum_recommendations
+# These options can be passed using the 'ceph_mgr_docker_extra_env' variable.
+#ceph_mgr_docker_memory_limit: 1g
+#ceph_mgr_docker_cpu_limit: 1
+
 #ceph_mgr_docker_extra_env: -e CLUSTER={{ cluster }} -e MGR_NAME={{ ansible_hostname }}
 #ceph_config_keys: [] # DON'T TOUCH ME
 
index 7afc6417d08fdfe360c640fc169f17f9ff2e7844..ccdaa177d75a9ee7137b42a648c7948cbbc83e9c 100644 (file)
@@ -100,7 +100,7 @@ dummy:
 # The value for 'key' can be a pre-generated key,
 # e.g key: "AQDC2UxZH4yeLhAAgTaZb+4wDUlYOsr1OfZSpQ=="
 # By default, keys will be auto-generated.
-# 
+#
 # To have have ansible setfacl the generated key, set the acls var like so:
 # acls: ["u:nova:r--", "u:cinder:r--", "u:glance:r--", "u:gnocchi:r--"]
 #openstack_keys:
@@ -115,6 +115,13 @@ dummy:
 ##########
 #ceph_mon_docker_subnet: "{{ public_network }}"# subnet of the monitor_interface
 
+# Resource limitation
+# For the whole list of limits you can apply see: docs.docker.com/engine/admin/resource_constraints
+# Default values are based from: https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/2/html/red_hat_ceph_storage_hardware_guide/minimum_recommendations
+# These options can be passed using the 'ceph_mon_docker_extra_env' variable.
+#ceph_mon_docker_memory_limit: 1g
+#ceph_mon_docker_cpu_limit: 1
+
 # ceph_mon_docker_extra_env:
 #
 # Use this variable to add extra env configuration to run your mon container.
index 777a5615b066936c92f23095d092f696c72836e9..985fd12a8ba7d099218cded1db45603a98d65b06 100644 (file)
@@ -226,6 +226,13 @@ dummy:
 
 #ceph_config_keys: [] # DON'T TOUCH ME
 
+# Resource limitation
+# For the whole list of limits you can apply see: docs.docker.com/engine/admin/resource_constraints
+# Default values are based from: https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/2/html/red_hat_ceph_storage_hardware_guide/minimum_recommendations
+# These options can be passed using the 'ceph_osd_docker_extra_env' variable.
+#ceph_osd_docker_memory_limit: 1g
+#ceph_osd_docker_cpu_limit: 1
+
 # PREPARE DEVICE
 #
 # WARNING /!\ DMCRYPT scenario ONLY works with Docker version 1.12.5 and above
index 994eb98b4e3d9ea9e82fda7c24f20aaa6d550fdd..b680b054c957b8279789bd8505b63e950bde4390 100644 (file)
@@ -23,6 +23,7 @@ dummy:
 # NOTE: deprecated generic local user id for pre-Luminous releases
 #ceph_rbd_mirror_local_user: "admin"
 
+
 #################
 # CONFIGURATION #
 #################
@@ -41,10 +42,19 @@ dummy:
 # /etc/ceph/<remote_cluster>.client.<remote_user>.keyring
 #ceph_rbd_mirror_remote_user: ""
 
+
 ##########
 # DOCKER #
 ##########
 
+# Resource limitation
+# For the whole list of limits you can apply see: docs.docker.com/engine/admin/resource_constraints
+# Default values are based from: https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/2/html/red_hat_ceph_storage_hardware_guide/minimum_recommendations
+# These options can be passed using the 'ceph_rbd_mirror_docker_extra_env' variable.
+#ceph_rbd_mirror_docker_memory_limit: 1g
+#ceph_rbd_mirror_docker_cpu_limit: 1
+
+#ceph_rbd_mirror_docker_extra_env:
 #ceph_config_keys: [] # DON'T TOUCH ME
 
 
index 2f99453497b207388f71c70a67ac29c9ca5c5424..164e51016acac96da44d7b977228c19eda97690d 100644 (file)
@@ -57,6 +57,13 @@ dummy:
 # DOCKER #
 ##########
 
+# Resource limitation
+# For the whole list of limits you can apply see: docs.docker.com/engine/admin/resource_constraints
+# Default values are based from: https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/2/html/red_hat_ceph_storage_hardware_guide/minimum_recommendations
+# These options can be passed using the 'ceph_rgw_docker_extra_env' variable.
+#ceph_rgw_docker_memory_limit: 1g
+#ceph_rgw_docker_cpu_limit: 1
+
 #ceph_rgw_docker_extra_env:
 #ceph_config_keys: [] # DON'T TOUCH ME
 #rgw_config_keys: "/" # DON'T TOUCH ME
index 9c16f5d62c7634fc18047743f2ef94de5612928d..73003ed87205ff240b6c1c14fcfe14f39daab859 100644 (file)
     monitor_name: "{{ ansible_fqdn }}"
   when: mon_use_fqdn
 
+- name: get docker version
+  command: docker --version
+  changed_when: false
+  always_run: yes
+  register: docker_version
+
+- set_fact:
+    docker_version: "{{ docker_version.stdout.split(' ')[2] }}"
+
 - name: check if a cluster is already running
   command: "docker ps -q -a --filter='ancestor={{ ceph_docker_image }}:{{ ceph_docker_image_tag }}'"
   register: ceph_health
index bd87d1c6f575615658010256400291a5a4ce9cf2..9d8fbbd43570300c22582d8cdff6067a91ff3c80 100644 (file)
@@ -17,6 +17,13 @@ copy_admin_key: false
 # DOCKER #
 ##########
 
+# Resource limitation
+# For the whole list of limits you can apply see: docs.docker.com/engine/admin/resource_constraints
+# Default values are based from: https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/2/html/red_hat_ceph_storage_hardware_guide/minimum_recommendations
+# These options can be passed using the 'ceph_mds_docker_extra_env' variable.
+ceph_mds_docker_memory_limit: 1g
+ceph_mds_docker_cpu_limit: 1
+
 ceph_mds_docker_extra_env: -e CLUSTER={{ cluster }} -e MDS_NAME={{ ansible_hostname }}
 ceph_config_keys: [] # DON'T TOUCH ME
 
index 6c901a7183964b584155ebeda2afd3e64862c15e..0d99e5314e103e9128dd037588568f792a0bb0b1 100644 (file)
@@ -7,20 +7,26 @@ EnvironmentFile=-/etc/environment
 ExecStartPre=-/usr/bin/docker stop ceph-mds-{{ ansible_hostname }}
 ExecStartPre=-/usr/bin/docker rm ceph-mds-{{ ansible_hostname }}
 ExecStart=/usr/bin/docker run --rm --net=host \
-   {% if not containerized_deployment_with_kv -%}
-   -v /var/lib/ceph:/var/lib/ceph \
-   -v /etc/ceph:/etc/ceph \
-   {% else -%}
-   -e KV_TYPE={{kv_type}} \
-   -e KV_IP={{kv_endpoint}} \
-   -e KV_PORT={{kv_port}} \
-   {% endif -%}
-   -v /etc/localtime:/etc/localtime:ro \
-   -e CEPH_DAEMON=MDS \
-   -e CEPHFS_CREATE=1 \
-   {{ ceph_mds_docker_extra_env }} \
-   --name=ceph-mds-{{ ansible_hostname }} \
-   {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
+  --memory={{ ceph_mds_docker_memory_limit }} \
+  {% if docker_version.split('.')[0] | version_compare('13', '>=') -%}
+  --cpus={{ ceph_mds_docker_cpu_limit }} \
+  {% else -%}
+  --cpu-quota={{ ceph_mds_docker_cpu_limit * 100000 }} \
+  {% endif -%}
+  {% if not containerized_deployment_with_kv -%}
+  -v /var/lib/ceph:/var/lib/ceph \
+  -v /etc/ceph:/etc/ceph \
+  {% else -%}
+  -e KV_TYPE={{kv_type}} \
+  -e KV_IP={{kv_endpoint}} \
+  -e KV_PORT={{kv_port}} \
+  {% endif -%}
+  -v /etc/localtime:/etc/localtime:ro \
+  -e CEPH_DAEMON=MDS \
+  -e CEPHFS_CREATE=1 \
+  {{ ceph_mds_docker_extra_env }} \
+  --name=ceph-mds-{{ ansible_hostname }} \
+  {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
 ExecStopPost=-/usr/bin/docker stop ceph-mds-{{ ansible_hostname }}
 Restart=always
 RestartSec=10s
index a0166404eb1ab3065f7e4e4f20e9b631d4c9170b..78a83fd35925fe2984660282d9225b25f8a91c7b 100644 (file)
@@ -3,6 +3,13 @@
 # DOCKER #
 ##########
 
+# Resource limitation
+# For the whole list of limits you can apply see: docs.docker.com/engine/admin/resource_constraints
+# Default values are based from: https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/2/html/red_hat_ceph_storage_hardware_guide/minimum_recommendations
+# These options can be passed using the 'ceph_mgr_docker_extra_env' variable.
+ceph_mgr_docker_memory_limit: 1g
+ceph_mgr_docker_cpu_limit: 1
+
 ceph_mgr_docker_extra_env: -e CLUSTER={{ cluster }} -e MGR_NAME={{ ansible_hostname }}
 ceph_config_keys: [] # DON'T TOUCH ME
 
index 02cbd96ebf580c107414053cd7264f37a8a7b5d9..5aecf4ce31831325e56baf551a21d7bb258df96b 100644 (file)
@@ -7,19 +7,25 @@ EnvironmentFile=-/etc/environment
 ExecStartPre=-/usr/bin/docker stop ceph-mgr-{{ ansible_hostname }}
 ExecStartPre=-/usr/bin/docker rm ceph-mgr-{{ ansible_hostname }}
 ExecStart=/usr/bin/docker run --rm --net=host \
-   {% if not containerized_deployment_with_kv -%}
-   -v /var/lib/ceph:/var/lib/ceph \
-   -v /etc/ceph:/etc/ceph \
-   {% else -%}
-   -e KV_TYPE={{kv_type}} \
-   -e KV_IP={{kv_endpoint}} \
-   -e KV_PORT={{kv_port}} \
-   {% endif -%}
-   -v /etc/localtime:/etc/localtime:ro \
-   -e CEPH_DAEMON=MGR \
-   {{ ceph_mgr_docker_extra_env }} \
-   --name=ceph-mgr-{{ ansible_hostname }} \
-   {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
+  --memory={{ ceph_mgr_docker_memory_limit }} \
+  {% if docker_version.split('.')[0] | version_compare('13', '>=') -%}
+  --cpus={{ ceph_mgr_docker_cpu_limit }} \
+  {% else -%}
+  --cpu-quota={{ ceph_mgr_docker_cpu_limit * 100000 }} \
+  {% endif -%}
+  {% if not containerized_deployment_with_kv -%}
+  -v /var/lib/ceph:/var/lib/ceph \
+  -v /etc/ceph:/etc/ceph \
+  {% else -%}
+  -e KV_TYPE={{kv_type}} \
+  -e KV_IP={{kv_endpoint}} \
+  -e KV_PORT={{kv_port}} \
+  {% endif -%}
+  -v /etc/localtime:/etc/localtime:ro \
+  -e CEPH_DAEMON=MGR \
+  {{ ceph_mgr_docker_extra_env }} \
+  --name=ceph-mgr-{{ ansible_hostname }} \
+  {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
 ExecStopPost=-/usr/bin/docker stop ceph-mgr-{{ ansible_hostname }}
 Restart=always
 RestartSec=10s
index 398ec65190b33dd8f61f1670fb574752a989f43c..88e0d80fbba6e44e12bca8dcbdae8d78a256ced8 100644 (file)
@@ -92,7 +92,7 @@ openstack_pools:
 # The value for 'key' can be a pre-generated key,
 # e.g key: "AQDC2UxZH4yeLhAAgTaZb+4wDUlYOsr1OfZSpQ=="
 # By default, keys will be auto-generated.
-# 
+#
 # To have have ansible setfacl the generated key, set the acls var like so:
 # acls: ["u:nova:r--", "u:cinder:r--", "u:glance:r--", "u:gnocchi:r--"]
 openstack_keys:
@@ -107,6 +107,13 @@ openstack_keys:
 ##########
 ceph_mon_docker_subnet: "{{ public_network }}"# subnet of the monitor_interface
 
+# Resource limitation
+# For the whole list of limits you can apply see: docs.docker.com/engine/admin/resource_constraints
+# Default values are based from: https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/2/html/red_hat_ceph_storage_hardware_guide/minimum_recommendations
+# These options can be passed using the 'ceph_mon_docker_extra_env' variable.
+ceph_mon_docker_memory_limit: 1g
+ceph_mon_docker_cpu_limit: 1
+
 # ceph_mon_docker_extra_env:
 #
 # Use this variable to add extra env configuration to run your mon container.
index a5f790f27b9fe77ed779270bcca837c8b124f2be..07c776a2c022a79b680f6b0cec7086fb56e38754 100644 (file)
@@ -7,37 +7,43 @@ EnvironmentFile=-/etc/environment
 ExecStartPre=-/usr/bin/docker rm ceph-mon-%i
 ExecStartPre=$(command -v mkdir) -p /etc/ceph /var/lib/ceph/mon
 ExecStart=/usr/bin/docker run --rm --name ceph-mon-%i --net=host \
-   {% if not containerized_deployment_with_kv -%}
-   -v /var/lib/ceph:/var/lib/ceph \
-   -v /etc/ceph:/etc/ceph \
-   {% else -%}
-   -e KV_TYPE={{kv_type}} \
-   -e KV_IP={{kv_endpoint}}\
-   -e KV_PORT={{kv_port}} \
-   {% endif -%}
-   -v /etc/localtime:/etc/localtime:ro \
-   {% if mon_docker_privileged -%}
-   --privileged \
-   {% endif -%}
-   {% if mon_docker_net_host -%}
-   --net=host \
-   {% endif -%}
-   -e CEPH_DAEMON=MON \
-   -e CEPH_PUBLIC_NETWORK={{ ceph_mon_docker_subnet }} \
-   -e IP_VERSION={{ ip_version[-1:] }} \
-   {% if monitor_address is defined and monitor_address != '0.0.0.0' %}
-     {% if ip_version == 'ipv4' -%}
-       -e MON_IP={{ monitor_address }} \
-     {% elif ip_version == 'ipv6' -%}
-       -e MON_IP=[{{ monitor_address }}] \
-     {% endif -%}
-   {% elif ip_version == 'ipv4' -%}
-   -e MON_IP={{ hostvars[inventory_hostname]['ansible_' + monitor_interface][ip_version]['address'] }} \
-   {% elif ip_version =='ipv6' -%}
-   -e MON_IP=[{{ hostvars[inventory_hostname]['ansible_' + monitor_interface][ip_version][0]['address'] }}] \
-   {% endif -%}
-   {{ ceph_mon_docker_extra_env }} \
-   {{ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
+  --memory={{ ceph_mon_docker_memory_limit }} \
+  {% if docker_version.split('.')[0] | version_compare('13', '>=') -%}
+  --cpus={{ ceph_mon_docker_cpu_limit }} \
+  {% else -%}
+  --cpu-quota={{ ceph_mon_docker_cpu_limit * 100000 }} \
+  {% endif -%}
+  {% if not containerized_deployment_with_kv -%}
+  -v /var/lib/ceph:/var/lib/ceph \
+  -v /etc/ceph:/etc/ceph \
+  {% else -%}
+  -e KV_TYPE={{kv_type}} \
+  -e KV_IP={{kv_endpoint}}\
+  -e KV_PORT={{kv_port}} \
+  {% endif -%}
+  -v /etc/localtime:/etc/localtime:ro \
+  {% if mon_docker_privileged -%}
+  --privileged \
+  {% endif -%}
+  {% if mon_docker_net_host -%}
+  --net=host \
+  {% endif -%}
+  -e CEPH_DAEMON=MON \
+  -e CEPH_PUBLIC_NETWORK={{ ceph_mon_docker_subnet }} \
+  -e IP_VERSION={{ ip_version[-1:] }} \
+  {% if monitor_address is defined and monitor_address != '0.0.0.0' %}
+    {% if ip_version == 'ipv4' -%}
+      -e MON_IP={{ monitor_address }} \
+    {% elif ip_version == 'ipv6' -%}
+      -e MON_IP=[{{ monitor_address }}] \
+    {% endif -%}
+  {% elif ip_version == 'ipv4' -%}
+  -e MON_IP={{ hostvars[inventory_hostname]['ansible_' + monitor_interface][ip_version]['address'] }} \
+  {% elif ip_version =='ipv6' -%}
+  -e MON_IP=[{{ hostvars[inventory_hostname]['ansible_' + monitor_interface][ip_version][0]['address'] }}] \
+  {% endif -%}
+  {{ ceph_mon_docker_extra_env }} \
+  {{ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
 ExecStopPost=-/usr/bin/docker stop ceph-mon-%i
 Restart=always
 RestartSec=10s
index 2c6588541bdf76e77701fe6b16689881991e051e..f771dd7a466ccc16b1d3aff4d943a135002748f7 100644 (file)
@@ -218,6 +218,13 @@ lvm_volumes: []
 
 ceph_config_keys: [] # DON'T TOUCH ME
 
+# Resource limitation
+# For the whole list of limits you can apply see: docs.docker.com/engine/admin/resource_constraints
+# Default values are based from: https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/2/html/red_hat_ceph_storage_hardware_guide/minimum_recommendations
+# These options can be passed using the 'ceph_osd_docker_extra_env' variable.
+ceph_osd_docker_memory_limit: 1g
+ceph_osd_docker_cpu_limit: 1
+
 # PREPARE DEVICE
 #
 # WARNING /!\ DMCRYPT scenario ONLY works with Docker version 1.12.5 and above
index 1ac606f5375df5bae93efd96d0efba8268ffde30..acc852ff387c0b65d1a800bf2324306d6fb6d7c4 100644 (file)
@@ -54,6 +54,12 @@ expose_partitions $1
   --net=host \
   --privileged=true \
   --pid=host \
+  --memory={{ ceph_osd_docker_memory_limit }} \
+  {% if docker_version.split('.')[0] | version_compare('13', '>=') -%}
+  --cpus={{ ceph_osd_docker_cpu_limit }} \
+  {% else -%}
+  --cpu-quota={{ ceph_osd_docker_cpu_limit * 100000 }} \
+  {% endif -%}
   -v /dev:/dev \
   -v /etc/localtime:/etc/localtime:ro \
   -v /var/lib/ceph:/var/lib/ceph \
index b343a205856f2fa419a4f2890a92c43ea8df35a7..4c1ecb7d5e46208a67007508a45d8e5d5490af35 100644 (file)
@@ -15,6 +15,7 @@ copy_admin_key: false
 # NOTE: deprecated generic local user id for pre-Luminous releases
 ceph_rbd_mirror_local_user: "admin"
 
+
 #################
 # CONFIGURATION #
 #################
@@ -33,10 +34,19 @@ ceph_rbd_mirror_remote_cluster: ""
 # /etc/ceph/<remote_cluster>.client.<remote_user>.keyring
 ceph_rbd_mirror_remote_user: ""
 
+
 ##########
 # DOCKER #
 ##########
 
+# Resource limitation
+# For the whole list of limits you can apply see: docs.docker.com/engine/admin/resource_constraints
+# Default values are based from: https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/2/html/red_hat_ceph_storage_hardware_guide/minimum_recommendations
+# These options can be passed using the 'ceph_rbd_mirror_docker_extra_env' variable.
+ceph_rbd_mirror_docker_memory_limit: 1g
+ceph_rbd_mirror_docker_cpu_limit: 1
+
+ceph_rbd_mirror_docker_extra_env:
 ceph_config_keys: [] # DON'T TOUCH ME
 
 
index 4b6537ba118eed55c62977828a8fccfdc26c5e7c..446685fcc3e50c75acc7349c62fbcde1bfc347f3 100644 (file)
@@ -7,17 +7,24 @@ EnvironmentFile=-/etc/environment
 ExecStartPre=-/usr/bin/docker stop ceph-rbd-mirror-{{ ansible_hostname }}
 ExecStartPre=-/usr/bin/docker rm ceph-rbd-mirror-{{ ansible_hostname }}
 ExecStart=/usr/bin/docker run --rm --net=host \
-   {% if not containerized_deployment_with_kv -%}
-   -v /etc/ceph:/etc/ceph \
-   {% else -%}
-   -e KV_TYPE={{kv_type}} \
-   -e KV_IP={{kv_endpoint}} \
-   -e KV_PORT={{kv_port}} \
-   {% endif -%}
-   -v /etc/localtime:/etc/localtime:ro \
-   -e CEPH_DAEMON=RBD_MIRROR \
-   --name=ceph-rbd-mirror-{{ ansible_hostname }} \
-   {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
+  --memory={{ ceph_rbd_mirorr_docker_memory_limit }} \
+  {% if docker_version.split('.')[0] | version_compare('13', '>=') -%}
+  --cpus={{ ceph_rbd_mirror_docker_cpu_limit }} \
+  {% else -%}
+  --cpu-quota={{ ceph_rbd_mirorr_docker_cpu_limit * 100000 }} \
+  {% endif -%}
+  {% if not containerized_deployment_with_kv -%}
+  -v /etc/ceph:/etc/ceph \
+  {% else -%}
+  -e KV_TYPE={{kv_type}} \
+  -e KV_IP={{kv_endpoint}} \
+  -e KV_PORT={{kv_port}} \
+  {% endif -%}
+  -v /etc/localtime:/etc/localtime:ro \
+  -e CEPH_DAEMON=RBD_MIRROR \
+  --name=ceph-rbd-mirror-{{ ansible_hostname }} \
+  {{ ceph_rbd_mirror_docker_extra_env }} \
+  {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }}
 ExecStopPost=-/usr/bin/docker stop ceph-rbd-mirror-{{ ansible_hostname }}
 Restart=always
 RestartSec=10s
index 4487865dc3e659937eed66c4df172b6edb0c3765..7f0a8aa4c47fe35011fbdd26aa1adced4c84a084 100644 (file)
@@ -49,6 +49,13 @@ rgw_pull_proto: "http"
 # DOCKER #
 ##########
 
+# Resource limitation
+# For the whole list of limits you can apply see: docs.docker.com/engine/admin/resource_constraints
+# Default values are based from: https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/2/html/red_hat_ceph_storage_hardware_guide/minimum_recommendations
+# These options can be passed using the 'ceph_rgw_docker_extra_env' variable.
+ceph_rgw_docker_memory_limit: 1g
+ceph_rgw_docker_cpu_limit: 1
+
 ceph_rgw_docker_extra_env:
 ceph_config_keys: [] # DON'T TOUCH ME
 rgw_config_keys: "/" # DON'T TOUCH ME
index afe7c72c61701e4620ed842b5a6472fbd693d5a2..25f8b5b0ba9a27d0d9d31ec09a7542fa885d5755 100644 (file)
@@ -7,6 +7,12 @@ EnvironmentFile=-/etc/environment
 ExecStartPre=-/usr/bin/docker stop ceph-rgw-{{ ansible_hostname }}
 ExecStartPre=-/usr/bin/docker rm ceph-rgw-{{ ansible_hostname }}
 ExecStart=/usr/bin/docker run --rm --net=host \
+  --memory={{ ceph_rgw_docker_memory_limit }} \
+  {% if docker_version.split('.')[0] | version_compare('13', '>=') -%}
+  --cpus={{ ceph_rgw_docker_cpu_limit }} \
+  {% else -%}
+  --cpu-quota={{ ceph_rgw_docker_cpu_limit * 100000 }} \
+  {% endif -%}
   {% if not containerized_deployment_with_kv -%}
   -v /var/lib/ceph:/var/lib/ceph \
   -v /etc/ceph:/etc/ceph \