π Automation Examples
π Table of Contentsβ
- Overview
- RabbitMQ Automation
- Kafka/Strimzi Automation
- FastAPI Automation
- k6 Load Testing Automation
- Best Practices
- Additional Resources
Overviewβ
This chapter provides real-world examples of service automation and relationships generated by Stacktic. These examples demonstrate how Stacktic automates configurations based on best-practice patterns, creating the necessary resources, documentation, and relationships to support full-stack demands.
Important Notesβ
β οΈ Scope Notice: These are examples only, not complete automation implementations.
The full automation is generated into your target repository's documentation with all configurations, secrets, and operational procedures.
What Gets Automatedβ
| Service | Automated Components | Key Features |
|---|---|---|
| RabbitMQ | Exchanges, queues, bindings, users | Message flow configuration |
| Kafka | Topics, bridges, connectors, sinks | Event streaming setup |
| FastAPI | Routes, endpoints, documentation | API gateway integration |
| k6 | Test scripts, CRDs, plugins | Performance testing |
π RabbitMQ Automationβ
Component Architectureβ
RabbitMQ automation demonstrates how Stacktic handles message queue patterns with sub-components and relationships.
Sub-Component Creationβ
You can create sub-components such as:
- Exchanges - Message routing logic
- Queues - Message storage
- Bindings - Flow definitions between exchanges and queues
Relationship Configurationβ
The link between an exchange and a queue represents the binding configuration:
Generated Configurationβ
Secret Configuration Exampleβ
The automation generates a complete RabbitMQ configuration stored as a Kubernetes secret:
cat k8s/deploy/base/rabbitmq/secret/definitions.json
{
"vhosts": [
{ "name": "/" }
],
"users": [
{
"name": "user",
"password_hash": "EJBKv6SgKs6UFaLurzia3tPUIxQ/d4NIfwXG0OUWD2ayoCRd",
"tags": "management"
},
{
"name": "admin",
"password_hash": "C5pNaWoy+Fb7WeHsIgtP/6DvaimpRJkdo4BQQYlO+yluv0b/",
"tags": "administrator"
}
],
"permissions": [
{ "user": "user", "vhost": "/", "configure": ".*", "write": ".*", "read": ".*" },
{ "user": "admin", "vhost": "/", "configure": ".*", "write": ".*", "read": ".*" }
],
"parameters": [],
"global_parameters": [
{ "name": "cluster_name", "value": "rabbit@my-rabbit" }
],
"policies": [],
"bindings": [{
"source": "api-system",
"destination": "systems",
"destination_type": "queue",
"vhost": "/",
"routing_key": "#"
}],
"queues": [{
"name": "systems",
"vhost": "/",
"durable": true,
"auto_delete": false,
"arguments": {}
}],
"exchanges": [{
"name": "api-system",
"type": "topic",
"vhost": "/",
"durable": true,
"auto_delete": false,
"internal": false,
"arguments": {}
}]
}
Additional Configurationsβ
| Configuration Type | Location | Purpose |
|---|---|---|
| Versioning | Component level | RabbitMQ version management |
| Resources | Component attributes | CPU/Memory allocation |
| Security | Component & links | Authentication, TLS, network policies |
| Monitoring | Auto-generated | Prometheus metrics, Grafana dashboards |
π Note: Additional configuration related to versioning, resources, and security exists within the RabbitMQ component itself.
π¦ Kafka Automationβ
Advanced Event Streamingβ
Kafka Strimzi is a more complex component but follows similar automation principles.
Sub-Component Typesβ
| Sub-Component | Purpose | Automation Features |
|---|---|---|
| Topics | Event streams | Partitions, replication, retention |
| Bridges | HTTP integration | REST API exposure |
| Connectors | External systems | Database sinks, source connectors |
| Users | Access control | ACLs, authentication |
Integration Capabilitiesβ
API Gateway Integrationβ
- Bridge connects to API gateway
- Integrates with OIDC via Keycloak
- Automatic authentication setup
Database Integrationβ
- Topic sub-components connect to databases for sink operations
- Automated Kafka Connect configuration
- End-to-end setup including connectors and secrets
Example Resourcesβ
Demo Repositoryβ
Explore a sample implementation (not full automation):
π Basic Strimzi Setup
Connectors Exampleβ
Review automated connector configurations:
π Kafka Connectors
Automated Componentsβ
| Component | Generated Assets |
|---|---|
| Kafka Cluster | StatefulSets, services, config |
| Kafka Connect | Deployment, connector definitions |
| Schema Registry | Deployment, schemas |
| Monitoring | JMX exporters, dashboards |
β‘ FastAPI Automationβ
API Development Accelerationβ
FastAPI automation streamlines API configuration and documentation through intelligent relationship management.
Automatic Configurationβ
When you connect FastAPI to a queue or database, Stacktic automatically:
| Action | Generated Assets |
|---|---|
| Adds dependencies | Python packages, requirements.txt |
| Configures routes | API endpoints, middleware |
| Creates services | Business logic templates |
| Generates endpoints | GET, POST, DELETE, PUT methods |
| Documents APIs | OpenAPI/Swagger specs |
API Gateway Integrationβ
Connect FastAPI to APISIX API Gateway for production-ready deployment:
- Automatic route registration
- Load balancing configuration
- Health check setup
- Rate limiting rules
Validation & Testingβ
Validate the configuration by testing the FastAPI endpoints and viewing generated documentation:
sub_component for custom APIβ
Stacktic acts as version control for your stack.
You can:
- Create your own API on the existing FastAPI service in the
mainbranch. - Modify an existing API.
- Or use sub-components to define APIs.
When you add a sub-component, Stacktic automatically generates the API code inside the existing structure.
You donβt need to manually touch mainβjust add the route and basic service definition.
β Advantages of Using Sub-Component APIsβ
- Saved as part of Stackticβs version control, making it easy to track changes.
- Minimizes direct code editingβno need to manage dependencies or modify
main; simply provide the API definition. - Gives Stacktic additional metadata about your logic, enabling smarter automation and insights.
Security Best Practicesβ
π Security Recommendation:
We recommend external authentication instead of relying solely on FastAPI's built-in API key system.
OIDC Integration with APISIX & Keycloakβ
Use APISIX and Keycloak for enterprise-grade authentication:
Benefits:
- β Centralized authentication
- β OIDC/OAuth2 support
- β Single Sign-On (SSO)
- β Token-based security
- β Role-based access control
Configuration Detailsβ
| Configuration | Level | Description |
|---|---|---|
| Versioning | Component | Python version, FastAPI version |
| Admin Credentials | Component | Initial admin setup |
| Resources | Component | CPU/Memory limits |
| Build Image | Link | Required when linking APIs |
π‘ Build Note: Build image is required when linking APIs to ensure dependency compatibility.
π k6 Load Testing Automationβ
Performance Testing Frameworkβ
To quickly assess your stack's performance and scaling configuration, link k6 to any service component.
Automated Test Generationβ
When k6 is linked to services, Stacktic automatically:
| Action | Generated Output |
|---|---|
| Creates test files | k6 JavaScript test scripts |
| Builds CRDs | Kubernetes custom resources |
| Configures plugins | Database, queue, API plugins |
| Sets up reporting | Metrics collection, dashboards |
Example k6 Structureβ
tree k8s/deploy/base/k6
k8s/deploy/base/k6
βββ k6.yaml # k6 operator configuration
βββ kustomization.yaml # Kustomize manifest
βββ mongodb_collector.yaml # MongoDB metrics collector
βββ namespace.yaml # k6 namespace
βββ secret
β βββ cloud.env # Cloud configuration
β βββ registry.json # Registry credentials
βββ test-run.yaml # Test execution definitions
βββ tests
βββ cnpg.js # PostgreSQL tests
βββ kafka.js # Kafka tests
βββ mongo.js # MongoDB tests
βββ psql.js # PostgreSQL tests
βββ rabbitmq.js # RabbitMQ tests
Test Execution Configurationβ
Sample test-run.yamlβ
apiVersion: k6.io/v1alpha1
kind: TestRun
metadata:
name: mongo-test
namespace: k6-operator-system
spec:
parallelism: 1
paused: "false"
quiet: "false"
script:
configMap:
name: k6-test-scripts
file: mongo.js
runner:
image: index.docker.io/asauer/k6:0.0.1-SNAPSHOT
imagePullSecrets:
- name: registry-credential
envFrom:
- secretRef:
name: k6-cm
resources:
limits:
cpu: 1000m
memory: 1Gi
requests:
cpu: 250m
memory: 256Mi
---
apiVersion: k6.io/v1alpha1
kind: TestRun
metadata:
name: rabbitmq-test
namespace: k6-operator-system
spec:
parallelism: 1
paused: "false"
quiet: "false"
script:
configMap:
name: k6-test-scripts
file: rabbitmq.js
runner:
image: index.docker.io/asauer/k6:0.0.1-SNAPSHOT
imagePullSecrets:
- name: registry-credential
envFrom:
- secretRef:
name: k6-cm
resources:
limits:
cpu: 1000m
memory: 1Gi
requests:
cpu: 250m
memory: 256Mi
Performance Testing Benefitsβ
| Feature | Benefit |
|---|---|
| Automated test creation | Tests generated from topology |
| One-time image build | Reusable across all tests |
| Integrated reporting | Results in Grafana dashboards |
| Scaling validation | Verify autoscaling configurations |
π Pro Tip: You only need to build the k6 image onceβtest definitions are referenced directly in the deployment through ConfigMaps.
π Best Practicesβ
General Automation Guidelinesβ
| Practice | Description | Benefit |
|---|---|---|
| Start Simple | Begin with basic components | Easier troubleshooting |
| Use Sub-Components | Leverage hierarchical structure | Better organization |
| Define Relationships | Connect components properly | Automatic configuration |
| Test in Stages | Dev β Staging β Production | Risk mitigation |
| Review Generated Docs | Check automation outputs | Understanding & validation |
Security Recommendationsβ
- External Authentication - Use OIDC providers over built-in auth
- Secret Management - Let Stacktic handle secret generation
- Network Policies - Enable auto-generated policies
- TLS Everywhere - Use encrypted connections
- Regular Updates - Keep component versions current
Performance Optimizationβ
- β Use k6 for baseline performance testing
- β Configure resource limits appropriately
- β Enable horizontal pod autoscaling
- β Implement caching strategies
- β Monitor with Prometheus/Grafana
π― Summaryβ
Key Takeawaysβ
β
Pattern-Based Automation - Best practices built into every component
β
Relationship Intelligence - Connections drive configuration
β
Complete Stack Coverage - From messaging to testing
β
Security by Default - Authentication, encryption, policies
β
Production Ready - Generated configurations are deployment-ready
What's Automated vs. What You Controlβ
| Stacktic Automates | You Control |
|---|---|
| Infrastructure configuration | Business logic |
| Service connections | Application code |
| Security policies | Data schemas |
| Monitoring setup | Business rules |
| Testing frameworks | Custom algorithms |
These examples demonstrate the power of Stacktic's automation. The full automation in your repository will include complete configurations, documentation, and operational procedures tailored to your specific stack.
Version: 2.0
Last Updated: September 2025
Β© Stacktic - Intelligent Stack Automation