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 get upgraded to the next minor release, here from version 6.5.4 to 6.6.0. You can either surreptitiously change the version of each deployments in the Cloud UI or you can automate finding all the deployments at the specific version level and upgrading 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 avaible. If you need to add versions before trying out this example, see Manage Elastic Stack Versions.

You can search for clusters 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 cluster:

  1. Get a list of the deployments and find the Elasticsearch clusters that need upgrading, here My First Deployment:

    curl -k -X GET -u USER:PASSWORD https://COORDINATOR_HOST:12443/api/v1/clusters/elasticsearch?q=plan_info.current.plan.elasticsearch.version:6.5.4
    {
      "return_count": 1,
      "match_count": 1,
      "elasticsearch_clusters": [{
        "cluster_name": "My First Deployment",
    
      ...
    
              "elasticsearch": {
                "version": "6.5.4"
              },
    
              ...
    
        "cluster_id": "19a4462c52694cc7ae94a50cfacd6631",
    
        ...
    
    }
  2. For each of the clusters that you want to upgrade, obtain the JSON for the existing plan and save it to a file:

    curl -k -X GET -u USER:PASSWORD https://COORDINATOR_HOST:12443/api/v1/clusters/elasticsearch/ELASTICSEARCH_CLUSTER_ID/plan >upgrade_me.json
    ELASTICSEARCH_CLUSTER_ID
    The Elasticsearch cluster ID, here 19a4462c52694cc7ae94a50cfacd6631 for My First Deployment
  3. Modify the plan stored in upgrade_me.json. In this case, the line that specifies the version needs to be changed to read "version": "6.6.0":

    {
      "cluster_topology": [{
        "node_type": {
          "master": true,
          "data": true,
          "ingest": true
        },
        "zone_count": 3,
        "instance_configuration_id": "data.default",
        "size": {
          "value": 4096,
          "resource": "memory"
        }
      }, {
        "node_type": {
          "master": true,
          "data": false,
          "ingest": false
        },
        "zone_count": 1,
        "instance_configuration_id": "master",
        "size": {
          "value": 0,
          "resource": "memory"
        }
      }, {
        "node_type": {
          "master": false,
          "data": false,
          "ingest": false,
          "ml": true
        },
        "zone_count": 1,
        "instance_configuration_id": "ml",
        "size": {
          "value": 0,
          "resource": "memory"
        }
      }],
      "elasticsearch": {
        "version": "6.6.0"
      },
      "deployment_template": {
        "id": "default"
      }
    }
  4. Apply the new plan to effect a version upgrade:

    curl -k -XPOST -u USER:PASSWORD https://COORDINATOR_HOST:12443/api/v1/clusters/elasticsearch/$ELASTICSEARCH_CLUSTER_ID/plan -H 'content-type: application/json' -d @upgrade_me.json

    After the upgrade operation completes, the cluster will be at version 6.6.0.

  5. Optional: Repeat step 1 to verify that there are no more clusters at the old version that need to be upgraded:

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