For the latest stable version, please use StreamX Guides 1.0.1! |
Run StreamX on 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 Cluster
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 https://www.streamx.dev/contact-us.html
-
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 source files for the example:
git clone https://github.com/streamx-dev/terraform-streamx-cloud
Optional Step 2: Configure StreamX Mesh
The fetched repository already contains 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:
-
The base configuration is located in the
examples/terraform-streamx-blueprint/config/streamx
directory. -
The overriding configuration is located in the
examples/terraform-streamx-blueprint/local/iac/config/streamx
directory.
Terraform is set up to use the base configuration and then selectively overwrite the values with those defined in the override configuration. Hence, the settings in your override configuration take precedence.
In the provided example, the overriding mesh configuration alters the number of blueprint replicas within StreamX.
Step 4: Initialize the Terraform
This action fetches all resources required by Terraform.
terraform init
Step 5: Prepare the Terraform plan
A Terraform plan displays an execution plan that is implemented in the subsequent steps.
terraform plan
Step 6: Validate and Implement plan
During this phase, Terraform generates and execute all necessary resources before creating the cluster. Command below can take up to 25 minutes to finish
terraform apply
Command above uses Streamx mesh.yaml file included in the 'terraform-streamx-cloud' repository. |
Optional Step 7: 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"