Deployment
All Kaa services, including TSX, are distributed as Docker images. You can run these images using software containerization and orchestration tools, such as Docker, Docker Swarm, Docker Compose, Kubernetes, etc. Kubernetes is the recommended system for managing Kaa-based clusters.
Runtime dependencies
TSX has the following runtime dependencies:
- NATS for inter-service communication.
Regardless of the deployment method, always make sure that you have dependency services up and running prior to starting up TSX.
Environment variables
The table below summarizes the variables supported by the TSX Docker image and provides default values along with descriptions.
Variable name | Default value | Description |
---|---|---|
INSTANCE_NAME |
tsx | Service instance name. |
NATS_HOST_PORT |
nats://nats:4222 | NATS service address. |
Kubernetes
To run TSX on Kubernetes:
- Install Kubernetes.
- Set up NATS as a Kubernetes service or a standalone server.
- Prepare Kubernetes deployment descriptor.
- Start up the pod:
kubectl create -f <deployment descriptor filename>
- Check that pods are running:
kubectl get pods
Deployment descriptor
Provided below is a sample deployment descriptor file that pulls the TSX version 1.0.0 Docker image from the official KaaIoT repository and runs one service replica (pod) with 100 MB RAM limit. Default environment variables are used in most cases.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: tsx
spec:
replicas: 1
template:
metadata:
labels:
app: tsx
tier: backend
spec:
containers:
- name: tsx
image: hub.kaaiot.net/kaaiot/tsx/tsx:1.0.0
terminationMessagePolicy: FallbackToLogsOnError
imagePullPolicy: Always
resources:
requests:
memory: 25Mi
limits:
memory: 100Mi
imagePullSecrets:
- name: kaaid
Below are some notable parameters of the deployment descriptor:
spec.replicas
defines the number of service instance replicas.spec.template.spec.containers.image
defines the Docker image to be used, whilespec.template.spec.containers.imagePullPolicy
defines the image update policy.spec.template.spec.imagePullSecrets
specifies the image pull secret for the official KaaIoT docker registry. To define this secret, use your KaaID credentials:$ export HISTCONTROL=ignorespace # Prevent saving your credentials in the shell history $ KAAID_USER=<your KaaID username>; kubectl create secret docker-registry kaaid --docker-server=hub.kaaiot.net --docker-username=$KAAID_USER --docker-email=$KAAID_USER --docker-password=<your KaaID password>
spec.template.spec.containers.resources
defines resources available to each replica. See how Kubernetes manages compute resources for containers.
Docker
To run TSX in Docker:
- Install Docker.
- Set up NATS as a Docker container or a standalone server.
- Run Docker container.
For example, use the following command to run the TSX version 1.0.0 image:
$ docker run hub.kaaiot.net/kaaiot/tsx/tsx:1.0.0