remote-clusters-migration.asciidoc 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. [[remote-clusters-migrate]]
  2. === Migrate remote clusters from certificate to API key authentication
  3. ++++
  4. <titleabbrev>Migrate from certificate to API key authentication</titleabbrev>
  5. ++++
  6. The API key based security model for remote clusters offers administrators more
  7. fine-grained access controls compared to the TLS certificate based security
  8. model. For that reason, you may want to migrate from the certificate based
  9. security model to the API key based model.
  10. While it is possible to migrate by defining a new remote cluster connection,
  11. using a new alias, this has several downsides:
  12. - For {ccr}, it's not possible to change the leader cluster alias for existing
  13. tasks. As a result, with a new remote cluster, follower indices would need to be
  14. re-created from scratch.
  15. - For {ccs}, transform and anomaly detection jobs do allow updating the remote
  16. cluster alias. However, if the job was created with wildcards, for example
  17. `*:source_index`, and `superuser`, adding a new remote cluster will cause the
  18. job to do double the amount of work and potentially skew results with
  19. duplications.
  20. For these reasons, you may prefer to migrate a remote cluster in-place, by
  21. following these steps:
  22. . <<remote-clusters-migration-prerequisites,Review the prerequisites>>
  23. . <<remote-clusters-migration-remote-cluster>>
  24. . <<remote-clusters-migration-stop>>
  25. . <<remote-clusters-migration-reconnect>>
  26. . <<remote-clusters-migration-resume>>
  27. . <<remote-clusters-migration-disable-cert>>
  28. If you run into any issues, refer to <<remote-clusters-troubleshooting>>.
  29. [[remote-clusters-migration-prerequisites]]
  30. ==== Prerequisites
  31. * The nodes of the local and remote clusters must be on version 8.10 or later.
  32. * The local and remote clusters must have an appropriate license. For more
  33. information, refer to https://www.elastic.co/subscriptions.
  34. [[remote-clusters-migration-remote-cluster]]
  35. ==== Reconfigure the remote cluster and generate a cross-cluster API key
  36. On the remote cluster:
  37. include::remote-clusters-api-key.asciidoc[tag=remote-cluster-steps]
  38. [[remote-clusters-migration-stop]]
  39. ==== Stop cross-cluster operations
  40. On the local cluster, stop any persistent tasks that refer to the remote
  41. cluster:
  42. * Use the <<stop-transform>> API to stop any transforms.
  43. * Use the <<ml-close-job>> API to close any anomaly detection jobs.
  44. * Use the <<ccr-pause-auto-follow-pattern>> API to pause any auto-follow {ccr}.
  45. * Use the <<ccr-post-pause-follow>> API to pause any manual {ccr} or existing
  46. indices that were created from the auto-follow pattern.
  47. [[remote-clusters-migration-reconnect]]
  48. ==== Reconnect to the remote cluster
  49. On the local cluster:
  50. . Enhance any roles used by local cluster users with the required
  51. <<roles-remote-indices-priv,remote indices privileges>> for {ccr} and {ccs}.
  52. Refer to <<remote-clusters-privileges-api-key>>. Note:
  53. ** You only need to assign additional `remote_indices` privileges to existing
  54. roles used for cross-cluster operations. You should be able to copy these
  55. privileges from the original roles on the remote cluster, where they are defined
  56. under the certification based security model.
  57. ** The roles on the local cluster can't exceed the `access` privilege granted by
  58. the cross-cluster API key. Any extra local privileges will be suppressed by the
  59. cross-cluster API key's privileges.
  60. ** No update is needed if the {ccr} or {ccs} tasks have been configured with a
  61. `superuser` role. The `superuser` role is automatically updated to allow access
  62. to all remote indices.
  63. ** Tasks that are run as regular users with named roles are immediately updated
  64. with the new privileges. A task will load a new definition the next time it
  65. runs.
  66. ** You need to restart tasks that are run using an API key (done in a later
  67. step).
  68. . If you've dynamically configured the remote cluster (via the cluster settings
  69. API):
  70. .. Retrieve the current remote cluster configuration, and store it in a safe
  71. place. You may need it later in case you need to
  72. <<remote-clusters-migration-rollback,roll back>>. Use the cluster settings API:
  73. +
  74. [source,console]
  75. ----
  76. GET /_cluster/settings?filter_path=persistent.cluster.remote
  77. ----
  78. .. Remove the existing remote cluster definition by setting the remote cluster
  79. settings to `null`.
  80. . If you've statically configured the remote cluster (via `elasticsearch.yml`),
  81. copy the `cluster.remote` settings from `elasticsearch.yml`, and store them
  82. in a safe place. You may need them later in case you need to
  83. <<remote-clusters-migration-rollback,roll back>>.
  84. include::remote-clusters-api-key.asciidoc[tag=local-cluster-steps]
  85. .. Add the cross-cluster API key, created on the remote cluster earlier, to the
  86. keystore:
  87. +
  88. [source,sh]
  89. ----
  90. ./bin/elasticsearch-keystore add cluster.remote.ALIAS.credentials
  91. ----
  92. +
  93. Replace `ALIAS` with the same alias that was used for cross-cluster operations
  94. before the migration. When prompted, enter the encoded cross-cluster API key
  95. created on the remote cluster earlier.
  96. . If you've dynamically configured the remote cluster (via the cluster settings
  97. API):
  98. .. Restart the local cluster to load changes to the keystore.
  99. .. Re-add the remote cluster. Use the same remote cluster alias, and change the
  100. transport port into the remote cluster port. For example:
  101. +
  102. [source,console]
  103. ----
  104. PUT /_cluster/settings
  105. {
  106. "persistent" : {
  107. "cluster" : {
  108. "remote" : {
  109. "my_remote" : { <1>
  110. "mode": "proxy",
  111. "proxy_address": "my.remote.cluster.com:9443" <2>
  112. }
  113. }
  114. }
  115. }
  116. }
  117. ----
  118. // TEST[skip:TODO]
  119. <1> The remote cluster alias. Use the same alias that was used before the
  120. migration.
  121. <2> The remote cluster address with the remote cluster port, which defaults to
  122. `9443`.
  123. . If you've statically configured the remote cluster (via `elasticsearch.yml`):
  124. .. Update the `cluster.remote` settings in `elasticsearch.yml` on each node of
  125. the local cluster. Change the port into the remote cluster port, which defaults
  126. to `9443`.
  127. .. Restart the local cluster to load changes to the keystore and settings.
  128. . Use the <<cluster-remote-info,remote cluster info API>> to verify that the
  129. local cluster has successfully connected to the remote cluster:
  130. +
  131. [source,console]
  132. ----
  133. GET /_remote/info
  134. ----
  135. // TEST[skip:TODO]
  136. +
  137. The API response should indicate that the local cluster has connected to the
  138. remote cluster:
  139. +
  140. [source,console-result]
  141. ----
  142. {
  143. "my_remote": {
  144. "connected": true, <1>
  145. "mode": "proxy",
  146. "proxy_address": "my.remote.cluster.com:9443",
  147. "server_name": "",
  148. "num_proxy_sockets_connected": 0,
  149. "max_proxy_socket_connections": 18,
  150. "initial_connect_timeout": "30s",
  151. "skip_unavailable": false,
  152. "cluster_credentials": "::es_redacted::" <2>
  153. }
  154. }
  155. ----
  156. // TEST[skip:TODO]
  157. <1> The remote cluster is connected.
  158. <2> If present, indicates the remote cluster has connected using API key
  159. authentication.
  160. [[remote-clusters-migration-resume]]
  161. ==== Resume cross-cluster operations
  162. Resume any persistent tasks that you stopped earlier. Tasks should be restarted
  163. by the same user or API key that created the task before the migration. Ensure
  164. the roles of this user or API key have been updated with the required
  165. `remote_indices` privileges. For users, tasks capture the caller's credentials
  166. when started and run in that user's security context. For API keys, restarting a
  167. task will update the task with the updated API key.
  168. * Use the <<start-transform>> API to start any transforms.
  169. * Use the <<ml-open-job>> API to open any anomaly detection jobs.
  170. * Use the <<ccr-post-resume-follow>> API to resume any auto-follow {ccr}.
  171. * Use the <<ccr-resume-auto-follow-pattern>> API to resume any manual {ccr} or
  172. existing indices that were created from the auto-follow pattern.
  173. [[remote-clusters-migration-disable-cert]]
  174. ==== Disable certificate based authentication and authorization
  175. NOTE: Only proceed with this step if the migration has been proved successful on
  176. the local cluster. If the migration is unsuccessful, either
  177. <<remote-clusters-troubleshooting,find out what the problem is and attempt to
  178. fix it>> or <<remote-clusters-migration-rollback,roll back>>.
  179. Next, disable the certification based connection. Optionally, you can also
  180. revoke the authorization.
  181. . There is no particular setting to enable or disable a certificate based cross
  182. cluster connection, because it shares the same transport protocol with the
  183. intra-cluster node-to-node communication.
  184. +
  185. One way a remote cluster administrator can stop an existing local cluster from
  186. connecting, is by changing TLS trust. The exact steps vary, depending on how the
  187. clusters have been configured. A generic solution is to
  188. <<encrypt-internode-communication,recreate the CA and certificate/key used by
  189. the remote transport interface>> so that any existing certificate/key, locally
  190. or distributed, is no longer trusted.
  191. +
  192. Another solution is to apply IP filters to the transport interface, blocking
  193. traffic from outside the cluster.
  194. . Optionally, delete any roles on the remote cluster that were only used for
  195. cross-cluster operations. These roles are no longer used under the API key based
  196. security model.
  197. [[remote-clusters-migration-rollback]]
  198. ==== Rollback
  199. If you need to roll back, follow these steps on the local cluster:
  200. . Stop any persistent tasks that refer to the remote cluster.
  201. . Remove the remote cluster definition by setting the remote cluster settings to
  202. `null`.
  203. . Remove the `remote_indices` privileges from any roles that were updated during
  204. the migration.
  205. . On each node, remove the `remote_cluster_client.ssl.*` settings from
  206. `elasticsearch.yml`.
  207. . Restart the local cluster to apply changes to the keystore and
  208. `elasticsearch.yml`.
  209. . On the local cluster, apply the original remote cluster settings. If the
  210. remote cluster connection has been configured statically (using the
  211. `elasticsearch.yml` file), restart the cluster.
  212. . Use the <<cluster-remote-info,remote cluster info API>> to verify that the
  213. local cluster has connected to the remote cluster. The response should have
  214. `"connected": true` and not have `"cluster_credentials": "::es_redacted::"`.
  215. . Restart any persistent tasks that you've stopped earlier.