remote-clusters-migration.asciidoc 10 KB

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