Run StreamX on a local Kubernetes cluster
In this guide, we walk you through the process of setting up StreamX on a local cluster by using Kubernetes in Docker (Kind).
Prerequisites
Please ensure you have the following before proceeding:
-
Approximately 30 minutes to complete the setup.
-
Access to StreamX Infrastructure as Code repository. If you don’t have this, you can inquire at StreamX Contact us.
-
Installed:
-
Docker resources are configured at least:
-
Memory limit: 8 GB
-
CPU limit: 8 cores
-
Virtual disk limit: 20 GB
-
Ensure no other application is occupying ports 443 or 80. |
Step 1: Obtain the source files
Clone the Git repository that contains the necessary source files:
git clone https://github.com/streamx-dev/terraform-streamx-cloud
Step 2: Configure StreamX Mesh (optional)
The fetched repository already contains the mesh configuration required to run StreamX. However, if you want to tailor the mesh configuration to your specific needs, you have that flexibility.
Within the fetched repository, there are two mesh.yaml files:
-
Base configuration:
examples/terraform-streamx-blueprint/config/streamx
directory. -
Override configuration:
examples/terraform-streamx-blueprint/local/iac/config/streamx
directory.
Terraform applies the base configuration first, then overwrites values with those in the override configuration. The override settings take precedence.
In the provided example, the overriding mesh configuration alters the number of blueprint replicas within StreamX.
Step 3: Deploy Terraform configuration
To deploy the Terraform configuration, follow these steps:
-
Go to the Terraform Directory:
cd examples/terraform-streamx-blueprint/local/iac
-
Fetch all resources required by Terraform with the following command:
terraform init
-
Display an execution plan:
terraform plan
-
Validate and implement plan. During this phase, Terraform generates and executes all necessary resources before creating the cluster. Execute the command below, it can take up to 25 minutes to finish.
terraform apply
Command above uses Streamx mesh.yaml file included in the terraform-streamx-cloud
repository.
Step 4: Validate StreamX
To verify your StreamX setup, you can publish a simple website and check its accessibility with the following script:
#!/bin/bash
INGESTION_URL=https://$(terraform output -json endpoints | jq -r '."ingestion"."rest"')
WEB_URL=https://$(terraform output -json endpoints | jq -r '."delivery"."blueprint_web"')
TOKEN="$(terraform output -raw ingestion_rest_jwt_token)"
curl -k -X POST ${INGESTION_URL}/ingestion/v1/channels/pages/messages \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" \
-d '{
"key" : "homepage.html",
"action" : "publish",
"eventTime" : null,
"properties" : { },
"payload" : {
"dev.streamx.blueprints.data.Page" : {
"content" : {
"bytes" : "<h1>Hello World!</h1>"
}
}
}
}'
sleep 0.5
echo "\n\nReceived: "
curl -k ${WEB_URL}
echo "\n"