# Company demo on OpenShift

Use the [company deployment decisions](company-demo.md) for the `tdp` project. Publish the images
of a release first. Then [install the demo](#install-the-demo) once, or
[update to the new release](#update-to-a-new-release). Use Bash with `oc` and Podman on the
company host, in `~/tdp`.

## Download the release

Download `testdataplus-company-demo-<version>-amd64.zip` and its SHA-256 checksum, and extract
the ZIP into `~/tdp/<version>`. The ZIP contains both loadable `.tar.gz` image archives,
their checksums, `release.json`, the guides and three manifests:

| Manifest | Use |
| --- | --- |
| `testdataplus-company-demo-setup.yaml` | Template for the Oracle settings and the generated keys. Once per installation. |
| `testdataplus-company-demo.yaml` | Deployments, Services and ingress policies with the release's image tags. Applied unchanged for every release. |
| `testdataplus-company-demo-routes.yaml` | The two edge Routes. Once, from a private copy with the certificates. |

The same files are available individually in the numbered release folder.

## Publish the images

Set `version` to the release folder name. Keep this terminal for the later steps. Podman uses your Nexus login to publish the images. OpenShift pulls them with the credentials
on the `default` service account.

```bash
version=0.3.0-r14
registry=build.equateplus.net:49096/library

(
  set -eu
  cd ~/tdp/"$version"
  for repository in tdp-suite tdp-demo-identity; do
    archive="$repository-$version-amd64.tar.gz"
    image="$registry/$repository:$version"
    sha256sum -c "$archive.sha256"
    podman load -i "$archive"
    podman tag "$repository:$version-amd64" "$image"
    podman push "$image"
  done
)
```

## Install the demo

1. Ask the DBA for the Suite user and its grants under
   [application database](database-accounts.md#application-database). Use an empty schema for a
   fresh start. To keep an existing schema, restore [its Suite key](#suite-key) first.

2. Create `~/tdp/oracle.env` with permissions `600` and one `NAME=value` per line. Use the
   existing PDB service. Add `ORACLE_USER=...` only for a login other than `TDP1`.

   ```text
   ORACLE_JDBC_URL=jdbc:oracle:thin:@//ORACLE_HOST:1521/PDB_SERVICE
   ORACLE_PASSWORD=the password
   ```

3. Create the Secrets, the workloads and, if they do not exist yet, the Routes. `oc create`
   refuses an existing Secret, so the generated keys are never replaced. First fill the PEM
   placeholders in a private copy of the Routes file, `~/tdp/company-demo-routes.private.yaml`.

   ```bash
   oc login https://api.cloud-tst.equateplus.net:6443
   cd ~/tdp/"$version"
   oc process --local -f testdataplus-company-demo-setup.yaml --param-file=../oracle.env |
     oc -n tdp create -f -
   oc -n tdp apply -f testdataplus-company-demo.yaml
   oc -n tdp create -f ../company-demo-routes.private.yaml
   oc -n tdp rollout status deployment/tdp-company-demo-suite --timeout=15m
   ```

4. [Verify the installation](#verify-the-installation).

The project quota must allow 8 GiB memory and 11 GiB ephemeral storage for the Suite pod.
A pod that stays `Pending` names the missing resource in `oc -n tdp describe pod`.

## Update to a new release

Publish the new release's images. Wait for active scans and loads to finish. From the new
release folder, show the change and apply it. Both Deployments restart; users sign in again.

```bash
cd ~/tdp/"$version"
oc -n tdp diff -f testdataplus-company-demo.yaml
oc -n tdp apply -f testdataplus-company-demo.yaml
oc -n tdp rollout status deployment/tdp-company-demo-suite --timeout=15m
```

To go back, apply `testdataplus-company-demo.yaml` of the previous release folder the same way. A
release that changed the Suite schema cannot go back: the previous Suite refuses the newer
schema and stays unready, without changes. Apply the new release again.

### Switch from the single template

An installation from the earlier single template needs these steps once. Add the Oracle
URL and user to its Secret, then replace the workload objects so that `oc apply` manages them.
The Secrets and Routes stay.

```bash
oc -n tdp set data secret/tdp-company-demo-oracle \
  url=jdbc:oracle:thin:@//ORACLE_HOST:1521/PDB_SERVICE user=TDP1
oc -n tdp delete deployment/tdp-company-demo-suite deployment/tdp-company-demo-identity \
  service/tdp-company-demo-suite service/tdp-company-demo-identity \
  networkpolicy/tdp-company-demo-suite-ingress networkpolicy/tdp-company-demo-identity-ingress \
  --ignore-not-found
oc -n tdp apply -f testdataplus-company-demo.yaml
oc -n tdp rollout status deployment/tdp-company-demo-suite --timeout=15m
```

The former PostgreSQL demo used other objects. List them, and delete those that exist once you
no longer need their synthetic data. Deleting the claim removes its data for good.

```bash
oc -n tdp get deployment/tdp-company-demo-postgres pvc/tdp-company-demo-postgres-data \
  service/tdp-company-demo-db configmap/tdp-company-demo-service-ca \
  configmap/tdp-company-demo-route-tls secret/tdp-company-demo-db --ignore-not-found
```

## Suite key

The setup template generates the Suite key on the first installation. Keep the exact bytes of
`tdp-company-demo-suite-key` with the Oracle backup. Restore that Secret before installing
against an existing Suite schema. A Suite with another key refuses to start.

## Oracle password

After the DBA changes the password, update the Secret and restart the Suite.

```bash
oc -n tdp set data secret/tdp-company-demo-oracle tdp.db.password='the new password'
oc -n tdp rollout restart deployment/tdp-company-demo-suite
```

## Demo passwords

Sign in as `admin` with `admin.42`. Every demo account uses `<login>.42` by default.
Set the desired `TDP_DEMO_<LOGIN>_PASSWORD` key in the `tdp-company-demo-users` Secret
to override it. Restart Java sign-in after changing an override.

An existing installation may hold passwords in that Secret. To use the defaults for all
demo logins, clear its password entries and restart sign-in.

```sh
oc -n tdp patch secret tdp-company-demo-users --type=merge --patch '{"data":null}'
oc -n tdp rollout restart deployment/tdp-company-demo-identity
oc -n tdp rollout status deployment/tdp-company-demo-identity --timeout=5m
```

## Verify the installation

1. Open <https://tdp-bt1.cloud-tst.equateplus.net/> and sign in with the
   [demo admin password](#demo-passwords). Complete first-run setup if prompted.
2. Under **Sources**, register the Oracle source with a
   [read-only source account](database-accounts.md#source-account).
3. Under **Test databases**, register the Oracle export target with its own
   [target account](database-accounts.md#target-account). Run a small synthetic export and read
   back the rows with an Oracle client.
4. For MCP, use <https://tdp-bt1.cloud-tst.equateplus.net/mcp> and OAuth client `tdp-ai`.
   Use the callback registered for your MCP client and sign in through the company sign-in Route.

## Operate the demo

```sh
oc -n tdp get deployments,pods,svc,route -l app.kubernetes.io/part-of=tdp-company-demo
oc -n tdp logs deployment/tdp-company-demo-suite -c suite --tail=80
oc -n tdp logs deployment/tdp-company-demo-identity -c identity --tail=80
```

For a startup failure, check the Oracle URL, user and password in `tdp-company-demo-oracle`,
the schema grants and the Suite key. For a Route failure, check the `http` Service port and
the ingress peers in the deployment decisions. For a failed source confirmation, match the
Workbench request ID to `source_change_resolution_proxy` and `source_change_resolution` in the
Suite log.

Keep Oracle backups with the Suite master key, OAuth and user Secrets, and private Route
certificates. Java sign-in generates a new signing key when its pod is replaced. Users may
need to sign in again.
