---
title: Manual upgrade steps by version
product: Self-Hosted Deployment
canonical: https://docs.unity.com/en-us/self-hosted-deployment/aws/maintenance/migration
last_updated: 2026-12-01
generated_at: 2026-12-01T22:13:07.340Z
locale: en-us
---

# Manual upgrade steps by version

> Complete the manual steps that each version of the AWS Terraform package needs in addition to the standard upgrade.

Use this page to complete the manual steps that an existing deployment of the AWS Terraform package needs when it upgrades to a release. These steps are in addition to the [standard upgrade](./upgrade.md). The newest release comes first, and a release that needs no such step has no section. For everything else that each release changes, refer to the [release notes](../release-notes).

When you upgrade across several releases, complete the section of every release after your current one, up to and including your target, oldest first.

## Version 1.5.0

### Decide which items apply to your deployment

Each move away from a data store is a maintenance window of its own. This order keeps each window short and checks each move before the next:

1. On your 1.4.x package, move Elasticsearch to Elastic Cloud on Kubernetes (ECK), including retiring the old cluster.
2. On your 1.4.x package, move MongoDB into the cluster. Change Keycloak's admin password in the console in the same window, as [Keep Keycloak's admin password](#keep-keycloak's-admin-password) describes.
3. Optionally, still on 1.4.x, move PostgreSQL from Amazon Relational Database Service (RDS) into the cluster, as [Move PostgreSQL on 1.4.x before you upgrade](#move-postgresql-on-1.4.x-before-you-upgrade) describes. The 1.5 window is then shorter. Until you upgrade, PostgreSQL backs up to a volume in the cluster, not to Amazon Simple Storage Service (S3), so keep RDS and its snapshot until the upgrade is verified.
4. Upgrade to this release in one window: the RabbitMQ queue check, the apply, the workflow artifacts copy, the collaboration data move, and PostgreSQL if it is still on RDS.

Most deployments need only some of the items in this section. Start at the top of the chart and follow the answers:

```mermaid
flowchart TD
    start([Upgrading to this release]) --> es{Still on the elasticsearch chart?}
    es -- yes --> esMove[Move Elasticsearch to ECK before you upgrade]
    esMove --> esVars
    es -- no --> esVars[Set enable_elasticsearch = false in your Terraform variables file]
    esVars --> mongo{MongoDB on a virtual machine,<br/>or outside the cluster?}
    mongo -- yes --> mongoMove[Move MongoDB into the cluster before you upgrade]
    mongoMove --> mongoVars
    mongo -- no --> mongoVars[Set enable_mongo = false in your Terraform variables file,<br/>and leave mongo_connection_uri unset]
    mongoVars --> keycloak[Keep Keycloak's admin password]
    keycloak --> miniusf[If your own workloads call Mini-USF,<br/>let them through its network policy]
    miniusf --> rabbit[Add missing RabbitMQ queue replicas<br/>before you run make apply]
    rabbit --> rds{PostgreSQL still on Amazon RDS?}
    rds -- yes --> when{Move it on 1.4.x first?}
    when -- yes --> early[Move PostgreSQL on 1.4.x before you upgrade]
    early --> after
    when -- no --> cutover[Move PostgreSQL during the 1.5 upgrade<br/>The same window includes the workflow artifacts copy<br/>and the collaboration data move]
    rds -- no --> moved{Moved it on 1.4.x?}
    moved -- yes --> after[Upgrade after you move PostgreSQL on 1.4.x]
    after --> plain
    moved -- no --> plain[Copy workflow artifacts before the deploy<br/>Move collaboration data to PostgreSQL during it]
```

The chart shows these decisions:

* If you still run the `elasticsearch` chart, move Elasticsearch to ECK first. Then set `enable_elasticsearch = false`.
* If MongoDB runs on a virtual machine or outside the cluster, move it into the cluster first. Then set `enable_mongo = false` and leave `mongo_connection_uri` unset.
* Keep Keycloak's admin password, let any workloads of your own that call Mini-USF connect through its network policy, and add missing RabbitMQ queue replicas before you run `make apply-<YOUR_REGION>`.
* If PostgreSQL still runs on Amazon RDS, choose whether to move it on 1.4.x first or during the 1.5 upgrade. If you already moved it on 1.4.x, upgrade after that move.
* Copy workflow artifacts before the deploy, and move collaboration data to PostgreSQL during it.

### Move Elasticsearch to ECK before you upgrade

This release always runs Elasticsearch on ECK, and no longer has the `elasticsearch` chart or the script that copies its data. Set `enable_elasticsearch = false` in your Terraform variables file (`tfvars/<YOUR_REGION>.tfvars`). The plan stops while the variable is missing or `true`.

To move Elasticsearch to ECK before you upgrade, complete these steps:

1. Before you extract this release, check whether your deployment still runs the `elasticsearch` chart:

   ```sh
   kubectl -n asset-solutions get statefulset elasticsearch-master
   ```

2. If the command finds the `StatefulSet`, use your 1.4.x package to complete [Migrate Elasticsearch to the ECK operator](#migrate-elasticsearch-to-the-eck-operator) first, including retiring the existing cluster.

3. If Argo CD deploys the charts, check that ECK has its credentials after the first reapply in that procedure, before you stop writes:

   ```sh
   kubectl -n asset-solutions get secret elasticsearch-apps-credentials
   ```

   Your 1.4.x `cluster-config` creates this `Secret` only during a sync operation, which Argo CD doesn't start when nothing else in `cluster-config` changed. If the `Secret` is missing, sync `cluster-config` once, either in the Argo CD UI or by running `argocd app sync cluster-config`, and check again. Without it, ECK has no `unity-apps` user, and the copy can't sign in.

4. Set `enable_elasticsearch = false` in your Terraform variables file, if it isn't already.

After you upgrade and verify the upgrade, complete these steps:

1. Delete the `elasticsearch-master-*` `PersistentVolumeClaim` objects, which this command lists:

   ```sh
   kubectl -n asset-solutions get pvc | grep elasticsearch-master
   ```

2. Delete the `PersistentVolume` objects that the claims leave `Released`, and the Amazon Elastic Block Store (EBS) volumes behind them, which the `gp3` storage class retains. The `spec.csi.volumeHandle` field of each `PersistentVolume` is the ID of its EBS volume.

### Move MongoDB into the cluster before you upgrade

This release always runs MongoDB in the cluster, as Percona Server for MongoDB (`psmdb-db`), and removes the Amazon Elastic Compute Cloud (EC2) instance that ran MongoDB, and its data volume. Terraform builds the in-cluster connection itself. Set `enable_mongo = false` in your Terraform variables file, and leave `mongo_connection_uri` unset. The plan stops while `enable_mongo` is missing or `true`, or while `mongo_connection_uri` is set in that file or as `TF_VAR_mongo_connection_uri`.

To move MongoDB into the cluster before you upgrade, complete these steps:

1. If your services still use the MongoDB EC2 instance (`enable_mongo` is `true` in your Terraform variables file), use your 1.4.x package to complete [Migrate your data to Percona Server for MongoDB](#migrate-your-data-to-percona-server-for-mongodb) before you extract this release.

2. If `mongo_connection_uri` points at a MongoDB outside the cluster, move that data into the cluster the same way.

3. Set `enable_mongo = false` in your Terraform variables file, if it isn't already.

4. Delete `mongo_connection_uri`.

   It names `psmdb-db-rs0` if you followed earlier steps that set it.

Your 1.4.x package created an `ExternalSecret` and a `SecretStore` for the MongoDB EC2 instance's certificate authority (CA) certificate. This release no longer declares them or writes the `mongo_pem_file` value they read, so the `ExternalSecret` reports `SecretSyncedError`, and nothing uses it. Neither Argo CD nor Helm removes them, because 1.4.x created them as Helm hooks.

After you upgrade and verify the upgrade, complete these steps:

1. Delete the `ExternalSecret`, and the `mongo-ca-certificate-pem` `Secret` goes with it:

   ```sh
   kubectl -n asset-solutions delete externalsecret mongo-ca-certificate-pem
   ```

2. Delete the `SecretStore`:

   ```sh
   kubectl -n asset-solutions delete secretstore mongo-ca-certificate-pem-secret-store
   ```

### Keep Keycloak's admin password

This item applies to every existing deployment. Keycloak's admin password now comes from the `keycloak_admin_password` Terraform variable, or a password Terraform generates when you leave it empty, but an existing deployment's Keycloak keeps the admin password it already has, which is `change-in-ui` unless you changed it. Until the two match, anything that signs in with the `keycloak-admin` secret's password is refused.

To keep Keycloak's admin password, complete these steps before you run `make apply-<YOUR_REGION>`:

1. If Keycloak's `admin` password is still `change-in-ui`, go to **Users** in the **master** realm of the Keycloak admin console.

   If you already changed the password, skip the steps that select `admin` and reset the password.

2. Select `admin`.

3. On the **Credentials** tab, reset the password with **Temporary** turned off.

4. In your Terraform variables file, set `keycloak_admin_password` to the password that the `admin` user has now.

### Let your own callers connect to Mini-USF through its network policy

This item applies if a workload of yours calls Mini-USF at `http://mini-usf:8080`. Mini-USF now has a `NetworkPolicy`. On its API port, 8080, it admits only pods in `asset-solutions` labeled `asset-solutions.unity.com/mini-usf-client: "true"`, which the package sets on its own callers, and the `upc-cli` admin pod (`run: upc-cli`). Its port 9090 serves only the metrics (`/metrics`) and the health check (`/health`), and admits every pod. If a scrape configuration of your own targets Mini-USF, change its port to 9090.

The policy takes effect only where the cluster's network plugin applies `NetworkPolicy`. The Amazon Virtual Private Cloud (VPC) Container Network Interface (CNI) plugin of the Amazon Elastic Kubernetes Service (EKS) cluster that this package creates doesn't, until you turn on its network policy support, as [Limit Pod traffic with Kubernetes network policies](https://docs.aws.amazon.com/eks/latest/userguide/cni-network-policy.html) in the Amazon EKS User Guide describes.

Before you run `make apply-<YOUR_REGION>`, let each of your own callers through, depending on where it runs:

* For a workload in `asset-solutions`, add the label to its pod template (`spec.template.metadata.labels`), not to its selector, because the selector of an existing `Deployment` can't change.
* For a workload in another namespace, add it to `allowFrom` in `applications/mini-usf/values.yaml`. Each key is a name you choose, each value a `NetworkPolicy` peer:

  ```yaml
  common-chart:
    networkPolicy:
      allowFrom:
        my-app:
          namespaceSelector:
            matchLabels:
              kubernetes.io/metadata.name: my-namespace
          podSelector:
            matchLabels:
              app.kubernetes.io/name: my-app
  ```

After the cluster applies `NetworkPolicy`, check that the policy refuses a pod without the label. The `upc-cli` image of your deployment has `curl`:

```sh
image=$(kubectl -n asset-solutions get jobs -o jsonpath='{..image}' | tr ' ' '\n' | grep -m1 upc-cli)
kubectl -n asset-solutions run np-test --rm -it --restart=Never --image="$image" \
  --command -- curl -sS -m 5 http://mini-usf:8080/health
```

The command times out after 5 seconds when the policy applies, and prints `Healthy` when it doesn't.

### Add missing RabbitMQ queue replicas before you upgrade

This item applies to every existing deployment. This release moves the EKS cluster to Kubernetes 1.35 in `make apply-<YOUR_REGION>`, which replaces every node, one at a time, and restarts every pod, RabbitMQ's included.

A RabbitMQ queue that was created while one of the RabbitMQ nodes was still starting can be missing a replica. A RabbitMQ pod that holds such a queue doesn't stop. It waits up to seven days for the replica. Its node then can't be drained, and `make apply-<YOUR_REGION>` fails on the node group update with `PodEvictionFailure`. From this release on, RabbitMQ adds missing replicas itself, but the node replacement runs before this release's RabbitMQ is deployed.

To check for missing queue replicas and add them, complete these steps before you run `make apply-<YOUR_REGION>` for this release:

1. Make sure that all the RabbitMQ pods are `Running` and ready.

2. Check each RabbitMQ pod:

   ```sh
   replicas=$(kubectl -n asset-solutions get statefulset rabbitmq-asset-solutions-server -o jsonpath='{.spec.replicas}')
   for i in $(seq 0 $((replicas - 1))); do
     kubectl -n asset-solutions exec rabbitmq-asset-solutions-server-$i -c rabbitmq -- rabbitmq-queues check_if_node_is_quorum_critical
   done
   ```

   A pod that reports `no queues/streams with minimum quorum` is fine. If every pod reports it, skip the rest of these steps.

3. If a pod lists a queue that `will become unavailable`, add the missing replicas on every node:

   ```sh
   replicas=$(kubectl -n asset-solutions get statefulset rabbitmq-asset-solutions-server -o jsonpath='{.spec.replicas}')
   for i in $(seq 0 $((replicas - 1))); do
     kubectl -n asset-solutions exec rabbitmq-asset-solutions-server-0 -c rabbitmq -- rabbitmq-queues grow rabbit@rabbitmq-asset-solutions-server-$i.rabbitmq-asset-solutions-nodes.asset-solutions all
   done
   ```

4. Run the check in step 2 (check each RabbitMQ pod) again.

If `make apply-<YOUR_REGION>` already failed on the node group update, and a RabbitMQ pod is stuck in `Terminating`, complete these steps:

1. Use the command from step 3 (add the missing replicas on every node) to add the missing replicas.

   The pod finishes stopping within a minute.

2. Run `make apply-<YOUR_REGION>` again.

   It resumes the node replacement.

### Copy workflow artifacts from RustFS to Amazon S3

This release stores workflow artifacts in an S3 bucket that Terraform creates (`argo-artifacts`), instead of the in-cluster RustFS, and no longer deploys Unity Studio. Its publications move to a `studio-assets` bucket that Terraform keeps as an archive, and the `publisher` database stays where it is. Copy RustFS's data after `make apply-<YOUR_REGION>` and before you deploy any chart of this release, including `cluster-config`, because the credentials that `cluster-config` deploys no longer reach RustFS, and the deploy removes RustFS.

If you also move PostgreSQL from RDS in this upgrade, do the copy in step 6 (copy the workflow artifacts) of [Move PostgreSQL during the 1.5 upgrade](#move-postgresql-during-the-1.5-upgrade). The platform is already stopped there, so one `migrate` is enough.

To copy the workflow artifacts, complete these steps:

1. Run `make apply-<YOUR_REGION>` for this release, but don't deploy its charts yet. If Argo CD deploys them, don't push the charts that `make apply-<YOUR_REGION>` wrote, and don't change your `ApplicationSet`, because an Application that leaves an `ApplicationSet` is deleted with everything it deployed, RustFS included.

2. From `aws/terraform`, read the names of the new buckets and set your region by running these commands:

   ```sh
   export STUDIO_ASSETS_BUCKET=$(terraform output -json | jq -r '.configuration.value.studio_assets_bucket')
   ```

   ```sh
   export ARGO_ARTIFACTS_BUCKET=$(terraform output -json | jq -r '.configuration.value.argo_artifacts_bucket')
   ```

   ```sh
   export AWS_REGION=<YOUR_REGION>
   ```

   The script uses your current `kubectl` context, and AWS credentials that can write to both buckets. Its header, in `aws/scripts/migrate-rustfs-to-s3.sh`, documents its options.

3. Compare the buckets:

   ```sh
   ../scripts/migrate-rustfs-to-s3.sh check
   ```

4. Copy what is missing:

   ```sh
   ../scripts/migrate-rustfs-to-s3.sh migrate
   ```

   `migrate` copies only what is missing, so you can run it again. The script doesn't copy workflow artifacts written to RustFS after the last `migrate`. Unless the platform is stopped, run `migrate` once more right before you deploy, in a maintenance window.

5. Compare the buckets again:

   ```sh
   ../scripts/migrate-rustfs-to-s3.sh check
   ```

   The last `check` exits with 0 when both buckets are in sync.

6. Deploy this release.

7. If you deploy with the direct Helm targets, remove the RustFS and Studio releases after `make helm-upgrade-<YOUR_REGION>`:

   ```sh
   helm -n asset-solutions uninstall rustfs studio-file-server studio-publisher-service
   ```

   Argo CD prunes them itself. Uninstalling deletes only the workloads, never the bucket or the database.

8. For either method, delete the `Secret` that nothing prunes:

   ```sh
   kubectl -n asset-solutions delete secret publisher-service-external-secrets
   ```

9. To keep a copy of Studio's publications, run `aws s3 sync "s3://$STUDIO_ASSETS_BUCKET" <LOCAL_DIRECTORY>`, where `STUDIO_ASSETS_BUCKET` holds the bucket name you read in step 2 (read the bucket names and set your region).

   Terraform still manages the bucket, so don't delete it by hand.

10. If PostgreSQL moves from RDS during this upgrade, run `pg_dump -d publisher` against RDS before you delete the instance, to keep a copy of Studio's `publisher` database.

    The `publisher` database isn't created in the cluster. If PostgreSQL moves from RDS during this upgrade, the database stays on RDS. If PostgreSQL ran in your cluster before this upgrade, the database stays there.

11. After you verify the deployment, delete the RustFS `PersistentVolumeClaim` objects, which this command lists:

    ```sh
    kubectl -n asset-solutions get pvc | grep rustfs
    ```

    They hold the RustFS data until you delete them. On a storage class that retains its volumes, such as `gp3`, also delete the `PersistentVolume` objects they leave `Released` and their EBS volumes.

### Move PostgreSQL from Amazon RDS into the cluster

This release runs PostgreSQL in the cluster (`pg-db`) instead of on Amazon RDS. This item applies to every deployment whose PostgreSQL runs on RDS, which is the default. If PostgreSQL ran in your cluster before you started (`enable_percona_postgres` in your 1.4.x Terraform variables file, and your services pointed at it), skip it, unless you moved it there on 1.4.x. In that case, follow only [Upgrade after you move PostgreSQL on 1.4.x](#upgrade-after-you-move-postgresql-on-1.4.x) in the 1.5 window.

The move is a cutover with downtime. You stop the platform, copy its databases from RDS into the cluster, and start it again on the copies. RDS isn't modified. This release stops managing it and leaves it running until you delete it yourself. In the cluster, PostgreSQL runs as three replicas on separate nodes, each requesting 2 CPU and 8 GiB of memory with a 400 GiB volume, and from this release backs up to a new S3 bucket.

Choose when to move PostgreSQL:

* [Move PostgreSQL on 1.4.x before you upgrade](#move-postgresql-on-1.4.x-before-you-upgrade) uses a window of its own on your 1.4.x package, then [Upgrade after you move PostgreSQL on 1.4.x](#upgrade-after-you-move-postgresql-on-1.4.x) in the 1.5 window. Each window is shorter, and you check the move before the upgrade.
* [Move PostgreSQL during the 1.5 upgrade](#move-postgresql-during-the-1.5-upgrade) uses one window, which also includes the workflow artifacts copy and the collaboration data move.

Both options use the same procedures for what they share. These are [Prepare for the maintenance window](#prepare-for-the-maintenance-window), then [Stop the platform](#stop-the-platform), [Start the copy pod](#start-the-copy-pod), [Copy and compare](#copy-and-compare), [Start the platform](#start-the-platform), and [Take a full backup](#take-a-full-backup), and afterwards [Clean up after the window](#clean-up-after-the-window).

#### Prepare for the maintenance window

To prepare for the maintenance window, complete these steps:

1. Measure the size of each database on RDS. From a machine that reaches RDS, run this query in `psql` as `assetsolutions`, using the `postgres_user_password` value in `asset-solutions/configuration` as the password:

   ```sql
   SELECT datname, pg_size_pretty(pg_database_size(datname)) FROM pg_database WHERE NOT datistemplate;
   ```

   The copy time depends on the size of each database.

2. Use the same access to measure the compressed dump of the largest database:

   ```sh
   pg_dump -Fc -d <DATABASE_NAME> | wc -c
   ```

   This command reads the database and writes nothing. The copy writes the dump to the disk of the copy pod's node, which needs that much free space, with a margin. The time the command takes is the copy's dump time. The restore rebuilds the indexes one at a time, so expect it to take several times longer. For example, a 68 GB database dumped to 4.7 GB in 16 minutes and took 86 minutes to restore in a test environment.

3. Make sure that three nodes can each take a PostgreSQL replica, or that the cluster autoscaler can add them.

4. Take a manual RDS snapshot:

   ```sh
   aws rds create-db-snapshot --db-instance-identifier asset-solutions-postgres --db-snapshot-identifier asset-solutions-postgres-before-1-5
   ```

   Keep the snapshot until you delete the instance.

5. In the 1.5 window, take an on-demand backup of MongoDB too, as [Move collaboration data to PostgreSQL](#move-collaboration-data-to-postgresql) shows, and wait until it is ready.

   Steps 13 and 14 (copy the collaboration data and check the copy) of the 1.5 upgrade procedure also copy the collaboration data from MongoDB into the cluster's PostgreSQL.

6. In the 1.5 window, decide whether the cutover also upgrades Kubernetes.

   This release moves the EKS cluster to Kubernetes 1.35 in the same `make apply-<YOUR_REGION>`, which replaces every node and restarts every pod. To keep the window short, set `eks_cluster_version = "1.34"` in your Terraform variables file for the cutover, and remove it in step 19 (remove `eks_cluster_version`) of the 1.5 upgrade procedure.

7. If Argo CD deploys the charts, prepare the `ApplicationSet` for the release you move on.

   Both releases add `pg-operator`, with the `ServerSideApply=true` sync option, and `pg-db`. This release also gives `pg-db` `RespectIgnoreDifferences=true` and an `ignoreDifferences` entry for `/spec/backups/pgbackrest/manual` of its `PerconaPGCluster` (group `pgv2.percona.com`), which the operator rewrites at every backup. Each release's `aws/scripts/generate-appsets.sh` writes its settings.

#### Stop the platform

If the platform is still stopped, as when you roll back right after you copy and compare the databases, skip this procedure, because recording the replica counts again would overwrite them with zeros.

To stop the platform, complete these steps:

1. If Argo CD deploys the charts, remove `automated` from the sync policy of your `ApplicationSet`, keep the original, and apply it.

   This turns off automated sync for every Application until you start the platform. Otherwise a sync could start the platform before you copy its data.

2. If Argo CD deploys the charts, check that no Application keeps `automated`:

   ```sh
   kubectl get applications -A -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,AUTOMATED:.spec.syncPolicy.automated'
   ```

3. Record the replica counts of the platform services and of Keycloak by running these commands:

   ```sh
   kubectl -n asset-solutions get deployment -l creator-services-app=asset-solutions -o custom-columns='NAME:.metadata.name,REPLICAS:.spec.replicas' --no-headers > replicas-before-1-5.txt
   ```

   ```sh
   kubectl -n asset-solutions get statefulset keycloak -o jsonpath='{.spec.replicas}{"\n"}'
   ```

4. Stop everything that writes to PostgreSQL, which is the platform services, Keycloak, and the Argo Workflows server and controller, by running these commands:

   ```sh
   kubectl -n asset-solutions scale deployment -l creator-services-app=asset-solutions --replicas=0
   ```

   ```sh
   kubectl -n asset-solutions scale statefulset keycloak --replicas=0
   ```

   ```sh
   kubectl -n asset-solutions scale deployment argo-workflows-server argo-workflows-workflow-controller --replicas=0
   ```

5. Check that RDS has no client connection left:

   ```sql
   SELECT datname, client_addr FROM pg_stat_activity WHERE usename = 'assetsolutions';
   ```

   Continue only when this query returns no row except your own session's.

#### Start the copy pod

The copy pod has the PostgreSQL client tools, from the image `pg-db` runs. `SKIP_DB` names the database the copy leaves out. In the 1.5 window it's `publisher`, where Studio is gone and its database stays on RDS. On 1.4.x it's `none`, where Studio still runs and its database moves too.

To start the copy pod, complete these steps:

1. Make sure that `SKIP_DB` is set in your shell, to `publisher` in the 1.5 window or `none` on 1.4.x.

   The step that starts the pod stops if `SKIP_DB` is unset.

2. Start a pod with the PostgreSQL client tools, from the image `pg-db` runs:

   ```sh
   : "${SKIP_DB:?set SKIP_DB first: publisher in the 1.5 window, none on 1.4.x}"
   RDS_HOST=$(aws rds describe-db-instances --db-instance-identifier asset-solutions-postgres --query 'DBInstances[0].Endpoint.Address' --output text)
   IMAGE=$(kubectl -n asset-solutions get perconapgcluster pg-db -o jsonpath='{.spec.image}')
   kubectl -n asset-solutions apply -f - <<EOF
   apiVersion: v1
   kind: Pod
   metadata:
     name: pg-copy
   spec:
     restartPolicy: Never
     imagePullSecrets:
       - name: asset-solutions-docker-credentials
     securityContext:
       runAsNonRoot: true
       runAsUser: 26
       runAsGroup: 26
       seccompProfile:
         type: RuntimeDefault
     containers:
       - name: pg-copy
         image: ${IMAGE}
         command: ["sleep", "infinity"]
         resources:
           requests: {cpu: 500m, memory: 512Mi}
           limits: {cpu: "2", memory: 2Gi}
         securityContext:
           allowPrivilegeEscalation: false
           capabilities:
             drop: ["ALL"]
         env:
           - name: RDS_HOST
             value: ${RDS_HOST}
           - name: SKIP_DB
             value: ${SKIP_DB}
           - name: PGUSER
             value: assetsolutions
           - name: PGPASSWORD
             valueFrom:
               secretKeyRef:
                 name: postgres-config-keycloak
                 key: password
   EOF
   kubectl -n asset-solutions wait --for=condition=Ready pod/pg-copy --timeout=5m
   ```

3. Check that the cluster accepts the `assetsolutions` user:

   ```sh
   kubectl -n asset-solutions exec pg-copy -- psql -h pg-db-primary -d postgres -c 'SELECT 1'
   ```

   Both RDS and the cluster accept the `assetsolutions` user with the password the pod uses.

4. In the 1.5 window, if step 3 (check that the cluster accepts the `assetsolutions` user) reports `password authentication failed`, empty the `verifier` key of the `pg-db-pguser-assetsolutions` `Secret` once:

   ```sh
   kubectl -n asset-solutions patch secret pg-db-pguser-assetsolutions --type merge -p '{"data":{"verifier":""}}'
   ```

   The operator then sets the user's password from that `Secret`.

5. If you emptied the `verifier` key, wait a minute, and then run the check in step 3 (check that the cluster accepts the `assetsolutions` user) again.

#### Copy and compare

To copy the databases and compare the copy, complete these steps:

1. Copy every database the platform created on RDS, Keycloak's and Argo Workflows' included, into the cluster:

   ```sh
   kubectl -n asset-solutions exec -i pg-copy -- bash -s <<'EOF'
   set -euo pipefail
   dbs=$(psql -h "$RDS_HOST" -d postgres -Atc "SELECT datname FROM pg_database WHERE NOT datistemplate AND datname NOT IN ('postgres', 'rdsadmin', '$SKIP_DB') ORDER BY 1")
   for db in $dbs; do
     echo "Copying $db"
     if [ -z "$(psql -h pg-db-primary -d postgres -Atc "SELECT 1 FROM pg_database WHERE datname = '$db'")" ]; then
       createdb -h pg-db-primary "$db"
     fi
     pg_dump -h "$RDS_HOST" -d "$db" -Fc --no-owner --no-acl -f "/tmp/$db.dump"
     pg_restore -h pg-db-primary -d "$db" --no-owner --no-acl --exit-on-error "/tmp/$db.dump"
     rm "/tmp/$db.dump"
   done
   EOF
   ```

   The command leaves out the database `SKIP_DB` names. It dumps one database at a time to the pod's disk, so the node needs free disk for the largest dump.

2. Compare the exact row count of every table on both sides:

   ```sh
   kubectl -n asset-solutions exec -i pg-copy -- bash -s <<'EOF'
   set -euo pipefail
   dbs=$(psql -h "$RDS_HOST" -d postgres -Atc "SELECT datname FROM pg_database WHERE NOT datistemplate AND datname NOT IN ('postgres', 'rdsadmin', '$SKIP_DB') ORDER BY 1")
   tables=0 mismatches=0
   for db in $dbs; do
     for table in $(psql -h "$RDS_HOST" -d "$db" -Atc "SELECT format('%I.%I', schemaname, tablename) FROM pg_tables WHERE schemaname NOT IN ('pg_catalog', 'information_schema') ORDER BY 1"); do
       rds=$(psql -h "$RDS_HOST" -d "$db" -Atc "SELECT count(*) FROM $table")
       cluster=$(psql -h pg-db-primary -d "$db" -Atc "SELECT count(*) FROM $table")
       tables=$((tables + 1))
       if [ "$rds" != "$cluster" ]; then
         echo "$db $table: $rds rows on RDS, $cluster in the cluster"
         mismatches=$((mismatches + 1))
       fi
     done
   done
   echo "$tables tables compared, $mismatches mismatches"
   EOF
   ```

   If any count differs, stop and [roll back](#roll-back-the-postgresql-move). The copy doesn't modify RDS.

#### Start the platform

To start the platform, complete these steps:

1. If Argo CD deploys the charts, apply your `ApplicationSet` with `automated` restored.

   Argo CD then syncs every Application, and prunes what the release removes.

2. If Argo CD deploys the charts, check that every Application is `Synced` and `Healthy`.

3. Use the replica counts you recorded to start the platform services again:

   ```sh
   while read -r name replicas; do kubectl -n asset-solutions scale deployment "$name" --replicas="$replicas"; done < replicas-before-1-5.txt
   ```

   A sync leaves a stopped service stopped, and so does its autoscaler. The command reports a service that the release removes as not found.

4. Check that Keycloak runs as many replicas as before:

   ```sh
   kubectl -n asset-solutions get statefulset keycloak
   ```

   If it doesn't, scale it to that count.

5. Check that you can sign in, list assets, run a transformation, and read a comment thread.

#### Take a full backup

The first backup that PostgreSQL took on its own ran before the copy, so it holds none of your data.

To take a full backup, complete these steps:

1. Create a full backup named after the window:

   ```sh
   kubectl -n asset-solutions apply -f - <<'EOF'
   apiVersion: pgv2.percona.com/v2
   kind: PerconaPGBackup
   metadata:
     name: pg-db-after-copy
   spec:
     pgCluster: pg-db
     repoName: repo1
     options:
       - --type=full
   EOF
   ```

   Give a repeated backup a new name.

2. Wait until `kubectl -n asset-solutions get perconapgbackup pg-db-after-copy` shows the backup `Succeeded`.

3. Check that the PostgreSQL backup bucket holds the backup, or on 1.4.x that the backup volume does.

#### Move PostgreSQL on 1.4.x before you upgrade

The platform keeps running until step 6 (start the maintenance window).

To move PostgreSQL on 1.4.x, use your 1.4.x package and its Terraform variables file to complete these steps:

1. Set `enable_percona_postgres` to `true` in your Terraform variables file.

2. Run `make apply-<YOUR_REGION>`.

3. Deploy the charts:

   * If Argo CD deploys the charts, push the charts it wrote and apply your `ApplicationSet` with `pg-operator` and `pg-db` added, as the last step of the maintenance window preparation describes.
   * If you deploy with the direct Helm targets, run `make helm-upgrade-<YOUR_REGION>`.

4. Wait until `kubectl -n asset-solutions get perconapgcluster pg-db` shows it `ready`.

   Nothing uses it yet.

5. Give the cluster's `assetsolutions` user the password it has on RDS.

   Your 1.4.x `pg-db` already declares that user, with a password of its own, and this release's keeps whatever password it has. Write RDS's password into the user's `Secret` and empty its `verifier`, so that the operator applies it, by running these commands in order:

   ```sh
   PW=$(kubectl -n asset-solutions get secret postgres-config-keycloak -o jsonpath='{.data.password}' | base64 -d)
   ```

   ```sh
   echo "${#PW} characters"
   ```

   The `echo` must print `24 characters`. Stop if it prints `0`.

   ```sh
   kubectl -n asset-solutions patch secret pg-db-pguser-assetsolutions --type merge -p "{\"stringData\":{\"password\":\"$PW\"},\"data\":{\"verifier\":\"\"}}"
   ```

   ```sh
   unset PW
   ```

   The operator applies the password within a minute, and the check that the cluster accepts the password, in step 3 of [Start the copy pod](#start-the-copy-pod), passes from then on.

6. Start the maintenance window, and [stop the platform](#stop-the-platform).

7. Set `SKIP_DB` to `none`:

   ```sh
   export SKIP_DB=none
   ```

8. [Start the copy pod](#start-the-copy-pod).

9. [Copy and compare](#copy-and-compare) the databases.

10. Set `postgres_server` to `pg-db-primary.asset-solutions.svc.cluster.local` in your Terraform variables file.

    Leave `enable_rds_postgres` as it is. RDS keeps running, and nothing modifies it.

11. Run `make apply-<YOUR_REGION>`.

12. If Argo CD deploys the charts, push the charts it wrote, still without `automated`.

13. Make the services' secrets read the new host now rather than at their next refresh:

    ```sh
    kubectl -n asset-solutions annotate externalsecrets --all force-sync=$(date +%s) --overwrite
    ```

14. Check one of the services' secrets:

    ```sh
    kubectl -n asset-solutions get secret postgres-config-keycloak -o jsonpath='{.data.host}' | base64 -d; echo
    ```

    It must print `pg-db-primary.asset-solutions.svc.cluster.local`.

15. If you deploy with the direct Helm targets, run `make helm-upgrade-<YOUR_REGION>`.

16. [Start the platform](#start-the-platform).

17. Check that RDS serves no service anymore. From the copy pod, run this query:

    ```sh
    kubectl -n asset-solutions exec pg-copy -- sh -c 'psql -h "$RDS_HOST" -d postgres -Atc "SELECT datname, client_addr FROM pg_stat_activity WHERE usename = current_user AND pid <> pg_backend_pid()"'
    ```

    The query returns no row.

18. [Take a full backup](#take-a-full-backup).

19. Delete the copy pod:

    ```sh
    kubectl -n asset-solutions delete pod pg-copy
    ```

    Keep RDS and your snapshot until you verify the 1.5 upgrade.

> **Warning:**
>
> Rolling back to RDS loses the writes made in the cluster after the copy.

To roll back to RDS, complete these steps:

1. [Stop the platform](#stop-the-platform), unless it is still stopped.

2. Remove `postgres_server` from your Terraform variables file.

3. Run `make apply-<YOUR_REGION>`.

4. Push or deploy the charts.

5. Run steps 13 and 14 (force-sync the services' secrets and check one of them). The check must print RDS's host.

6. [Start the platform](#start-the-platform).

The copied databases stay in the cluster. Before you copy again, on 1.4.x or in the 1.5 window, drop them with the command in step 3 (drop the copied databases in the cluster) of the rollback procedure.

#### Move PostgreSQL during the 1.5 upgrade

> **Warning:**
>
> After step 5 (run `make apply-<YOUR_REGION>` for this release), you can't apply the previous release's Terraform again. To undo the cutover, refer to [Roll back the PostgreSQL move](#roll-back-the-postgresql-move).

To move PostgreSQL during the 1.5 upgrade, complete these steps:

1. Start the maintenance window, and [stop the platform](#stop-the-platform).

2. Extract this release and update your Terraform variables file, as in [Upgrade your solution](./upgrade.md).

3. Run `make plan-<YOUR_REGION>`.

4. Check that the four RDS resources (the instance, its parameter group, its subnet group, and its security group) show as "will no longer be managed by Terraform", and that none is destroyed.

5. Run `make apply-<YOUR_REGION>`.

6. Copy the workflow artifacts now, before you deploy anything of this release, by completing steps 2 through 5 (set the variables, compare the buckets, copy what is missing, compare again) of [Copy workflow artifacts from RustFS to Amazon S3](#copy-workflow-artifacts-from-rustfs-to-amazon-s3).

7. Deploy the PostgreSQL operator, the configuration, and PostgreSQL, but nothing else yet:

   * If Argo CD deploys the charts, push the charts that `make apply-<YOUR_REGION>` wrote, apply this release's `ApplicationSet` with `automated` still removed, and then sync `pg-operator`, `cluster-config`, and `pg-db`, in this order.
   * If you deploy with the direct Helm targets, run this command from `aws/terraform`:

     ```sh
     for release in pg-operator cluster-config pg-db; do helm upgrade --install --dependency-update "$release" "../argocd/charts/<YOUR_REGION>/$release" --namespace asset-solutions --wait; done
     ```

     The charts are in `../argocd/charts/<ENVIRONMENT_DIRECTORY>/<YOUR_REGION>` if you set `ENV`, or in `TARGET_DIR` if you set it.

8. Wait until `kubectl -n asset-solutions get perconapgcluster pg-db` shows it `ready`.

   PostgreSQL has no data yet.

9. Set `SKIP_DB` to `publisher`:

   ```sh
   export SKIP_DB=publisher
   ```

10. [Start the copy pod](#start-the-copy-pod).

11. [Copy and compare](#copy-and-compare) the databases.

12. Run this release's database migrations on the copied data, and recreate Keycloak:

    * If Argo CD deploys the charts, sync the `asset-collaboration`, `authoring`, `automation`, `linksharing`, `mini-usf`, `public-api`, `secret-manager`, and `workspace-service` Applications. A sync runs their migration `Job` objects even when nothing else changed. Check that each succeeded by running `kubectl -n asset-solutions get jobs`. Then sync `keycloak`. It reports a sync error on its `StatefulSet`, whose fields can't change. Delete the `StatefulSet` by running `kubectl -n asset-solutions delete statefulset keycloak`, and sync `keycloak` again. Then sync `argo-workflows`.
    * If you deploy with the direct Helm targets, delete the Keycloak `StatefulSet` by running `kubectl -n asset-solutions delete statefulset keycloak`, and then deploy every chart and run the migrations by running `make helm-upgrade-<YOUR_REGION>`.

13. While every service is still at zero, run this command from the extracted package, with `kubectl` pointed at the cluster, to copy the collaboration data:

    ```sh
    ./common/scripts/collab-migration.sh copy
    ```

    This runs from the service's image and configuration, not from its pods, as the collaboration data procedure explains. The copy refuses to run while the service runs. It must exit 0.

14. Check the copy, before the service starts:

    ```sh
    ./common/scripts/collab-migration.sh check
    ```

    The check must run before the service starts, because the service's first start purges the comments deleted more than 30 days ago, which MongoDB still holds, and the check would report those. It must exit 0.

15. [Start the platform](#start-the-platform).

16. [Take a full backup](#take-a-full-backup).

17. Delete the copy pod:

    ```sh
    kubectl -n asset-solutions delete pod pg-copy
    ```

18. End the maintenance window.

19. If you set `eks_cluster_version = "1.34"` at the start, remove it.

20. If you removed `eks_cluster_version`, run `make apply-<YOUR_REGION>` and deploy again.

    This upgrades Kubernetes, about 4 minutes per node.

#### Upgrade after you move PostgreSQL on 1.4.x

To upgrade after you move PostgreSQL on 1.4.x, complete these steps:

1. In your Terraform variables file, delete `enable_percona_postgres` and `postgres_server`.

   Leave `postgres_user_password` unset. This release takes the password the cluster's `assetsolutions` user already has.

2. Run `make plan-<YOUR_REGION>`.

3. Check that the four RDS resources (the instance, its parameter group, its subnet group, and its security group) show as "will no longer be managed by Terraform", and that none is destroyed.

4. Upgrade as the standard upgrade describes.

   Complete [Copy workflow artifacts from RustFS to Amazon S3](#copy-workflow-artifacts-from-rustfs-to-amazon-s3) and [Move collaboration data to PostgreSQL](#move-collaboration-data-to-postgresql) in the same window.

5. Recreate Keycloak.

   This release changes its `StatefulSet` in fields that can't change in place.

   * If Argo CD deploys the charts, `keycloak` reports a sync error on its `StatefulSet`. Delete the `StatefulSet` by running `kubectl -n asset-solutions delete statefulset keycloak`, and sync `keycloak` again. Argo CD doesn't retry a failed sync by itself.
   * If you deploy with the direct Helm targets, delete the `StatefulSet` before you run `make helm-upgrade-<YOUR_REGION>`.

6. When the platform runs, [take a full backup](#take-a-full-backup) and name it `pg-db-after-upgrade`.

   Don't use the name the 1.4.x window used, because this release moves PostgreSQL's backups to the S3 bucket, which holds none yet.

7. After the backup shows `Succeeded`, delete the volume the 1.4.x backups used, which the operator released.

   On `gp3`, that is the `PersistentVolume` that `pg-db-repo1` released, and its EBS volume.

#### Clean up after the window

To clean up after the window, complete these steps at your own pace, when you no longer need RDS:

1. If PostgreSQL moved during the 1.5 upgrade and you want to keep Studio's data, run `pg_dump -d publisher` against RDS.

2. Take a final RDS snapshot.

3. Turn off the instance's deletion protection:

   ```sh
   aws rds modify-db-instance --db-instance-identifier asset-solutions-postgres --no-deletion-protection --apply-immediately
   ```

4. Delete the instance:

   ```sh
   aws rds delete-db-instance --db-instance-identifier asset-solutions-postgres --skip-final-snapshot
   ```

5. Delete its DB subnet group, DB parameter group, and security group. Terraform no longer manages any of them.

#### Roll back the PostgreSQL move

> **Warning:**
>
> A rollback that copies the data from RDS again loses the writes made in the cluster after the last copy.

* On 1.4.x, follow the rollback steps at the end of [Move PostgreSQL on 1.4.x before you upgrade](#move-postgresql-on-1.4.x-before-you-upgrade).
* After you complete [Upgrade after you move PostgreSQL on 1.4.x](#upgrade-after-you-move-postgresql-on-1.4.x), RDS holds your data only as of the 1.4.x copy, and you can't use the previous release's Terraform or the 1.4.x volume backups again. Contact support before you act. The only way to roll back is to copy from RDS again, as the rollback during the 1.5 upgrade after the apply describes, and every write after the 1.4.x window is lost.
* During the 1.5 upgrade, before you run `make apply-<YOUR_REGION>` for this release, [start the platform](#start-the-platform). Nothing else has changed.
* During the 1.5 upgrade, after the apply, you can't apply the previous release's Terraform again, because this release moves resources within the Terraform state and creates others that the previous release doesn't know. Copy the data from RDS again instead, while the instance exists.

If you roll back during the 1.5 upgrade after the apply, complete these steps:

1. [Stop the platform](#stop-the-platform) again, unless it is still stopped.

2. If you deleted the copy pod, start it again, as in [Start the copy pod](#start-the-copy-pod).

3. Drop the copied databases in the cluster:

   ```sh
   kubectl -n asset-solutions exec -i pg-copy -- bash -s <<'EOF'
   set -euo pipefail
   dbs=$(psql -h "$RDS_HOST" -d postgres -Atc "SELECT datname FROM pg_database WHERE NOT datistemplate AND datname NOT IN ('postgres', 'rdsadmin', '$SKIP_DB') ORDER BY 1")
   for db in $dbs; do dropdb -h pg-db-primary --if-exists --force "$db"; done
   EOF
   ```

4. Repeat the steps of [Move PostgreSQL during the 1.5 upgrade](#move-postgresql-during-the-1.5-upgrade) from step 9 (set `SKIP_DB` to `publisher`), and give the backup a new name.

### Move collaboration data to PostgreSQL

This release moves the collaboration service's data (comments, annotations, their attachments, and read receipts) from MongoDB into the cluster's PostgreSQL, in a new `collaboration` database the `pg-db` chart creates. The sync creates the tables. The copy is a step of this upgrade that you run once, after the sync and with the service stopped. A comment written while the copy runs would never reach PostgreSQL, and nobody can read or write comments from the moment you stop the service until you start it again. Sync this release during a maintenance window and tell your users.

If this upgrade also moves PostgreSQL from Amazon RDS into the cluster, [Move PostgreSQL during the 1.5 upgrade](#move-postgresql-during-the-1.5-upgrade) covers this move too, in order. Its step 1 (start the maintenance window and stop the platform) stops the collaboration service with the rest, step 7 (deploy the PostgreSQL operator, the configuration, and PostgreSQL) starts `pg-db` with the `collaboration` database, steps 13 and 14 (copy the collaboration data and check the copy) run this copy and its check, and step 15 (start the platform) starts the service again. Step 5 (take an on-demand backup of MongoDB) of [Prepare for the maintenance window](#prepare-for-the-maintenance-window) is the MongoDB backup. The rest of this section describes what the copy does and how to roll back.

To move the collaboration data to PostgreSQL, complete these steps:

1. Before you sync, create an on-demand backup of MongoDB:

   ```sh
   backup=$(kubectl -n asset-solutions create -o name -f - <<'EOF'
   apiVersion: psmdb.percona.com/v1
   kind: PerconaServerMongoDBBackup
   metadata:
     generateName: before-upgrade-
   spec:
     clusterName: psmdb-db
     storageName: s3-primary
   EOF
   )
   ```

   It goes to the backup storage your 1.4.x `psmdb-db` names `s3-primary`, which this release renames `managed`.

2. Wait until the backup is ready:

   ```sh
   kubectl -n asset-solutions wait "$backup" --for=jsonpath='{.status.state}'=ready --timeout=60m
   ```

3. Stop the collaboration service, from the extracted package with `kubectl` pointed at the cluster:

   ```sh
   ./common/scripts/collab-migration.sh stop
   ```

   The command scales its `Deployment` to zero and waits for its pods to stop. Its autoscaler takes no action while the `Deployment` is at zero, and the sync leaves it there, so the service stays stopped until you start it again in step 7 (start the service).

4. Sync this release as you usually do, either in Argo CD or by running `make helm-upgrade-<YOUR_REGION>`.

   The sync creates the tables, in the `asset-cloud-collaboration-service-migration-schema` `Job` that runs ahead of the service's new pods and retries on its own while `pg-db` is still creating the database, and it leaves the service stopped.

5. After the sync completes, copy the documents:

   ```sh
   ./common/scripts/collab-migration.sh copy
   ```

   The copy runs the migration tool from the service's image and configuration, not from its pods, so it needs none running. It refuses to run while one does, or before you sync this release.

   It runs from a short-lived `Job`, reads every MongoDB document, inserts what PostgreSQL lacks, and prints the tool's summary, which lists the counts per collection and any documents it couldn't copy. It took 17 minutes for 50,000 comments in a test environment, in three passes, because the tool retries a reply on the next pass when it reads the reply before its thread. The script waits up to two hours (`TIMEOUT`, in seconds). Exit code 0 means the script copied every document. Exit code 1 means it couldn't copy some documents, which its log names, so keep that log and contact support. Exit code 2 means it couldn't run, and it says why. You can run it again, because it copies nothing twice.

6. Check the copy document by document, still before you start the service again:

   ```sh
   ./common/scripts/collab-migration.sh check
   ```

   The check must run before the service starts, because the service's first start purges the comments deleted more than 30 days ago, which MongoDB still holds, and the check would report those.

   It compares every MongoDB document with its PostgreSQL row and changes nothing in either store. Exit code 0 means every document matches. Exit code 1 means it found differences, which its log lists, so keep that log and contact support. Exit code 2 means the check couldn't run. Run it only once, because every comment written after the upgrade exists only in PostgreSQL, and a later run reports those comments as differences.

7. Start the service again:

   ```sh
   ./common/scripts/collab-migration.sh start
   ```

   Its autoscaler then controls the number of replicas.

Contact support before you roll back.

If you have to roll back after the upgrade, don't deploy an earlier release. To switch the collaboration service to MongoDB instead, complete these steps:

1. In `applications/asset-collaboration/values.yaml`, switch the collaboration service to MongoDB:

   ```yaml
   common-chart:
     configMaps:
       asset-collaboration-service:
         data:
           CollaborationServiceDataAccessSettings__Implementation: MongoDb
   ```

2. Sync again.

   The service then reads and writes MongoDB again, which still holds everything it held before the upgrade. Comments written after the upgrade stay in PostgreSQL and aren't shown until you switch the service to PostgreSQL again.

To switch the service to PostgreSQL again, complete these steps:

1. Set the value to `Postgresql`.

2. Stop the service, as step 3 (stop the collaboration service) shows.

3. Sync, as step 4 (sync this release) shows.

4. Run the copy once more, as step 5 (copy the documents) shows.

   The copy adds the comments written on MongoDB in the meantime, but not the edits made to older threads during that time.

5. Start the service, as step 7 (start the service) shows.

The MongoDB collections stay in place for now, and a later release removes them.

## Version 1.4.0

### Migrate Elasticsearch to the ECK operator

The `elasticsearch` `StatefulSet` chart is deprecated, and release 1.5.0 removes it.

You need to migrate to ECK. There's no data loss or downtime, but expect a brief write pause during the final copy, because the procedure scales `asset-catalog-writer` to zero while the script copies the data.

#### Plan capacity for the parallel run

Plan capacity for the parallel run of the ECK and existing Elasticsearch.

The ECK cluster needs about 5.5 CPU and 22 GiB of memory. This is in addition to the existing cluster, until you retire it. In total, you need three dedicated primary nodes and two data nodes at 4 CPU and 8 GiB limits, sized so that org-wide asset search stays fast.

#### Upgrade

To migrate Elasticsearch to ECK, complete these steps:

1. Upgrade to this release and set `enable_elasticsearch_eck = true`.

2. Run `make apply-<YOUR_REGION>`.

3. Deploy the regenerated charts, either by running `make helm-upgrade-<YOUR_REGION>` or by syncing in your GitOps tool.

   In this procedure, *reapply* means running `make apply-<YOUR_REGION>`, then deploying the regenerated charts.

   The ECK operator and an empty `elastic-eck-cluster` start alongside your existing Elasticsearch.

   Catalog services keep using the existing cluster, so nothing changes yet.

4. If Argo CD deploys the charts through an `ApplicationSet` that lists them, add `elasticsearch-eck-operator` and `elasticsearch-eck` to it, as `make apply-<YOUR_REGION>` now writes them.

5. Stop writes during the copy:

   ```sh
   kubectl scale deploy/asset-catalog-writer --replicas=0 -n asset-solutions
   ```

6. Copy your data into the ECK cluster. Run the command from `aws/terraform`, where you run `make`. It streams `aws/scripts/elasticsearch-reindex.sh` from the 1.4 package.

   The script runs as a one-shot pod streamed over standard input, and uses the public `nicolaka/netshoot` debug image for its `bash`, `curl`, and `jq` tooling.

   If your nodes can't pull from Docker Hub, substitute any image that has those three tools.

   The command injects the Elasticsearch password from the `elasticsearch-apps-credentials` `Secret`, so it never appears in your shell or in the pod spec:

   ```sh
   kubectl run es-reindex -n asset-solutions --restart=Never --rm -i \
    --pod-running-timeout=10m \
    --image=docker.io/nicolaka/netshoot:v0.14 \
    --overrides='{
     "spec": {
       "securityContext": {"runAsNonRoot": true, "runAsUser": 1001, "runAsGroup": 1001, "seccompProfile": {"type": "RuntimeDefault"}},
       "containers": [{
         "name": "es-reindex",
         "image": "docker.io/nicolaka/netshoot:v0.14",
         "stdin": true,
         "stdinOnce": true,
         "command": ["bash", "-s"],
         "securityContext": {"allowPrivilegeEscalation": false, "capabilities": {"drop": ["ALL"]}},
         "resources": {"requests": {"cpu": "100m", "memory": "128Mi"}, "limits": {"cpu": "500m", "memory": "256Mi"}},
         "env": [{"name": "ELASTIC_PASSWORD", "valueFrom": {"secretKeyRef": {"name": "elasticsearch-apps-credentials", "key": "password"}}}]
       }]
     }
    }' < ../scripts/elasticsearch-reindex.sh
   ```

   To pass the optional overrides, add them to the `env` array. For example, pass `{"name": "DST_SHARDS", "value": "2"}`. The optional overrides are `DST_SHARDS`, `DST_REPLICAS`, `SRC`, `DST`, and `ES_USER`. The script header documents each one.

   Each index's shard count is based on its actual data size, with one primary shard for each started 25 GB and one replica. Set `DST_SHARDS` and `DST_REPLICAS` if you need a specific layout.

   While the script looks for each index on ECK, a `curl: (22) … 404` is expected. The script compares each index's document count on both clusters itself, and ends with `Reindex complete.`. The document counts that `_cat/indices` shows are higher, because it also counts nested documents.

   Re-running the script only creates indices that are missing on the destination. An index that already exists there keeps its current shard layout, and the script reports it. To recreate such an index with a new layout, delete it on the destination first.

7. Set `use_eck_elasticsearch = true` to cut over.

8. Reapply, so catalog services take the ECK endpoint.

9. Scale `asset-catalog-writer` back up, to your `kubernetes_pod_min_replicas` (2 by default), because its autoscaler stays off while it is at 0.

10. Verify search and catalog operations.

11. Retire the existing cluster by setting `enable_elasticsearch = false` and reapplying.

    * If Argo CD deploys the charts through an `ApplicationSet` that lists them, remove `elasticsearch` from it.
    * If you deploy with the direct Helm targets, run `helm -n asset-solutions uninstall elasticsearch` once to uninstall the release.

Release 1.5.0 removes the existing chart. After you upgrade to it, you can delete the old `elasticsearch-master-*` `PersistentVolumeClaim` objects to reclaim storage.

#### Roll back an Elasticsearch migration

To roll back before you scale `asset-catalog-writer` up again, set `use_eck_elasticsearch = false` and reapply. Catalog services return to the still-running existing cluster with no data loss.

If you've started writing against the ECK cluster, the existing cluster is stale. If you roll back at this point, catalog services return to a dataset that's missing everything written after cutover. You must copy the new data before you roll back. To copy it, complete these steps:

1. Stop writes again.

2. Delete the affected indices on the existing cluster (the script skips indices that already exist on the destination).

3. Re-run the script with `SRC` and `DST` swapped.

4. Set `use_eck_elasticsearch = false` and reapply.

### Move Unity Licensing Server storage to EBS

The Unity Licensing Server data volume (`licserver-data`) doesn't provision to Amazon Elastic File System (EFS) anymore. It now provisions on EBS block storage. The `kubernetes_ebs_storage_class_name` variable sets the storage class, and it defaults to `gp3`.

Because `StatefulSet` volume claims are immutable, you must move the volume manually. To move it, complete these steps:

1. Choose how to keep your licensing data, before you delete anything:
   * Request and import a new license bundle after the upgrade. No data backup is required. For more information, refer to [Licensing](../../admin/licensing/_index).
   * Use `common/scripts/migrate-licserver-storage.sh` to keep your existing license data. The script header documents its usage. Run `backup` now, while the original volume still exists. The backup reads the volume the `StatefulSet` has bound.
2. If a GitOps tool such as Argo CD manages the deployment, pause its reconciliation of the `license-server` application.
3. Delete the `unity-licensing-server` `StatefulSet` and its `licserver-data-unity-licensing-server-0` volume claim.
4. Deploy this release.
5. Import your new license bundle, or, if you backed up your data, run the script's `restore` into the new volume.

## Version 1.3.0

### Migrate Mini-USF from version 1 to version 2

You must migrate Mini-USF from version 1 to version 2, due to architectural changes that decouple Keycloak from entities such as projects. This section describes the required steps.

#### Complete the steps before the migration

Before the migration, while the application still uses Mini-USF v1, complete the procedures in this section.

##### Recreate the service accounts

Recreate the service accounts that you had created directly in Keycloak as clients instead of using Unity Dashboard, because all service accounts must follow the common Unity model. To do so, complete these steps:

1. In Unity Dashboard, create the new service accounts that you will use instead of the old ones.

2. Create a key for each new account in Unity Dashboard, and save the secrets.

   The key names use the universally unique identifier (UUID) format instead of the free-form names that the previous keys used.

3. Assign the required roles to these accounts.

4. Replace the keys of the old accounts with the keys of the new accounts wherever you use the service accounts, for example, in scripts or in pipelines.

##### Run the migration tool in dry run mode

Prepare the migration tool to run against the installation of Self-Hosted Deployment and run it in dry run mode. To do so, complete these steps:

1. To deploy the migration tool in dry run mode, run this command:

   ```sh
   kubectl run migrator-tool -n asset-solutions \
    --image=uccmpprivatecloud.azurecr.io/docker/migrator:2026.13.19 \
    --restart=Never \
    --attach \
    --rm -it \
    --overrides='{
     "spec": {
       "securityContext": {
         "runAsNonRoot": true,
         "runAsUser": 1000,
         "runAsGroup": 1000,
         "fsGroup": 1000
       },
       "imagePullSecrets": [{"name": "asset-solutions-docker-credentials"}],
       "containers": [{
         "name": "migrator-tool",
         "image": "uccmpprivatecloud.azurecr.io/docker/migrator:2026.13.19",
         "resources": {
           "limits": {"cpu": "1", "memory": "1Gi"},
           "requests": {"cpu": "200m", "memory": "512Mi"}
         },
         "envFrom": [
           {"secretRef": {"name": "mini-usf"}}
         ],
         "env": [
           {"name": "MINIUSF_DryRun", "value": "true"},
           {"name": "MINIUSF_MigrateEntities", "value": "true"},
           {"name": "MINIUSF_MigrateRoleAssignments", "value": "true"},
           {"name": "ASPNETCORE_ENVIRONMENT", "value": "Production"},
           {"name": "MINIUSF_Keycloak_Realm", "value": "unity"},
           {"name": "MINIUSF_Keycloak_EventType", "value": "LOGIN"},
           {"name": "MINIUSF_Keycloak_EventsMaxNumber", "value": "10000"},
           {"name": "MINIUSF_Keycloak__RealmPathPrefix", "value": "auth/realms"},
           {"name": "MINIUSF_Keycloak__RealmAdminPathPrefix", "value": "auth/admin/realms"},
           {"name": "MINIUSF_Jwt__Issuer", "value": "http://keycloak"},
           {"name": "MINIUSF_Jwt__HttpsRequired", "value": "false"},
           {"name": "MINIUSF_Jwt__RealmPathPrefix", "value": "auth/realms"},
           {"name": "MINIUSF_Keycloak__BaseUri", "value": "http://keycloak"}
         ]
       }]
     }
   }'
   ```

   > **Note:**
   >
   > The migration tool might print this warning:
   >
   > ```text
   > Cannot load library libgssapi_krb5.so.2
   > Error: libgssapi_krb5.so.2: cannot open shared object file: No such file or directory
   > ```
   >
   > You can ignore this warning.

2. Check that the tool runs successfully, and fix any reported errors.

#### Complete the migration

##### Prepare to start the migration

To prepare for the migration, complete these steps:

1. Block the network access to the solution for users. To do so, you can temporarily take down the DNS route, because administrators who perform the migration still need access.

2. To disable the cron jobs of the `upc-cronjob` release, which include the identity sync, run this command:

   ```sh
   helm uninstall upc-cronjob -n asset-solutions
   ```

3. To uninstall Mini-USF, run this command:

   ```sh
   helm uninstall mini-usf -n asset-solutions
   ```

4. Back up the PostgreSQL instance that Keycloak and Mini-USF use.

##### Perform the migration

###### Perform the first part of the migration

If an operation fails and you can't fix it, stop the migration and perform the [post-migration steps](#complete-the-steps-after-the-migration). You don't need to perform a rollback at this stage.

To complete the first part of the migration, complete these steps:

1. Run the migration tool in dry run mode. Check that it runs successfully, and fix any reported errors.

2. Run the migration tool in full mode.

   The tool copies information from Keycloak to the Mini-USF database, while Keycloak data remains intact.

   To run the migration tool in full mode, run this command:

   ```sh
   kubectl run migrator-tool -n asset-solutions \
    --image=uccmpprivatecloud.azurecr.io/docker/migrator:2026.13.19 \
    --restart=Never \
    --attach \
    --rm -it \
    --overrides='{
     "spec": {
       "securityContext": {
         "runAsNonRoot": true,
         "runAsUser": 1000,
         "runAsGroup": 1000,
         "fsGroup": 1000
       },
       "imagePullSecrets": [{"name": "asset-solutions-docker-credentials"}],
       "containers": [{
         "name": "migrator-tool",
         "image": "uccmpprivatecloud.azurecr.io/docker/migrator:2026.13.19",
         "resources": {
           "limits": {"cpu": "1", "memory": "1Gi"},
           "requests": {"cpu": "200m", "memory": "512Mi"}
         },
         "envFrom": [
           {"secretRef": {"name": "mini-usf"}}
         ],
         "env": [
           {"name": "MINIUSF_DryRun", "value": "false"},
           {"name": "MINIUSF_MigrateEntities", "value": "true"},
           {"name": "MINIUSF_MigrateRoleAssignments", "value": "true"},
           {"name": "ASPNETCORE_ENVIRONMENT", "value": "Production"},
           {"name": "MINIUSF_Keycloak_Realm", "value": "unity"},
           {"name": "MINIUSF_Keycloak_EventType", "value": "LOGIN"},
           {"name": "MINIUSF_Keycloak_EventsMaxNumber", "value": "10000"},
           {"name": "MINIUSF_Keycloak__RealmPathPrefix", "value": "auth/realms"},
           {"name": "MINIUSF_Keycloak__RealmAdminPathPrefix", "value": "auth/admin/realms"},
           {"name": "MINIUSF_Jwt__Issuer", "value": "http://keycloak"},
           {"name": "MINIUSF_Jwt__HttpsRequired", "value": "false"},
           {"name": "MINIUSF_Jwt__RealmPathPrefix", "value": "auth/realms"},
           {"name": "MINIUSF_Keycloak__BaseUri", "value": "http://keycloak"}
         ]
       }]
     }
   }'
   ```

###### Perform the second part of the migration

If an operation fails and you can't fix it, stop the migration and perform a rollback operation.

To complete the second part of the migration, complete these steps:

1. To upgrade Mini-USF to version 2, run this command from the generated `mini-usf` chart directory, `aws/argocd/charts/<YOUR_REGION>/mini-usf`, which holds its values:

   ```sh
   helm upgrade --install --debug --dependency-update -n asset-solutions mini-usf .
   ```

2. To assign the global administrator role to the users who need it, run this command:

   ```sh
   kubectl run upc-cli -n asset-solutions \
    --image=uccmpprivatecloud.azurecr.io/docker/upc-cli:1.1.3 \
    --restart=Never \
    --attach \
    --rm \
    --overrides='{"spec":{"imagePullSecrets":[{"name":"asset-solutions-docker-credentials"}]}}' \
    -- --fqdn http://mini-usf:8080 --path-prefix="" --no-auth roles assign --user-id "<USER_ID>" --role-id 812804b0-b643-4579-be8c-ef180e8c2c5a
   ```

3. Configure the default access for new users.

   * For the default access to an organization, run this command:

     ```sh
     kubectl run upc-cli -n asset-solutions \
        --image=uccmpprivatecloud.azurecr.io/docker/upc-cli:1.1.3 \
        --restart=Never \
        --attach \
        --rm \
        --overrides='{"spec":{"imagePullSecrets":[{"name":"asset-solutions-docker-credentials"}]}}' \
        -- --fqdn http://mini-usf:8080 --path-prefix="" --no-auth default-access set-org --organization-id "<ORGANIZATION_ID>" --user-type-id 39943160-54da-49ac-b1c7-bf26adc65855 --role-ids=""
     ```

   * For the default access to a project, run this command:

     ```sh
     kubectl run upc-cli -n asset-solutions \
        --image=uccmpprivatecloud.azurecr.io/docker/upc-cli:1.1.3 \
        --restart=Never \
        --attach \
        --rm \
        --overrides='{"spec":{"imagePullSecrets":[{"name":"asset-solutions-docker-credentials"}]}}' \
        -- --fqdn http://mini-usf:8080 --path-prefix="" --no-auth default-access set-project --project-id "<PROJECT_ID>" --role-ids 4101ecc8-2223-4066-aa4b-6b6f4d0d01e6
     ```

#### Complete the steps after the migration

To finish the migration, complete these steps:

1. Check that existing functionality works as expected.

2. Deploy the `upc-cronjob` chart again to enable its cron jobs.

3. Restore the network access to the solution.

## Version 1.1.0

### Migrate your data to Percona Server for MongoDB

Use a staged approach to migrate your data, at your own pace, from the MongoDB virtual machine (VM), which is the MongoDB EC2 instance, to Percona Server for MongoDB (PSMDB) in your Kubernetes cluster.

The Terraform variable `enable_percona_mongo` is for the deployment of the PSMDB operator and database in your Kubernetes cluster as a parallel setup. This variable is disabled by default. However, to ensure zero downtime, all services initially continue using your current MongoDB instance. The connection string logic follows this priority order:

1. The custom URI, if provided
2. The existing MongoDB VM
3. The new PSMDB cluster

The switch itself needs a maintenance window, because anything written to the MongoDB VM after the backup doesn't reach PSMDB. Release 1.5.0 removes the MongoDB VM, so if your deployment still uses it, use your 1.4.x package to complete these steps before you upgrade to 1.5.0 or later. The steps use the package's `aws/scripts/mongodb-backup.sh` and `mongodb-restore.sh`, and two passwords from the `asset-solutions/configuration` secret in AWS Secrets Manager. They are the VM's `asset-manager` password inside `mongo_db_connection_string`, and the PSMDB password, `psmdb_asset_manager_password`.

> **Warning:**
>
> Steps 15 and 16 (set `enable_mongo = false`, then run `make apply-<YOUR_REGION>` and deploy) delete the MongoDB VM and its data volume. From then on, the archive that step 5 (back up the VM) wrote, and that step 8 (copy the archive to your machine) copied, is your only copy of the VM's data. Keep it.

To move your data to PSMDB, complete these steps:

1. Set `enable_percona_mongo = true`, then run `make apply-<YOUR_REGION>` and deploy.

   If Argo CD deploys the charts through an `ApplicationSet` that lists them, add `psmdb-operator` and `psmdb-db` to it, and `pmm` if you set `enable_percona_monitoring = true`. PSMDB (`psmdb-db`) starts beside the VM, and the services keep using the VM.

2. Wait until `psmdb-db` is ready.

3. Start a maintenance window. No one uses the platform and no transformation runs until step 18 (end the maintenance window). Anything written to the VM after the backup in step 5 (back up the VM) is lost.

4. Open an AWS Systems Manager (SSM) session on the MongoDB VM, and grant `asset-manager` the `backup` role in the `admin` database:

   ```sh
   mongosh --username asset-manager --password <YOUR_VM_PASSWORD> --authenticationDatabase admin admin --eval 'db.grantRolesToUser("asset-manager", ["backup"])'
   ```

5. Put `mongodb-backup.sh` on the VM and run it. It writes `/tmp/mongo_data_backup_<TIMESTAMP>.archive`:

   ```sh
   bash mongodb-backup.sh asset-manager <YOUR_VM_PASSWORD>
   ```

6. Back up the `BulkOperation` database as well, and restore it after step 13 (restore the archive on the PSMDB primary), or the bulk operations in progress are lost. The script leaves it out, without warning.

7. In the SSM session, add a temporary public key of yours to `ec2-user`'s `~/.ssh/authorized_keys`.

   The VM has no SSH key.

8. Copy the archive to your machine:

   ```sh
   AWS_REGION=<YOUR_REGION> scp -o ProxyCommand="aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters portNumber=%p" ec2-user@<INSTANCE_ID>:/tmp/mongo_data_backup_<TIMESTAMP>.archive .
   ```

9. Remove the temporary key from `ec2-user`'s `~/.ssh/authorized_keys`.

10. Find the PSMDB primary. Its pod is the first part of the host name that this command prints, `psmdb-db-rs0-<POD_NUMBER>`:

    ```sh
    kubectl -n asset-solutions exec psmdb-db-rs0-0 -c mongod -- mongosh --username asset-manager --password <YOUR_PSMDB_PASSWORD> --authenticationDatabase admin --eval 'db.hello().primary'
    ```

11. Copy the archive to the primary:

    ```sh
    kubectl cp mongo_data_backup_<TIMESTAMP>.archive asset-solutions/<PRIMARY_POD_NAME>:/tmp/mongo_data_backup_<TIMESTAMP>.archive -c mongod
    ```

12. Copy the restore script to the primary:

    ```sh
    kubectl cp aws/scripts/mongodb-restore.sh asset-solutions/<PRIMARY_POD_NAME>:/tmp/mongodb-restore.sh -c mongod
    ```

13. Restore the archive, and answer `y` when the script prompts you:

    ```sh
    kubectl -n asset-solutions exec -it <PRIMARY_POD_NAME> -c mongod -- bash /tmp/mongodb-restore.sh asset-manager <YOUR_PSMDB_PASSWORD> /tmp/mongo_data_backup_<TIMESTAMP>.archive
    ```

14. Check that every collection holds as many documents in PSMDB as on the VM. If one differs, stop. The services still use the VM, and nothing is lost.

15. Set `enable_mongo = false`, and leave `mongo_connection_uri` unset.

16. Run `make apply-<YOUR_REGION>` and deploy.

    This deletes the VM and its data volume, and points the services' MongoDB connection at PSMDB.

17. A minute after the apply, restart every service that reads MongoDB:

    ```sh
    kubectl rollout restart deployment -l creator-services-app=asset-solutions -n asset-solutions
    ```

18. End the maintenance window.
