Applying a new deployment configuration: Upgrade

edit

Applying a new deployment configuration: Upgrade

edit

One of the many useful aspects of an API is that you can automate changes across a large number of deployments. Let’s say you have many deployments that are at a specific version of the Elastic Stack that need to be upgraded to a later release. You can either manually change the version of each deployment through the Cloud UI, or you can automate finding all the deployments at the specific version level and then upgrade them through a script.

Before you begin

edit

This example requires a deployment with an Elasticsearch cluster to work with that is not being used for anything important. If you don’t already have one, you can follow our My First Deployment example to create one.

Each version of ECE ships with some versions of the Elastic Stack, but you can add new versions as they become available. If you need to add a new version before trying out this example, see Manage Elastic Stack versions, and then create a new deployment using the selected version. If you’re using environment variables, remember to set $DEPLOYMENT_ID to the ID of your new deployment.

You can search for deployments that are at a specific version through the RESTful API or you can iterate over the JSON output from the API to get the list you need, similar to what Step 1 shows.

Steps

edit

To upgrade a deployment:

  1. Use the _search endpoint to get a list of the deployments which have Elasticsearch resources that need upgrading. Here, we query for deployments on Elastic Stack version 7.12.1, and we find a deployment Upgrade Deployment. To test try this example, you can use the API or the UI to create a deployment on a previous stack version, and then search for it as shown:

    curl -k -X POST -H "Authorization: ApiKey $ECE_API_KEY" https://$COORDINATOR_HOST:12443/api/v1/deployments/_search -H 'content-type: application/json' -d '{
    "query": {
        "nested" : {
            "path" : "resources.elasticsearch",
            "query" : {
                "bool" : {
                    "must" : [{
                        "match" : {"resources.elasticsearch.info.plan_info.current.plan.elasticsearch.version" : { "query" : "7.12.1"}}
                    }]
                }
            }
        }
     },
     "size": 100,
     "sort": [{"metadata.last_modified": { "order": "desc"}}]
    }
    '
    {
      "return_count" : 1,
      "match_count" : 1,
      "deployments" : [
        {
          "id" : "DEPLOYMENT_ID",
          "name" : "Upgrade Deployment",
          "healthy" : true,
          "resources" : {
    
        ...
    
              "elasticsearch": {
                "version": "7.12.1"
              },
    
        ...
    
    }

    Just for reference, here is the same deployment in the UI:

    The Upgrade Deployment card in the ECE UI
  2. For each of the deployments that you want to upgrade, make a PUT request updating the version setting (in this case version is updated to 7.14.0). Note that both the elasticsearch and kibana resources are present in the request:

    curl -k -X PUT -H "Authorization: ApiKey $ECE_API_KEY" https://$COORDINATOR_HOST:12443/api/v1/deployments/$DEPLOYMENT_ID -H 'content-type: application/json' -d '
    {
      "prune_orphans": false,
      "resources": {
        "elasticsearch": [
          {
            "region": "ece-region",
            "ref_id": "main-elasticsearch",
            "plan": {
              "cluster_topology": [
                {
                  "id": "hot_content",
                  "node_roles": [
                    "data_hot",
                    "data_content",
                    "master",
                    "ingest",
                    "remote_cluster_client",
                    "transform"
                  ],
                  "zone_count": 1,
                  "elasticsearch": {
                    "enabled_built_in_plugins": [],
                    "node_attributes": {
                      "data": "hot"
                    }
                  },
                  "instance_configuration_id": "data.default",
                  "size": {
                    "value": 4096,
                    "resource": "memory"
                  }
                },
                {
                  "id": "warm",
                  "node_roles": [
                    "data_warm",
                    "remote_cluster_client"
                  ],
                  "zone_count": 1,
                  "elasticsearch": {
                    "enabled_built_in_plugins": [],
                    "node_attributes": {
                      "data": "warm"
                    }
                  },
                  "instance_configuration_id": "data.highstorage",
                  "size": {
                    "value": 0,
                    "resource": "memory"
                  }
                },
                {
                  "id": "cold",
                  "node_roles": [
                    "data_cold",
                    "remote_cluster_client"
                  ],
                  "zone_count": 1,
                  "elasticsearch": {
                    "enabled_built_in_plugins": [],
                    "node_attributes": {
                      "data": "cold"
                    }
                  },
                  "instance_configuration_id": "data.highstorage",
                  "size": {
                    "value": 0,
                    "resource": "memory"
                  }
                },
                {
                  "id": "coordinating",
                  "node_roles": [
                    "ingest",
                    "remote_cluster_client"
                  ],
                  "zone_count": 1,
                  "elasticsearch": {
                    "enabled_built_in_plugins": []
                  },
                  "instance_configuration_id": "coordinating",
                  "size": {
                    "value": 0,
                    "resource": "memory"
                  }
                },
                {
                  "id": "master",
                  "node_roles": [
                    "master",
                    "remote_cluster_client"
                  ],
                  "zone_count": 1,
                  "elasticsearch": {
                    "enabled_built_in_plugins": []
                  },
                  "instance_configuration_id": "master",
                  "size": {
                    "value": 0,
                    "resource": "memory"
                  }
                },
                {
                  "id": "ml",
                  "node_roles": [
                    "ml",
                    "remote_cluster_client"
                  ],
                  "zone_count": 1,
                  "elasticsearch": {
                    "enabled_built_in_plugins": []
                  },
                  "instance_configuration_id": "ml",
                  "size": {
                    "value": 0,
                    "resource": "memory"
                  }
                }
              ],
              "elasticsearch": {
                "version": "7.14.0"
              },
              "deployment_template": {
                "id": "default"
              },
              "autoscaling_enabled": false
            }
          }
        ],
        "kibana": [
          {
            "ref_id": "main-kibana",
            "elasticsearch_cluster_ref_id": "main-elasticsearch",
            "region": "ece-region",
            "plan": {
              "zone_count": 1,
              "cluster_topology": [
                {
                  "instance_configuration_id": "kibana",
                  "size": {
                    "value": 1024,
                    "resource": "memory"
                  },
                  "zone_count": 1
                }
              ],
              "kibana": {
                "version": "7.14.0"
              }
            }
          }
        ]
      }
    }
    '
    DEPLOYMENT_ID
    The deployment ID for the deployment that you want to upgrade.
  3. After the upgrade operation completes, the Elasticsearch and Kibana resource will be at version 7.14.0. You can confirm that by running:

    curl -k -X GET -H "Authorization: ApiKey $ECE_API_KEY" https://$COORDINATOR_HOST:12443/api/v1/deployments/$DEPLOYMENT_ID
            "elasticsearch" : {
              "version" : "7.14.0"
            },
            ...
            "kibana" : {
              "version" : "7.14.0",
            }

    You can also confirm the change in the UI:

    The Upgrade Deployment card in the ECE UI
  4. Optional: Repeat Step 1 to verify that there are no more deployments with Elasticsearch resources at the old version that need to be upgraded:

    {
      "return_count": 0,
      "match_count": 0,
      "deployments": []
    }

We recommend keeping all of the components in your deployments at the same version. For that reason, our upgrade example includes both enabled resources: elasticsearch and kibana. If a deployment includes other resources, such as APM & Fleet or Enterprise Search, they should also be part of the upgrade request.