Celestra provides powerful execution capabilities that allow you to not only generate configuration files but also run them directly. This enables a seamless workflow from DSL definition to actual deployment.
fromcelestraimportApp,DockerComposeOutput# Define your applicationapp=App("web-app").image("nginx:latest").port(8080)# Create output instanceoutput=DockerComposeOutput()# Generate and run in one workflowoutput.generate(app,"docker-compose.yml").up(detached=True)
fromcelestraimportApp,AppGroup,DockerComposeOutput# Define servicesweb=App("web").image("nginx:latest").port(80)api=App("api").image("myapp/api:latest").port(3000)db=App("db").image("postgres:13").port(5432)# Create app groupapp_group=AppGroup("myapp").add_services([web,api,db])# Generate and runoutput=DockerComposeOutput()output.generate(app_group,"docker-compose.yml")# Start all servicesoutput.up(detached=True)# Check statusoutput.ps()# Show logs for specific serviceoutput.logs("api")# Scale a serviceoutput.scale({"api":3})# Stop and clean upoutput.down(volumes=True)
fromcelestraimportApp,DockerComposeOutputapp=App("dev-app").image("myapp:dev").port(8080)output=DockerComposeOutput()# Development workflow(output.generate(app,"docker-compose.dev.yml").build()# Build the image.up(detached=True)# Start in background.logs(follow=True))# Follow logs
fromcelestraimportApp,KubernetesOutput# Define your applicationapp=App("web-app").image("nginx:latest").port(8080)# Create output instanceoutput=KubernetesOutput()# Generate and deployoutput.generate(app,"./manifests/").apply()
fromcelestraimportApp,AppGroup,KubernetesOutput# Define production applicationweb=App("web-prod").image("myapp:v1.0.0").port(80).replicas(3)api=App("api-prod").image("myapi:v1.0.0").port(3000).replicas(2)db=App("db-prod").image("postgres:13").port(5432).replicas(1)app_group=AppGroup("production").add_services([web,api,db])# Production deployment workflowoutput=KubernetesOutput()(output.generate(app_group,"./manifests/prod/").validate()# Validate manifests.diff()# Show what will change.apply(namespace="prod",wait=True)# Deploy and wait.get("pods",namespace="prod")# Check status.health(namespace="prod"))# Verify health
The execution API automatically tracks the last generated files, so you don't need to specify file paths repeatedly:
output=DockerComposeOutput()# Generate file (automatically tracked)output.generate(app,"docker-compose.yml")# Use tracked file automaticallyoutput.up()# Uses the last generated fileoutput.logs()# Uses the last generated fileoutput.down()# Uses the last generated file
The execution API integrates seamlessly with CI/CD pipelines:
# CI/CD deployment scriptfromcelestraimportApp,KubernetesOutputdefdeploy_to_environment(app,environment):output=KubernetesOutput()# Generate and deployoutput.generate(app,f"./manifests/{environment}/")ifenvironment=="production":# Production deployment with extra safetyoutput.validate().diff().apply(wait=True,timeout=600)else:# Development/staging deploymentoutput.apply(wait=True)# Verify deploymentoutput.health()returnoutput# Usage in pipelineapp=App("myapp").image("myapp:latest").port(8080)deploy_to_environment(app,"staging")deploy_to_environment(app,"production")
This execution API transforms Celestra from a configuration generator into a complete deployment tool, enabling you to go from DSL definition to running applications with just a few lines of code.