Migrate logs procedure

Guidelines to migrate logs previous to Tequila Aura Platform release.

Prerequirements

  • Recommended:
    • kubectl installed in your local host.
    • curl installed in your local host.
    • jq installed in your local host.

Procedure

Get the credentials from the destination cluster

As we will use the common storage account created in releases after Tequila (included), we need to get its credentials of it from the new cluster, executing the following command:

kubectl -n aura-system get secret elasticsearch-es-secure-settings -o yaml

This will return a yaml with two keys with the credentials needed to access the storage account, as shown below:

  azure.client.migrate.account: c29tZXN0b3JhZ2VhY2NvdW50bmFtZQ==
  azure.client.migrate.key: YzI5dFpYTjBiM0poWjJWaFkyTnZkVzUwYTJWNWFXNWlZWE5sTmpRPQ==

Create manifest with secrets

Copy the base64 encoded values of each key and create a file with the following content, replacing the values with the ones copied:

apiVersion: v1
data:
  azure.client.default.account: c29tZXN0b3JhZ2VhY2NvdW50bmFtZQ==
kind: Secret
metadata:
  labels:
    app: elasticsearch
    stack: management
  name: eck-elasticsearch-azure-account
  namespace: aura-system
type: Opaque


---

apiVersion: v1
data:
  azure.client.default.key: YzI5dFpYTjBiM0poWjJWaFkyTnZkVzUwYTJWNWFXNWlZWE5sTmpRPQ==
kind: Secret
metadata:
  annotations:
  labels:
    app: elasticsearch
    stack: management
  name: eck-elasticsearch-azure-key
  namespace: aura-system
type: Opaque

Apply the manifest

Apply the manifest created in the previous step in the source cluster, executing the following command:

kubectl apply -f <manifest-file>

This will make an operator reconciliation needed, so the elastic-operator will restart the Elasticsearch cluster, so it has to wait until the whole cluster pods are restarted. We can check the reconciliation status checking the status field from the Elasticsearch object:

kubectl -n aura-system get elasticsearches.elasticsearch.k8s.elastic.co elasticsearch -o json |jq .status

Take the snapshot

After the previous step we have the source cluster ready to take the snapshot in the common storage account which is shared with the destination cluster. Now we can take the snapshot to restore it in the destination cluster later.

To do this we need to make a port-forward to the Elasticsearch pod/svc in the source cluster and, once we have the port-forward established, we can execute the following command to take the snapshot:

curl -XPUT "https://localhost:9200/_snapshot/aura_azure_backup/migration-elastic" -k -u 'elastic:XXXXXX' -d '{ "indices": "aurak8s-service*", "ignore_unavailable": "true", "include_global_state": "false", "metadata": { "taken_by": "aura" } }' -H 'Content-Type: application/json'

Check the snapshot status with the command:

curl "https://localhost:9200/_snapshot/aura_azure_backup/migration-elastic" -k -u 'elastic:XXXXXX' |jq '.snapshots[].state'

Once the snapshot is finished, put the repository in readonly mode as now the destination cluster will be the one using it:

curl -XPUT https://localhost:9200/_snapshot/aura_azure_backup -k -u 'elastic:XXXXXX' -d '{ "type": "azure", "settings": { "readonly": true, "container": "eck", "base_path": "elk", "chunk_size": "32m", "compress": true }}' -H 'Content-Type: application/json'

Restore the snapshot

Once the snapshot is taken, we can restore it in the destination cluster. To do this, make a port-forward to the Elasticsearch pod/svc in the destination cluster and once the port-forward is established, execute the following command to put the repository in readwrite mode:

curl -XPUT https://localhost:9200/_snapshot/aura_azure_backup -k -u 'elastic:XXXXXX' -d '{ "type": "azure", "settings": { "readonly": false, "container": "eck", "base_path": "elk", "chunk_size": "32m", "compress": true }}' -H 'Content-Type: application/json'

Now, we can restore the snapshot executing the following command:

curl -XPOST -H 'Content-Type: application/json' "https://localhost:9200/_snapshot/aura_azure_backup/migration-elastic/_restore" -k -u 'elastic:XXXXXX' -d '{
  "indices": "aurak8s-*",
  "rename_pattern": "(.+)",
  "rename_replacement": "$1-restored",
  "feature_states": [ "none" ]
  }'

This process will take a while. The cluster status will turn yellow during the restore. We can check the status with the command:

curl https://localhost:9200/_cluster/health -k -u 'elastic:XXXXXX' |jq