repository-gcs.asciidoc 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. [[repository-gcs]]
  2. === Google Cloud Storage Repository Plugin
  3. The GCS repository plugin adds support for using the https://cloud.google.com/storage/[Google Cloud Storage]
  4. service as a repository for {ref}/modules-snapshots.html[Snapshot/Restore].
  5. :plugin_name: repository-gcs
  6. include::install_remove.asciidoc[]
  7. [[repository-gcs-usage]]
  8. ==== Getting started
  9. The plugin uses the https://cloud.google.com/storage/docs/json_api/[Google Cloud Storage JSON API] (v1)
  10. to connect to the Storage service. If this is the first time you use Google Cloud Storage, you first
  11. need to connect to the https://console.cloud.google.com/[Google Cloud Platform Console] and create a new
  12. project. Once your project is created, you must enable the Cloud Storage Service for your project.
  13. [[repository-gcs-creating-bucket]]
  14. ===== Creating a Bucket
  15. Google Cloud Storage service uses the concept of https://cloud.google.com/storage/docs/key-terms[Bucket]
  16. as a container for all the data. Buckets are usually created using the
  17. https://console.cloud.google.com/[Google Cloud Platform Console]. The plugin will not automatically
  18. create buckets.
  19. To create a new bucket:
  20. 1. Connect to the https://console.cloud.google.com/[Google Cloud Platform Console]
  21. 2. Select your project
  22. 3. Got to the https://console.cloud.google.com/storage/browser[Storage Browser]
  23. 4. Click the "Create Bucket" button
  24. 5. Enter a the name of the new bucket
  25. 6. Select a storage class
  26. 7. Select a location
  27. 8. Click the "Create" button
  28. The bucket should now be created.
  29. [[repository-gcs-service-authentication]]
  30. ===== Service Authentication
  31. The plugin supports two authentication modes:
  32. * The built-in <<repository-gcs-using-compute-engine, Compute Engine authentication>>. This mode is
  33. recommended if your elasticsearch node is running on a Compute Engine virtual machine.
  34. * Specifying <<repository-gcs-using-service-account, Service Account>> credentials.
  35. [[repository-gcs-using-compute-engine]]
  36. ===== Using Compute Engine
  37. When running on Compute Engine, the plugin use Google's built-in authentication mechanism to
  38. authenticate on the Storage service. Compute Engine virtual machines are usually associated to a
  39. default service account. This service account can be found in the VM instance details in the
  40. https://console.cloud.google.com/compute/[Compute Engine console].
  41. This is the default authentication mode and requires no configuration.
  42. NOTE: The Compute Engine VM must be allowed to use the Storage service. This can be done only at VM
  43. creation time, when "Storage" access can be configured to "Read/Write" permission. Check your
  44. instance details at the section "Cloud API access scopes".
  45. [[repository-gcs-using-service-account]]
  46. ===== Using a Service Account
  47. If your elasticsearch node is not running on Compute Engine, or if you don't want to use Google's
  48. built-in authentication mechanism, you can authenticate on the Storage service using a
  49. https://cloud.google.com/iam/docs/overview#service_account[Service Account] file.
  50. To create a service account file:
  51. 1. Connect to the https://console.cloud.google.com/[Google Cloud Platform Console]
  52. 2. Select your project
  53. 3. Got to the https://console.cloud.google.com/permissions[Permission] tab
  54. 4. Select the https://console.cloud.google.com/permissions/serviceaccounts[Service Accounts] tab
  55. 5. Click on "Create service account"
  56. 6. Once created, select the new service account and download a JSON key file
  57. A service account file looks like this:
  58. [source,js]
  59. ----
  60. {
  61. "type": "service_account",
  62. "project_id": "your-project-id",
  63. "private_key_id": "...",
  64. "private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
  65. "client_email": "service-account-for-your-repository@your-project-id.iam.gserviceaccount.com",
  66. "client_id": "...",
  67. "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  68. "token_uri": "https://accounts.google.com/o/oauth2/token",
  69. "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  70. "client_x509_cert_url": "..."
  71. }
  72. ----
  73. // NOTCONSOLE
  74. This file must be stored in the {ref}/secure-settings.html[elasticsearch keystore], under a setting name
  75. of the form `gcs.client.NAME.credentials_file`, where `NAME` is the name of the client congiguration.
  76. The default client name is `default`, but a different client name can be specified in repository
  77. settings using `client`.
  78. For example, if specifying the credentials file in the keystore under
  79. `gcs.client.my_alternate_client.credentials_file`, you can configure a repository to use these
  80. credentials like this:
  81. [source,js]
  82. ----
  83. PUT _snapshot/my_gcs_repository
  84. {
  85. "type": "gcs",
  86. "settings": {
  87. "bucket": "my_bucket",
  88. "client": "my_alternate_client"
  89. }
  90. }
  91. ----
  92. // CONSOLE
  93. // TEST[skip:we don't have gcs setup while testing this]
  94. [[repository-gcs-bucket-permission]]
  95. ===== Set Bucket Permission
  96. The service account used to access the bucket must have the "Writer" access to the bucket:
  97. 1. Connect to the https://console.cloud.google.com/[Google Cloud Platform Console]
  98. 2. Select your project
  99. 3. Got to the https://console.cloud.google.com/storage/browser[Storage Browser]
  100. 4. Select the bucket and "Edit bucket permission"
  101. 5. The service account must be configured as a "User" with "Writer" access
  102. [[repository-gcs-repository]]
  103. ==== Create a Repository
  104. Once everything is installed and every node is started, you can create a new repository that
  105. uses Google Cloud Storage to store snapshots:
  106. [source,js]
  107. ----
  108. PUT _snapshot/my_gcs_repository
  109. {
  110. "type": "gcs",
  111. "settings": {
  112. "bucket": "my_bucket"
  113. }
  114. }
  115. ----
  116. // CONSOLE
  117. // TEST[skip:we don't have gcs setup while testing this]
  118. The following settings are supported:
  119. `bucket`::
  120. The name of the bucket to be used for snapshots. (Mandatory)
  121. `client`::
  122. The client congfiguration to use. This controls which credentials are used to connect
  123. to Compute Engine.
  124. `base_path`::
  125. Specifies the path within bucket to repository data. Defaults to
  126. the root of the bucket.
  127. `chunk_size`::
  128. Big files can be broken down into chunks during snapshotting if needed.
  129. The chunk size can be specified in bytes or by using size value notation,
  130. i.e. `1g`, `10m`, `5k`. Defaults to `100m`.
  131. `compress`::
  132. When set to `true` metadata files are stored in compressed format. This
  133. setting doesn't affect index files that are already compressed by default.
  134. Defaults to `false`.
  135. `application_name`::
  136. Name used by the plugin when it uses the Google Cloud JSON API. Setting
  137. a custom name can be useful to authenticate your cluster when requests
  138. statistics are logged in the Google Cloud Platform. Default to `repository-gcs`