# Update an installer installation

Upgrade an installation that the AWS or Google Cloud installer made to a new version, or change its settings, with the same installer.

The installer that made the installation also updates it: to a new version of Platforma, or to new settings. You give it all parameters of the installation again, so the installation stays the same except for what you change. On AWS, the stack keeps the parameters, and a change set shows what the update will change before it starts. On Google Cloud, you run `install.sh` again with the answers that you saved at the installation (see [Steps](/install-cloud-installer/#steps)). The database, the workspace (The storage where the Backend and all jobs keep the working files of running jobs. The Backend and the jobs use it at the same time. In Kubernetes, it is a network file system; in Single Server mode, it is a folder on the server.) and the results stay.

For an upgrade, this page replaces only the step “Upgrade” of [Upgrade Platforma](/maintain-upgrading/): do the steps before and after the upgrade there.

## Before you start

1. **For an upgrade, do the steps of [Before the upgrade](/maintain-upgrading/#before-the-upgrade)**: read the release notes, write down the version that runs now, check the health of the installation, tell the users and make a fresh backup.

2. **Have the parameters of the installation.**

   #### Variant: AWS installer

   The stack keeps all parameters. Have the values of the secret parameters in case you change them: the stack shows `****` for them. A changed secret value also needs a larger `SecretsRevision`. See the last step of the installation in [Steps](/install-cloud-installer/#steps).

   #### Variant: Google Cloud installer

   Have the file of the answers that you saved at the installation, for example `platforma-answers.sh`. The installer does not keep the answers: each run sends all of them again. If you do not have the file, write it again with the same values: the same `PROJECT_ID`, `DEPLOYMENT_NAME` and `IM_LOCATION`, the same sign-in providers (A configured way for users to sign in to the Backend: single sign-on (SSO), LDAP or a static list of users. One Backend can have more than one.) and the full list of data libraries (A folder or bucket with input data of the company. Users select files from it in the Desktop App. Platforma only reads it.). See the last step of the installation in [Steps](/install-cloud-installer/#steps).

3. **Have the rights of the installation.** An update needs the same rights as the installation: see [Permissions](/plan-permissions/). On Google Cloud, each run of `install.sh` needs the role `roles/config.admin` (Infrastructure Manager Admin). On AWS, the steps with `kubectl` also need an EKS access entry: see [Change a secret](/maintain-updating-cloud-installer/#change-a-secret). The installer checks its permissions first. When one is missing, it stops before it changes anything and shows the command that grants the role.

## Upgrade to a new version

#### Variant: AWS installer

A new release has a new template at the same address. The template holds the version of the Backend (The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs.), and the versions of the cluster services (Kueue (A Kubernetes add-on that holds jobs in a queue until the cluster has free CPU, memory and GPU for them.), AppWrapper (A Kubernetes add-on that wraps the pods of one job into a single unit, so that Kueue admits and starts them together.), Cluster Autoscaler, the load balancer controller and External DNS). With a change set, you see what the update changes before it starts.

1. **Create a change set.** In the CloudFormation console, select the stack and choose **Stack actions** → **Create change set for current stack**. Choose **Replace current template** → **Amazon S3 URL**, and paste the same template URL as for the installation: it always gives the last release.

   ```text
   https://platforma-cloudformation.s3.eu-central-1.amazonaws.com/cloudformation-eks-1-35.yaml
   ```

2. **Keep the parameters.** CloudFormation shows the current values: change only what you want to change. The secret parameters show `****` and keep their values. When `PlatformaVersion` has a value, clear it: a fixed version stays after the update, and an empty one gives the version of the new template.

3. **Accept and create.** Keep the stack options, accept that the stack makes IAM resources, and choose **Submit**. Result: the change set has the status `CREATE_COMPLETE`.

4. **Review the changes** on the tab **Changes**. Each line is a resource, with its action and whether CloudFormation replaces it:

   - `TriggerPlatformaDeploy` with the action **Modify**: the Backend gets the new version. `TriggerHelmDeploy` with **Modify**: the cluster services get new versions.
   - A node group (`NodeGroup` in the name, for example `SystemNodeGroupV5`) with the action **Modify**, **Add** or **Remove**: its nodes are replaced or removed, and the jobs (One run of a tool on data. The Backend starts jobs on the server where it runs, or in a Kubernetes cluster.) on them fail. Execute the change set when no job runs.
   - **Replacement** `True` for the cluster (`EksCluster`), the network (`Vpc`, the subnets), the bucket (`S3Bucket`) or the file system (`EfsFileSystem`): do not execute the change set. Delete it and contact MiLaboratories support.

5. **Execute the change set.** Choose **Execute change set**. Result: the status of the stack is `UPDATE_COMPLETE`.

To get each new version of the Backend, create a change set with this template again. Then do the checks of [After the upgrade](/maintain-upgrading/#after-the-upgrade).

#### Variant: Google Cloud installer

The release tag of `platforma-helm` sets the version: the installer deploys the chart `platforma` from the folder that you run it from, and the app version of this chart is the version of the Backend. The installer does not show the changes before it applies them. A new release can change the node pools of the cluster, and a job fails when its node stops. So run the upgrade when no job runs.

1. **Get the new release.** In Cloud Shell, select the project of the installation. In the folder `platforma-helm` of the installation, check out the new release tag:

   ```sh
   gcloud config set project <project>
   cd platforma-helm
   git fetch --tags
   git checkout <new release tag>
   cd infrastructure/gcp/cloudshell
   ```

   When the folder is not there any more, clone the new tag as in the installation steps.

2. **Run the installer with the saved answers:**

   ```sh
   source platforma-answers.sh
   bash install.sh
   ```

   The installer does not ask the answers that the file sets. When it asks a question, the file does not have that answer: give the value of the installation, and add it to the file.

3. **Check the review and confirm.** The line `Source:` shows the new release tag. `Project`, `Deployments` and the IM location must be those of the installation: with other values, the installer makes a second installation. Answer `y`. The installer updates the deployments `<name>-infra` and `<name>-platforma` with new revisions. Result: the installer shows `Done.`

Then do the checks of [After the upgrade](/maintain-upgrading/#after-the-upgrade).

## Change settings

To change a setting, run the update with the new value and all other values as before. The Configuration pages describe the Terraform modules (The Terraform code that MiLaboratories provides to install Platforma. The cloud-specific Terraform modules make the cluster and its cloud parts in AWS or Google Cloud; the cloud-agnostic Terraform modules install Platforma into the cluster.), the Helm chart `platforma-backend` and Single Server mode: for the AWS parameter and the Google Cloud variable of each setting, see [Settings and their parameters](/reference-installer-parameters/#settings-and-their-parameters).

#### Variant: AWS installer

1. In the CloudFormation console, select the stack and choose **Stack actions** → **Create change set for current stack** → **Use current template**.
2. Change only the parameters that you want to change: CloudFormation keeps the values of all others. When you change a secret parameter, also set `SecretsRevision` to a larger number. Accept that the stack makes IAM resources, and choose **Submit**.
3. Review the changes, as in [Upgrade to a new version](#upgrade-to-a-new-version), step 4, and execute the change set. Result: the status of the stack is `UPDATE_COMPLETE`.

To get a new version of Platforma at the same time, choose **Replace current template** instead: see [Upgrade to a new version](#upgrade-to-a-new-version).

#### Variant: Google Cloud installer

1. In Cloud Shell, go to the folder of the installer from the installation: `cd platforma-helm/infrastructure/gcp/cloudshell`. Keep the release tag of the installation; to change the version at the same time, see [Upgrade to a new version](#upgrade-to-a-new-version).
2. Change the value in the file of the saved answers, for example `export DEPLOYMENT_SIZE=medium`, and load the file: `source platforma-answers.sh`.
3. Run `bash install.sh`, check the review as in [Upgrade to a new version](#upgrade-to-a-new-version), step 3, and confirm. Result: the installer shows `Done.`

Before you change a setting, know these effects:

- **Secret parameters (AWS).** The stack keeps the values of the secret parameters in Secrets Manager, and the deployer of Platforma does not get them. Thus a change of a secret value alone does not apply it. In the same update, set `SecretsRevision` to a larger number: for example, from `1` to `2`. The secret parameters are `LicenseKey`, `HtpasswdContent`, `LdapSearchPassword`, `GoogleClientSecret`, and the access keys and secret keys of the data libraries. For each secret, see [Change a secret](/maintain-updating-cloud-installer/#change-a-secret).
- **Data libraries.** Give the full list each time. The installer removes the libraries that you leave out. To remove a library that projects use, see [Remove a data library](/maintain-removing-data-library/).
- **Sign-in providers.** When you add or remove a provider, all users must sign in (To show the Backend who you are, with a sign-in provider or a single-user token. The verb is "sign in"; the noun and the adjective are "sign-in".) again one time. To move users from one provider to another, see [Migrate between sign-in providers](/maintain-migrating-sign-in-providers/).
- **Deployment size.** On Google Cloud, a larger size makes new quota requests.
- **Settings that make new infrastructure.** On AWS: `ClusterName`, `PlatformaNamespace`, the VPC and subnet parameters, `S3BucketName` and `SystemNodeAZ`. On Google Cloud: `REGION` and `ZONE_SUFFIX`. A change of these settings replaces the cluster, the storage or the disks of the Backend: treat it as a new installation. On Google Cloud, a new `DEPLOYMENT_NAME`, `PROJECT_ID` or `IM_LOCATION` makes a second installation.

> **Changes outside the installer:**
>
> Change the settings only with the installer. The installer sets all values of the Helm release from its own settings, so the next run of the installer can remove a change that you made with Helm or `kubectl`.

## Change a secret

Change a secret with the installer that made the installation, not with `kubectl` alone. The next run of the installer writes its own values into the Secrets again. For the master secret, which signs out all users, see [Change the master secret](/configuration-users-and-roles/#change-the-master-secret).

Make the new key before you remove the old one. Keep the old key valid until the check is complete: at the identity provider, in the cloud of a data library or at the license service. Then remove the old key. A restart of the Backend is a short outage: see [Restart of the Backend](/configuration-storage/#restart-of-the-backend).

#### Variant: AWS installer

The stack keeps the secret parameters in AWS Secrets Manager, and the passwords that it makes in Parameter Store. The commands use the namespace `platforma`: with another `PlatformaNamespace`, use its value.

| Secret                                                                                                                                                                             | Where you change it                                                | Kubernetes (A system that runs programs on a group of machines (a cluster). Platforma can run in a Kubernetes cluster.) Secret | Restart of the Backend                                            |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------- |
| License key                                                                                                                                                                        | Parameter `LicenseKey`                                             | `platforma-license`                                                                                                            | Do step 3                                                         |
| Static list of users (A sign-in provider that is a file with the logins and the password hashes of the users, in the htpasswd format. The Backend reads it again when it changes.) | Parameter `HtpasswdContent`                                        | `platforma-htpasswd`                                                                                                           | Not necessary: the Backend reads the list again in 1 to 2 minutes |
| Password of the login `platforma` (administrator)                                                                                                                                  | Parameter Store, `/<ClusterName>/platforma/admin-password`         | `platforma-admin-htpasswd`                                                                                                     | Not necessary                                                     |
| Password of the list that the stack made when `HtpasswdContent` is empty                                                                                                           | Parameter Store, `/<ClusterName>/platforma/users-password`         | `platforma-htpasswd`                                                                                                           | Not necessary                                                     |
| LDAP (The directory of users of a company. The Backend can check logins and passwords in it.) search password                                                                      | Parameter `LdapSearchPassword`                                     | —                                                                                                                              | The stack update restarts the Backend                             |
| Google client secret                                                                                                                                                               | Parameter `GoogleClientSecret`                                     | `platforma-sso-client-secret`                                                                                                  | Do step 3                                                         |
| Keys of data library N (1 to 3)                                                                                                                                                    | Parameters `DataLibrary<N>AccessKey` and `DataLibrary<N>SecretKey` | `platforma-library-<N>-creds`                                                                                                  | Do step 3                                                         |

1. **For a password in Parameter Store only**, write the new value. Use the `ClusterName` and the `Region` of the stack:

   ```sh
   aws ssm put-parameter --name "/<ClusterName>/platforma/admin-password" \
     --type SecureString --overwrite --region <Region> --value '<new password>'
   ```

   For the other list, use `/<ClusterName>/platforma/users-password`.

2. **Update the stack with the current template.** Follow [Change settings](/maintain-updating-cloud-installer/#change-settings). Give the new value of each secret parameter that you change. Set `SecretsRevision` to a larger number than its value in the **Parameters** tab of the stack, for example from `1` to `2`. Without a larger `SecretsRevision`, the stack does not give the new value to the Backend. Result: the status of the stack is `UPDATE_COMPLETE`.

3. **Restart the Backend** when the table says so. The `kubectl` commands need an EKS access entry for your IAM principal: see [Access to the cluster](#access-to-the-cluster).

   ```sh
   aws eks update-kubeconfig --name <ClusterName> --region <Region>
   kubectl rollout restart --namespace platforma deployment/platforma
   kubectl rollout status --namespace platforma deployment/platforma
   ```

   Result: `deployment "platforma" successfully rolled out`.

4. **Check that the Backend uses the new value.** See [Check the change](#check-the-change).

#### Access to the cluster

The `kubectl` commands work only for an IAM principal with an EKS access entry of the cluster. The stack gives an access entry with the administrator rights of the cluster to the principal that created the stack. Another operator (The person who installs and runs Platforma in your company, for example an IT engineer or a bioinformatician.) makes an access entry for their own IAM role, with the rights of the installation (see [Permissions](/plan-permissions/)). This entry gives the role administrator rights in the namespace `platforma` only:

```sh
aws eks create-access-entry --cluster-name <ClusterName> --region <Region> \
  --principal-arn arn:aws:iam::<ACCOUNT_ID>:role/<role name>
aws eks associate-access-policy --cluster-name <ClusterName> --region <Region> \
  --principal-arn arn:aws:iam::<ACCOUNT_ID>:role/<role name> \
  --policy-arn arn:aws:eks::aws:cluster-access-policy/AmazonEKSAdminPolicy \
  --access-scope type=namespace,namespaces=platforma
```

Use the ARN of the IAM role, not the `assumed-role` ARN that `aws sts get-caller-identity` shows.

You can keep the static list of users yourself: the Secret `platforma-htpasswd`, with an empty parameter `HtpasswdContent`. The stack does not change such a Secret, so replace it with `kubectl`. See [Static list of users](/configuration-authentication/#static-list-of-users).

#### Variant: Google Cloud installer

The installer keeps each secret in Google Secret Manager. When a value changes, it adds a new version, writes the Kubernetes Secret again and restarts the Backend by itself.

| Secret                                            | Where you change it                                                                                      | Kubernetes Secret                     |
| ------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------- |
| License key                                       | `LICENSE_KEY` in the file of answers                                                                     | `platforma-license`                   |
| Static list of users                              | `HTPASSWD_FILE` (the path of the new file) or `HTPASSWD_CONTENT`, with `ENABLE_LOCAL_USERS=true`         | `platforma-htpasswd-provided`         |
| Password of the login `platforma` (administrator) | Secret Manager, `<DEPLOYMENT_NAME>-cluster-admin-password`                                               | `platforma-admin-htpasswd`            |
| LDAP search password                              | `LDAP_SEARCH_PASSWORD`                                                                                   | `platforma-ldap-search-password`      |
| Google client secret                              | `GOOGLE_CLIENT_SECRET`                                                                                   | `platforma-sso-client-secret`         |
| Keys of an S3 data library                        | `LIB_<N>_ACCESS_KEY` and `LIB_<N>_SECRET_KEY`, or `access_key` and `secret_key` in `DATA_LIBRARIES_JSON` | `platforma-datasource-<library name>` |

Change the values in the file of answers, not in Secret Manager: each run writes the values of the answers into Secret Manager again. The administrator password is the exception: it is not an answer.

1. **In Cloud Shell, go to the folder of the installer** of the installation: `cd platforma-helm/infrastructure/gcp/cloudshell`. Keep the release tag of the installation.

2. **Put the new value in place.** For an answer, change its line in the file of answers, for example `export LICENSE_KEY=<new license key>`. For the administrator password, add a new version in Secret Manager:

   ```sh
   printf '%s' '<new password>' | gcloud secrets versions add <DEPLOYMENT_NAME>-cluster-admin-password \
     --project=<PROJECT_ID> --data-file=-
   ```

3. **Run the installer** with the saved answers:

   ```sh
   source platforma-answers.sh
   bash install.sh
   ```

   For each changed answer, the installer shows `Stored <name> in Secret Manager.` before the review. For the administrator password, it shows `<DEPLOYMENT_NAME>-cluster-admin-password in Secret Manager is up to date.`: you added the version in step 2. Check the review and confirm. Then the installer shows `Kubernetes Secret <name> updated.` for each changed Secret. Result: the installer shows `Done.`

   The installer does not show a line about the restart of the Backend. The Backend starts again in about 1 minute. Check 2 of [Check the change](#check-the-change) shows it.

4. **Check that the Backend uses the new value.** See [Check the change](#check-the-change).

When you answer `n` at the review, the new versions stay in Secret Manager. The next run of the installer applies them.

### Check the change

Connect `kubectl` to the cluster. On AWS: `aws eks update-kubeconfig --name <ClusterName> --region <Region>`. On Google Cloud: `gcloud container clusters get-credentials <DEPLOYMENT_NAME>-cluster --location=<REGION>-<ZONE_SUFFIX> --project=<PROJECT_ID>`. Then do these checks:

1. The Kubernetes Secret holds the new value. Do this check for keys only. A Secret with a password holds a hash, so check a password when you sign in (check 3). For example, for the license key:

   ```sh
   kubectl get secret platforma-license --namespace platforma \
     -o jsonpath='{.data.MI_LICENSE}' | base64 -d; echo
   ```

   For the other Secrets, use the key of the Secret: `client-secret`, `password` (the LDAP search password), `access-key` or `secret-key`.

2. The Backend started after the change, where a restart is necessary. The `AGE` of its pod is shorter than the time since the change:

   ```sh
   kubectl get pods --namespace platforma \
     -l app.kubernetes.io/name=platforma,app.kubernetes.io/instance=platforma
   ```

3. The function works with the new value:

   - license key: `kubectl logs --namespace platforma deployment/platforma | grep "License is OK"` shows the line;
   - a password or a sign-in secret: sign in with the Desktop App (The program that each user installs on their own computer to work with Platforma. It is a client of the Backend.) as a user of that sign-in provider. For example, use the login `platforma` with the new administrator password;
   - keys of a data library: in the Desktop App, add a dataset from the library and see its files.

When the check is complete, remove the old key at its source.

## What an update keeps and restarts

An update keeps the data and the secrets of the installation: the database, the workspace, the primary storage (The bucket (Amazon S3 or Google Cloud Storage) or folder where Platforma keeps all results and uploaded files.) with the results, the master secret, and the passwords that the installer made. On AWS, these passwords are in Parameter Store, under `/<ClusterName>/platforma/`. On Google Cloud, they are in Secret Manager.

The Backend restarts only when its version or its values change: the old Backend stops, then the new one starts. The Desktop App loses its connection for a short time and connects again by itself, and jobs that run in the cluster continue.

#### Variant: AWS installer

The stack installs Platforma again only when the version or a parameter of Platforma changes: an update with the same values does not change Platforma. A changed secret parameter is an exception: the stack applies it only when `SecretsRevision` also gets a larger number (see [Change settings](#change-settings)). When the template has new versions of the cluster services, or other node groups, the stack also installs the cluster services again. A change of the infrastructure parameters changes only the infrastructure.

#### Variant: Google Cloud installer

Each run applies both deployments, `<name>-infra` and then `<name>-platforma`, and Terraform changes only what differs from the last revision. Between the two deployments, the installer writes the Kubernetes Secrets from Secret Manager, and shows `created`, `updated` or `unchanged` for each Secret.

The installer adds a new version of a secret in Secret Manager only when the value is different. A new version restarts the Backend; with the same values, the Backend does not restart. To change a secret, see [Change a secret](/maintain-updating-cloud-installer/#change-a-secret).

The installer uses the master secret that is in Secret Manager. Do not set `MASTER_SECRET` on an update: a new value replaces the master secret, and all users sign in again. To change the master secret on purpose, see [Change the master secret](/configuration-users-and-roles/#change-the-master-secret).

After an update, keep the folder of the new release. To uninstall later, use the `teardown.sh` of this release: the teardown must have the release of the last `install.sh` run. See [Uninstall an installer installation](/maintain-uninstalling-cloud-installer/).

## When the update fails

#### Variant: AWS installer

The stack waits 15 minutes until the new Backend is ready. If it is not, Helm deploys the old version again, and CloudFormation rolls back the update of the stack to the old template and parameters. Result: the status of the stack is `UPDATE_ROLLBACK_COMPLETE`. The events of the stack name the failed resource, and the log of the CodeBuild project `<ClusterName>-platforma-deployer` gives the reason.

> **A long database conversion can undo the upgrade:**
>
> The new Backend converts the database when it starts, before it is ready. When the conversion of a large database takes more than 15 minutes, the rollback deploys the old version, which cannot start on the converted database. If the stack update fails in this way, do not keep the old version: update the stack again with the new template and the same parameters, as in [Upgrade to a new version](#upgrade-to-a-new-version). The conversion continues from the last step that it finished. To go back to the old version, see [Go back to the old version](/maintain-upgrading/#go-back-to-the-old-version).

#### Variant: Google Cloud installer

The installer waits up to 30 minutes until the new Backend is ready. If it is not, the deployment has the state `FAILED`, and the installer shows the command that describes it. The installer does not go back to the old version: the new Backend continues to start. Its revision in Infrastructure Manager shows the error.

Fix the cause, then run `bash install.sh` again with the same answers: it updates the failed deployment. When the Backend was converting a large database, the conversion continues from the last step that it finished. When the installer says that the deployment is busy, wait until Infrastructure Manager finishes, then run it again.

To go back to the old version, see [Go back to the old version](/maintain-upgrading/#go-back-to-the-old-version).

## Next

- [Upgrade Platforma](/maintain-upgrading/)
- [Installer parameters](/reference-installer-parameters/)

Source: https://docs.platforma.bio/maintain-updating-cloud-installer/
