diff --git a/templates/es-cluster/0/README.md b/templates/es-cluster/0/README.md index c6ad399..c662188 100644 --- a/templates/es-cluster/0/README.md +++ b/templates/es-cluster/0/README.md @@ -2,8 +2,4 @@ A scalable Elasticsearch cluster -## Notes - -You have to set vm.max_map_count to atleast 262144 on each of the hosts that will run Elasticsearch! - -To do so run `sudo sysctl -w vm.max_map_count=262144` \ No newline at end of file +WARN: To avoid vm.max_map_count errors you could set "Update host sysctl" to true. Then param vm.max_map_count will be update to 262144 if it's less in your hosts. diff --git a/templates/es-cluster/0/docker-compose.yml b/templates/es-cluster/0/docker-compose.yml.tpl similarity index 85% rename from templates/es-cluster/0/docker-compose.yml rename to templates/es-cluster/0/docker-compose.yml.tpl index ad14ab9..d07c69c 100644 --- a/templates/es-cluster/0/docker-compose.yml +++ b/templates/es-cluster/0/docker-compose.yml.tpl @@ -5,6 +5,9 @@ services: io.rancher.scheduler.affinity:container_label_soft_ne: io.rancher.stack_service.name=$${stack_name}/$${service_name} io.rancher.container.hostname_override: container_name io.rancher.sidekicks: es-storage + {{- if eq .Values.UPDATE_SYSCTL "true" -}} + ,es-sysctl + {{- end}} image: docker.elastic.co/elasticsearch/elasticsearch:5.4.0 environment: - "cluster.name=${cluster_name}" @@ -35,6 +38,9 @@ services: io.rancher.scheduler.affinity:container_label_soft_ne: io.rancher.stack_service.name=$${stack_name}/$${service_name} io.rancher.container.hostname_override: container_name io.rancher.sidekicks: es-storage + {{- if eq .Values.UPDATE_SYSCTL "true" -}} + ,es-sysctl + {{- end}} image: docker.elastic.co/elasticsearch/elasticsearch:5.4.0 environment: - "cluster.name=${cluster_name}" @@ -66,6 +72,9 @@ services: io.rancher.scheduler.affinity:container_label_soft_ne: io.rancher.stack_service.name=$${stack_name}/$${service_name} io.rancher.container.hostname_override: container_name io.rancher.sidekicks: es-storage + {{- if eq .Values.UPDATE_SYSCTL "true" -}} + ,es-sysctl + {{- end}} image: docker.elastic.co/elasticsearch/elasticsearch:5.4.0 environment: - "cluster.name=${cluster_name}" @@ -91,7 +100,7 @@ services: - es-storage depends_on: - es-master - + es-storage: labels: io.rancher.container.start_once: true @@ -100,6 +109,17 @@ services: volumes: - es-storage-volume:/usr/share/elasticsearch/data + {{- if eq .Values.UPDATE_SYSCTL "true" }} + es-sysctl: + labels: + io.rancher.container.start_once: true + image: rawmind/alpine-sysctl:0.1 + privileged: true + environment: + - "SYSCTL_KEY=vm.max_map_count" + - "SYSCTL_VALUE=262144" + {{- end}} + volumes: es-storage-volume: driver: local diff --git a/templates/es-cluster/0/rancher-compose.yml b/templates/es-cluster/0/rancher-compose.yml index 0e5f11d..e5580a1 100644 --- a/templates/es-cluster/0/rancher-compose.yml +++ b/templates/es-cluster/0/rancher-compose.yml @@ -11,6 +11,18 @@ description: "Name of the Elasticsearch Cluster" default: "es-cluster" + - variable: "UPDATE_SYSCTL" + label: "Update host sysctl:" + description: | + Set true to avoid vm.max_map_count errors. + WARN: If set true, host param vm.max_map_count will be update to 262144. + default: false + required: true + type: enum + options: + - false + - true + - variable: "master_heap_size" type: "string" required: true