> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/tposs/latest/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/tposs/latest/installation/tposs-api-gw-installation.md).

# TPOSS API Gateway installation

TPOSS API Gateway is an optional component that preserves the TPOSS API compatibility layer. It allows you to interact with TPOSS through the [JSON-RPC API](https://docs.cennso.com/components/tposs/latest/api-reference/api.md).

> [!IMPORTANT]
> This document describes the steps you need to execute to deploy TPOSS API Gateway. For more information on how to configure TPOSS API Gateway, see the [TPOSS API Gateway chart configuration](https://docs.cennso.com/components/tposs/latest/technical-reference/api-gw-configuration.md) document.

## Installation steps

The gateway is delivered as a separate Helm chart, so it needs its own Helm release next to TPOSS. To install it, use the following commands:

1. Log in to the OCI registry with the charts:

   ```bash
   echo {REGISTRY_SECRET_TOKEN} | helm registry login {REGISTRY_HOST} -u {USERNAME} --password-stdin
   ```

2. Prepare a `values.yaml` file with your TPOSS API Gateway configuration.

3. Run this command to install the TPOSS API Gateway Helm release:

   ```bash
   helm install {API_GW_RELEASE_NAME} oci://{REGISTRY_HOST}/charts/tposs-api-gw --version {API_GW_CHART_VERSION} -f values.yaml -n {NAMESPACE}
   ```

The gateway uses the same registry placeholders as TPOSS, described in the [Placeholders](https://docs.cennso.com/components/tposs/latest/installation/installation.md#placeholders) section of the installation document, plus these two:

| Placeholder | Description |
|---|---|
| `{API_GW_RELEASE_NAME}` | Name for the Helm release to install, for example `api-gw`. It must differ from the TPOSS release name. |
| `{API_GW_CHART_VERSION}` | Version of the TPOSS API Gateway chart to install, for example `1.6.8`. |

If you changed only the configuration and not the image, the pod keeps running with the old values. Updating the chart configuration leaves the pod specification unchanged, so Kubernetes does not recreate the pod.

Restart the pod to apply the new configuration:

```bash
kubectl rollout restart deployment {API_GW_RELEASE_NAME}-tposs-api-gw -n {NAMESPACE}
```

## Verify the TPOSS API Gateway installation

Check that the Helm release is deployed and the TPOSS API Gateway pod is running and ready:

```bash
helm status {API_GW_RELEASE_NAME} -n {NAMESPACE}
kubectl get pods -n {NAMESPACE}
```

To check that the gateway forwards the requests to TPOSS, forward the gateway port and send a JSON-RPC request. The `12000` port is the default value of the **service.externalPort** configuration option. You can use the following command to forward this port locally:

```bash
kubectl port-forward svc/{API_GW_RELEASE_NAME}-tposs-api-gw 12000:12000 -n {NAMESPACE}
```

After the port is accessible locally, you can try to send a JSON-RPC request:

```bash
curl -H "Content-Type: application/json" -X POST http://127.0.0.1:12000 --data-binary @- <<EOF
{
  "id": "1",
  "jsonrpc": "2.0",
  "method": "Subscriber.Read",
  "params": {
    "AuthKey": "{AUTH-KEY}",
    "FeId": "{FeID}",
    "FeSId": "{FeSId}"
  }
}
EOF
```

TPOSS can answer with the `-33333 Not authenticated` error, because the request carries no valid key. The error means that the request reached TPOSS through the gateway. For the valid values of the `AuthKey` and `FeId` fields and the available methods, see the [JSON-RPC 2.0 API](https://docs.cennso.com/components/tposs/latest/api-reference/rpc/overview.md) document.
