Skip to main content

πŸ“š Automation Examples

πŸ“‹ Table of Contents​

  1. Overview
  2. RabbitMQ Automation
  3. Kafka/Strimzi Automation
  4. FastAPI Automation
  5. k6 Load Testing Automation
  6. Best Practices
  7. 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​

ServiceAutomated ComponentsKey Features
RabbitMQExchanges, queues, bindings, usersMessage flow configuration
KafkaTopics, bridges, connectors, sinksEvent streaming setup
FastAPIRoutes, endpoints, documentationAPI gateway integration
k6Test scripts, CRDs, pluginsPerformance 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
alt text

Relationship Configuration​

The link between an exchange and a queue represents the binding configuration:

alt text

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 TypeLocationPurpose
VersioningComponent levelRabbitMQ version management
ResourcesComponent attributesCPU/Memory allocation
SecurityComponent & linksAuthentication, TLS, network policies
MonitoringAuto-generatedPrometheus 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​

alt text
Sub-ComponentPurposeAutomation Features
TopicsEvent streamsPartitions, replication, retention
BridgesHTTP integrationREST API exposure
ConnectorsExternal systemsDatabase sinks, source connectors
UsersAccess controlACLs, 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​

ComponentGenerated Assets
Kafka ClusterStatefulSets, services, config
Kafka ConnectDeployment, connector definitions
Schema RegistryDeployment, schemas
MonitoringJMX 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:

ActionGenerated Assets
Adds dependenciesPython packages, requirements.txt
Configures routesAPI endpoints, middleware
Creates servicesBusiness logic templates
Generates endpointsGET, POST, DELETE, PUT methods
Documents APIsOpenAPI/Swagger specs
alt text

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:

alt text

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 main branch.
  • 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.
alt text

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:

alt text

Benefits:

  • βœ… Centralized authentication
  • βœ… OIDC/OAuth2 support
  • βœ… Single Sign-On (SSO)
  • βœ… Token-based security
  • βœ… Role-based access control

Configuration Details​

ConfigurationLevelDescription
VersioningComponentPython version, FastAPI version
Admin CredentialsComponentInitial admin setup
ResourcesComponentCPU/Memory limits
Build ImageLinkRequired 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.

alt text

Automated Test Generation​

When k6 is linked to services, Stacktic automatically:

ActionGenerated Output
Creates test filesk6 JavaScript test scripts
Builds CRDsKubernetes custom resources
Configures pluginsDatabase, queue, API plugins
Sets up reportingMetrics 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​

FeatureBenefit
Automated test creationTests generated from topology
One-time image buildReusable across all tests
Integrated reportingResults in Grafana dashboards
Scaling validationVerify 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​

PracticeDescriptionBenefit
Start SimpleBegin with basic componentsEasier troubleshooting
Use Sub-ComponentsLeverage hierarchical structureBetter organization
Define RelationshipsConnect components properlyAutomatic configuration
Test in StagesDev β†’ Staging β†’ ProductionRisk mitigation
Review Generated DocsCheck automation outputsUnderstanding & validation

Security Recommendations​

  1. External Authentication - Use OIDC providers over built-in auth
  2. Secret Management - Let Stacktic handle secret generation
  3. Network Policies - Enable auto-generated policies
  4. TLS Everywhere - Use encrypted connections
  5. 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 AutomatesYou Control
Infrastructure configurationBusiness logic
Service connectionsApplication code
Security policiesData schemas
Monitoring setupBusiness rules
Testing frameworksCustom 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