NATS configuration
NATS is a crucial component for global locking in the TPOSS cluster. If you use sessions.global_lock.algorithm set to the NATS service specified by one of the nats-services.{SERVICE_NAME} services, you need a NATSOpens in a new tab instance for TPOSS to communicate with. You may use your own NATS installation or the one that TPOSS Helm chart provides as a dependency. To use NATS provided by TPOSS, use this configuration option:
NATS included in the TPOSS Helm chart is already configured in the most optimal way. The following sections provide recommended configuration options and their values for NATS that you may re-use for your own installation. The whole list of the configuration options of the NATS chart and their default values you may find in the Configuration parameters section and in the official documentationOpens in a new tab.
Recommended configuration
Caution
The default values for the configuration options in this section are thoroughly tested and confirmed to work reliably. Changing these options may affect system performance or stability. Proceed with caution, as any changes are made at your own risk.
All the configuration parameters related to NATS are located under the nats section in the TPOSS Helm chart.
The next sections provide information about common configuration options of the NATS deployment, which can be deployed from the TPOSS Helm chart.
NATS image and secrets configuration
You can use the following configuration options to configure the NATS imageOpens in a new tab version, the secrets to pull the image, and the image pull policyOpens in a new tab:
NATS resources configuration
You can use the following configuration options to configure Kubernetes resourcesOpens in a new tab needed by the NATS containers:
Caution
TPOSS needs NATS JetStreamOpens in a new tab enabled to work properly. It is enabled by default in the TPOSS chart with the nats.config.jetstream.enabled: true configuration option.
Persistence configuration
As the global lock based on NATS does not need persistence, you should enable only memory storage for NATS using the following configuration options:
For the existing use cases, TPOSS only needs around 50 MB of memory for NATS. However, it's recommended to allocate more, as some commands run by the NATS CLIOpens in a new tab tool can cause memory spikes.
NATS server monitoring configuration
You can use the following configuration options to enable NATS server monitoring and see its metrics:
If this configuration option is set to true, TPOSS installs the ServiceMonitorOpens in a new tab, which defines settings for how metrics should be scraped. You can specify labelsOpens in a new tab assigned to this ServiceMonitor using these configuration options:
The TPOSS Helm chart also provides the Grafana dashboard located in the dashboards/nats.json. You can use it to display the NATS server metrics.
Accessing NATS server
You can use the following configuration option to enable the nats-boxOpens in a new tab sidecar container that contains useful utilities to access the NATS server:
Updating NATS
If you need to upgrade the NATS server (for version or configuration updates), there are several ways to do it. The best approach is to update NATS during a maintenance window to avoid any impact on TPOSS user sessions. If it's not possible to stop incoming requests and you must upgrade NATS while TPOSS is handling traffic, you can either update the NATS instance, which will cause some rejected requests, or follow these steps to minimize the impact:
- Deploy the new NATS server with the updated version or configuration while the old NATS server is running.
- Update the nats-services.{SERVICE_NAME}.server configuration option in TPOSS to point to the new NATS server.
- Redeploy TPOSS with the updated configuration. Read the installation guide to learn more.
- Once TPOSS is running with the new configuration, terminate the old NATS server.
Caution
During the transition between the old and new NATS servers, TPOSS cannot send locking information. If TPOSS fails to send locking information while processing a session request, the request is rejected with an error.
This method can cause lock inconsistencies during the NATS update. It may lead to TPOSS handling two requests for the same identifier, which results in unpredictable behaviour. However, this is rare and can be avoided by performing the update during low-traffic periods.
Configuration parameters
The following table lists configurable parameters for the NATSOpens in a new tab deployment: