discovery-ec2.asciidoc 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. [[discovery-ec2]]
  2. === EC2 Discovery Plugin
  3. The EC2 discovery plugin uses the https://github.com/aws/aws-sdk-java[AWS API] for unicast discovery.
  4. [[discovery-ec2-install]]
  5. [float]
  6. ==== Installation
  7. This plugin can be installed using the plugin manager:
  8. [source,sh]
  9. ----------------------------------------------------------------
  10. sudo bin/plugin install discovery-ec2
  11. ----------------------------------------------------------------
  12. The plugin must be installed on every node in the cluster, and each node must
  13. be restarted after installation.
  14. [[discovery-ec2-remove]]
  15. [float]
  16. ==== Removal
  17. The plugin can be removed with the following command:
  18. [source,sh]
  19. ----------------------------------------------------------------
  20. sudo bin/plugin remove discovery-ec2
  21. ----------------------------------------------------------------
  22. The node must be stopped before removing the plugin.
  23. [[discovery-ec2-usage]]
  24. ==== Getting started with AWS
  25. The plugin will default to using
  26. http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html[IAM Role]
  27. credentials for authentication. These can be overridden by, in increasing
  28. order of precedence, system properties `aws.accessKeyId` and `aws.secretKey`,
  29. environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_KEY`, or the
  30. elasticsearch config using `cloud.aws.access_key` and `cloud.aws.secret_key`:
  31. [source,yaml]
  32. ----
  33. cloud:
  34. aws:
  35. access_key: AKVAIQBF2RECL7FJWGJQ
  36. secret_key: vExyMThREXeRMm/b/LRzEB8jWwvzQeXgjqMX+6br
  37. ----
  38. [[discovery-ec2-usage-security]]
  39. ===== Transport security
  40. By default this plugin uses HTTPS for all API calls to AWS endpoints. If you wish to configure HTTP you can set
  41. `cloud.aws.protocol` in the elasticsearch config. You can optionally override this setting per individual service
  42. via: `cloud.aws.ec2.protocol` or `cloud.aws.s3.protocol`.
  43. [source,yaml]
  44. ----
  45. cloud:
  46. aws:
  47. protocol: https
  48. ec2:
  49. protocol: https
  50. ----
  51. In addition, a proxy can be configured with the `proxy_host` and `proxy_port` settings (note that protocol can be
  52. `http` or `https`):
  53. [source,yaml]
  54. ----
  55. cloud:
  56. aws:
  57. protocol: https
  58. proxy_host: proxy1.company.com
  59. proxy_port: 8083
  60. ----
  61. You can also set different proxies for `ec2` and `s3`:
  62. [source,yaml]
  63. ----
  64. cloud:
  65. aws:
  66. s3:
  67. proxy_host: proxy1.company.com
  68. proxy_port: 8083
  69. ec2:
  70. proxy_host: proxy2.company.com
  71. proxy_port: 8083
  72. ----
  73. [[discovery-ec2-usage-region]]
  74. ===== Region
  75. The `cloud.aws.region` can be set to a region and will automatically use the relevant settings for both `ec2` and `s3`.
  76. The available values are:
  77. * `us-east` (`us-east-1`)
  78. * `us-west` (`us-west-1`)
  79. * `us-west-1`
  80. * `us-west-2`
  81. * `ap-southeast` (`ap-southeast-1`)
  82. * `ap-southeast-1`
  83. * `ap-southeast-2`
  84. * `ap-northeast` (`ap-northeast-1`)
  85. * `eu-west` (`eu-west-1`)
  86. * `eu-central` (`eu-central-1`)
  87. * `sa-east` (`sa-east-1`)
  88. * `cn-north` (`cn-north-1`)
  89. [[discovery-ec2-usage-signer]]
  90. ===== EC2 Signer API
  91. If you are using a compatible EC2 service, they might be using an older API to sign the requests.
  92. You can set your compatible signer API using `cloud.aws.signer` (or `cloud.aws.ec2.signer`)
  93. with the right signer to use.
  94. [[discovery-ec2-discovery]]
  95. ==== EC2 Discovery
  96. ec2 discovery allows to use the ec2 APIs to perform automatic discovery (similar to multicast in non hostile multicast
  97. environments). Here is a simple sample configuration:
  98. [source,yaml]
  99. ----
  100. discovery:
  101. type: ec2
  102. ----
  103. You must also set `cloud.aws.region` if you are not using default AWS region. See <<discovery-ec2-usage-region>> for details.
  104. The ec2 discovery is using the same credentials as the rest of the AWS services provided by this plugin (`repositories`).
  105. See <<discovery-ec2-usage>> for details.
  106. The following are a list of settings (prefixed with `discovery.ec2`) that can further control the discovery:
  107. `groups`::
  108. Either a comma separated list or array based list of (security) groups.
  109. Only instances with the provided security groups will be used in the
  110. cluster discovery. (NOTE: You could provide either group NAME or group
  111. ID.)
  112. `host_type`::
  113. The type of host type to use to communicate with other instances. Can be
  114. one of `private_ip`, `public_ip`, `private_dns`, `public_dns`. Defaults to
  115. `private_ip`.
  116. `availability_zones`::
  117. Either a comma separated list or array based list of availability zones.
  118. Only instances within the provided availability zones will be used in the
  119. cluster discovery.
  120. `any_group`::
  121. If set to `false`, will require all security groups to be present for the
  122. instance to be used for the discovery. Defaults to `true`.
  123. `ping_timeout`::
  124. How long to wait for existing EC2 nodes to reply during discovery.
  125. Defaults to `3s`. If no unit like `ms`, `s` or `m` is specified,
  126. milliseconds are used.
  127. [IMPORTANT]
  128. .Binding the network host
  129. ==============================================
  130. It's important to define `network.host` as by default it's bound to `localhost`.
  131. You can use {ref}/modules-network.html[core network host settings] or
  132. <<discovery-ec2-network-host,ec2 specific host settings>>:
  133. ==============================================
  134. [[discovery-ec2-network-host]]
  135. ==== EC2 Network Host
  136. When the `discovery-ec2` plugin is installed, the following are also allowed
  137. as valid network host settings:
  138. [cols="<,<",options="header",]
  139. |==================================================================
  140. |EC2 Host Value |Description
  141. |`_ec2:privateIpv4_` |The private IP address (ipv4) of the machine.
  142. |`_ec2:privateDns_` |The private host of the machine.
  143. |`_ec2:publicIpv4_` |The public IP address (ipv4) of the machine.
  144. |`_ec2:publicDns_` |The public host of the machine.
  145. |`_ec2:privateIp_` |equivalent to _ec2:privateIpv4_.
  146. |`_ec2:publicIp_` |equivalent to _ec2:publicIpv4_.
  147. |`_ec2_` |equivalent to _ec2:privateIpv4_.
  148. |==================================================================
  149. [[discovery-ec2-permissions]]
  150. ===== Recommended EC2 Permissions
  151. EC2 discovery requires making a call to the EC2 service. You'll want to setup
  152. an IAM policy to allow this. You can create a custom policy via the IAM
  153. Management Console. It should look similar to this.
  154. [source,js]
  155. ----
  156. {
  157. "Statement": [
  158. {
  159. "Action": [
  160. "ec2:DescribeInstances"
  161. ],
  162. "Effect": "Allow",
  163. "Resource": [
  164. "*"
  165. ]
  166. }
  167. ],
  168. "Version": "2012-10-17"
  169. }
  170. ----
  171. [[discovery-ec2-filtering]]
  172. ===== Filtering by Tags
  173. The ec2 discovery can also filter machines to include in the cluster based on tags (and not just groups). The settings
  174. to use include the `discovery.ec2.tag.` prefix. For example, setting `discovery.ec2.tag.stage` to `dev` will only
  175. filter instances with a tag key set to `stage`, and a value of `dev`. Several tags set will require all of those tags
  176. to be set for the instance to be included.
  177. One practical use for tag filtering is when an ec2 cluster contains many nodes that are not running elasticsearch. In
  178. this case (particularly with high `ping_timeout` values) there is a risk that a new node's discovery phase will end
  179. before it has found the cluster (which will result in it declaring itself master of a new cluster with the same name
  180. - highly undesirable). Tagging elasticsearch ec2 nodes and then filtering by that tag will resolve this issue.
  181. [[discovery-ec2-attributes]]
  182. ===== Automatic Node Attributes
  183. Though not dependent on actually using `ec2` as discovery (but still requires the cloud aws plugin installed), the
  184. plugin can automatically add node attributes relating to ec2 (for example, availability zone, that can be used with
  185. the awareness allocation feature). In order to enable it, set `cloud.node.auto_attributes` to `true` in the settings.
  186. [[discovery-ec2-endpoint]]
  187. ===== Using other EC2 endpoint
  188. If you are using any EC2 api compatible service, you can set the endpoint you want to use by setting
  189. `cloud.aws.ec2.endpoint` to your URL provider.