|
1 | 1 | # Update
|
2 | 2 |
|
3 |
| -## Update node group size |
| 3 | +## Modify existing cluster |
| 4 | + |
| 5 | +You can add or remove node groups, resize existing node groups, and update some configuration fields of a running cluster. |
| 6 | + |
| 7 | +Fetch the current cluster configuration: |
4 | 8 |
|
5 | 9 | ```bash
|
6 |
| -cortex cluster scale --node-group <node-group-name> --min-instances <min-instances> --max-instances <max-instances> |
| 10 | +cortex cluster info --print-config --name CLUSTER_NAME --region REGION > cluster.yaml |
7 | 11 | ```
|
8 | 12 |
|
9 |
| -## Upgrade to a newer version |
| 13 | +Make your desired changes, and then apply them: |
10 | 14 |
|
11 | 15 | ```bash
|
12 |
| -# spin down your cluster |
13 |
| -cortex cluster down --name <name> --region <region> |
| 16 | +cortex cluster configure cluster.yaml |
| 17 | +``` |
| 18 | + |
| 19 | +Cortex will calculate the difference and you will be prompted with the update plan. |
| 20 | + |
| 21 | +If you would like to update fields that cannot be modified on a running cluster, you must create a new cluster with your desired configuration. |
| 22 | + |
| 23 | +## Upgrade to a new version |
| 24 | + |
| 25 | +Updating an existing Cortex cluster is not supported at the moment. Please spin down the previous version of the cluster, install the latest version of the Cortex CLI, and use it to spin up a new Cortex cluster. See the next section for how to do this without downtime. |
| 26 | + |
| 27 | +## Update or upgrade without downtime |
| 28 | + |
| 29 | +It is possible to update to a new version Cortex or to migrate from one cluster to another without downtime. |
| 30 | + |
| 31 | +Note: it is important to not spin down your previous cluster until after your new cluster is receiving traffic. |
| 32 | + |
| 33 | +### Set up a subdomain using a Route 53 hosted zone |
| 34 | + |
| 35 | +If you've already set up a subdomain with a Route 53 hosted zone pointing to your cluster, skip this step. |
| 36 | + |
| 37 | +Setting up a Route 53 hosted zone allows you to transfer traffic seamlessly from from an existing cluster to a new cluster, thereby avoiding downtime. You can find the instructions for setting up a subdomain [here](../networking/custom-domain.md). You will need to update any clients interacting with your Cortex APIs to point to the new subdomain. |
14 | 38 |
|
15 |
| -# update your CLI to the latest version |
16 |
| -pip install --upgrade cortex |
| 39 | +### Export all APIs from your previous cluster |
17 | 40 |
|
18 |
| -# confirm version |
| 41 | +The `cluster export` command can be used to get the YAML specifications of all APIs deployed in your cluster: |
| 42 | + |
| 43 | +```bash |
| 44 | +cortex cluster export --name <previous_cluster_name> --region <region> |
| 45 | +``` |
| 46 | + |
| 47 | +### Spin up a new cortex cluster |
| 48 | + |
| 49 | +If you are creating a new cluster with the same Cortex version: |
| 50 | + |
| 51 | +```bash |
| 52 | +cortex cluster up new-cluster.yaml --configure-env cortex2 |
| 53 | +``` |
| 54 | + |
| 55 | +This will create a CLI environment named `cortex2` for accessing the new cluster. |
| 56 | + |
| 57 | +If you are spinning a up a new cluster with a different Cortex version, first install the cortex CLI matching the desired cluster version: |
| 58 | + |
| 59 | +```bash |
| 60 | +# download the desired CLI version, replace 0.38.0 with the desired version (Note the "v"): |
| 61 | +bash -c "$(curl -sS https://github.com/raw/cortexlabs/cortex/v0.38.0/get-cli.sh)" |
| 62 | + |
| 63 | +# confirm Cortex CLI version |
19 | 64 | cortex version
|
20 | 65 |
|
21 |
| -# spin up your cluster |
22 |
| -cortex cluster up cluster.yaml |
| 66 | +# spin up your cluster using the new CLI version |
| 67 | +cortex cluster up cluster.yaml --configure-env cortex2 |
| 68 | +``` |
| 69 | + |
| 70 | +You can use different Cortex CLIs to interact with the different versioned clusters; here is an example: |
| 71 | + |
| 72 | +```bash |
| 73 | +# download the desired CLI version, replace 0.38.0 with the desired version (Note the "v"): |
| 74 | +CORTEX_INSTALL_PATH=$(pwd)/cortex0.38.0 bash -c "$(curl -sS https://github.com/raw/cortexlabs/cortex/v0.38.0/get-cli.sh)" |
| 75 | + |
| 76 | +# confirm cortex CLI version |
| 77 | +./cortex0.38.0 version |
| 78 | +``` |
| 79 | + |
| 80 | +### Deploy the APIs to your new cluster |
| 81 | + |
| 82 | +Please read the [changelogs](https://github.com/cortexlabs/cortex/releases) and the latest documentation to identify any features and breaking changes in the new version. You may need to make modifications to your cluster and/or API configuration files. |
| 83 | + |
| 84 | +```bash |
| 85 | +cortex deploy -e cortex2 <api_spec_file> |
| 86 | +``` |
| 87 | + |
| 88 | +After you've updated the API specifications and images if necessary, you can deploy them onto your new cluster. |
| 89 | + |
| 90 | +### Point your custom domain to your new cluster |
| 91 | + |
| 92 | +Verify that all of the APIs in your new cluster are working as expected by accessing via the cluster's API load balancer URL. |
| 93 | + |
| 94 | +Get the cluster's API load balancer URL: |
| 95 | + |
| 96 | +```bash |
| 97 | +cortex cluster info --name <new_cluster_name> --region <region> |
23 | 98 | ```
|
24 | 99 |
|
25 |
| -## Upgrade without downtime |
| 100 | +Once the APIs on the new cluster have been verified as working properly, it is recommended to update `min_replicas` of your APIs on the new cluster to match the current values in your previous cluster. This will avoid large sudden scale-up events as traffic is shifted to the new cluster. |
26 | 101 |
|
27 |
| -In production environments, you can upgrade your cluster without downtime if you have a backend service or DNS in front of your Cortex cluster: |
| 102 | +Then, navigate to the A record in your custom domains's Route 53 hosted zone and update the Alias to point the new cluster's API load balancer URL. Rather than suddenly routing all of your traffic from the previous cluster to the new cluster, you can use [weighted records](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy.html#routing-policy-weighted) to incrementally route more traffic to your new cluster. |
28 | 103 |
|
29 |
| -1. Spin up a new cluster. For example: `cortex cluster up new-cluster.yaml --configure-env cortex2` (this will create a CLI environment named `cortex2` for accessing the new cluster). |
30 |
| -1. Re-deploy your APIs in your new cluster. For example, if the name of your CLI environment for your existing cluster is `cortex`, you can use `cortex get --env cortex` to list all running APIs in your cluster, and re-deploy them in the new cluster by running `cortex deploy --env cortex2` for each API. Alternatively, you can run `cortex cluster export --name <previous_cluster_name> --region <region>` to export the API specifications for all of your running APIs, change directories the folder that was exported, and run `cortex deploy --env cortex2 <file_name>` for each API that you want to deploy in the new cluster. |
31 |
| -1. Route requests to your new cluster. |
32 |
| - * If you are using a custom domain: update the A record in your Route 53 hosted zone to point to your new cluster's API load balancer. |
33 |
| - * If you have a backend service which makes requests to Cortex: update your backend service to make requests to the new cluster's endpoints. |
34 |
| - * If you have a self-managed API Gateway in front of your Cortex cluster: update the routes to use new cluster's endpoints. |
35 |
| -1. Spin down your previous cluster. If you updated DNS settings, wait 24-48 hours before spinning down your previous cluster to allow the DNS cache to be flushed. |
36 |
| -1. You may now rename your new CLI environment name if you'd like (e.g. to rename it back to "cortex": `cortex env rename cortex2 cortex`) |
| 104 | +If you increased `min_replicas` for your APIs in the new cluster during the transition, you may reduce `min_replicas` back to your desired level once all traffic has been shifted. |
| 105 | + |
| 106 | +### Spin down the previous cluster |
| 107 | + |
| 108 | +After confirming that your previous cluster has completed servicing all existing traffic and is not receiving any new traffic, spin down your previous cluster: |
| 109 | + |
| 110 | +```bash |
| 111 | +# Note: it is recommended to install the Cortex CLI matching the previous cluster's version to ensure proper deletion. |
| 112 | + |
| 113 | +cortex cluster down --name <previous_cluster_name> --region <region> |
| 114 | +``` |
0 commit comments