Skip to main content

A Python DSL for generating Kubernetes manifests with minimal complexity

Project description

Celestra ๐Ÿš€

Transform your application deployments with a simple Python DSL

Celestra is a powerful Domain-Specific Language (DSL) that lets you define cloud-native applications using simple Python code and automatically generates production-ready Kubernetes manifests, Docker Compose files, Helm charts, and more.

โœจ Why Celestra?

Before (Traditional YAML):

# 100+ lines of complex YAML for a simple web app
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web-app
  template:
    metadata:
      labels:
        app: web-app
    spec:
      containers:
      - name: web-app
        image: web-server:latest
        ports:
        - containerPort: 8080
        resources:
          requests:
            cpu: 500m
            memory: 512Mi
          limits:
            cpu: 1000m
            memory: 1Gi
# ... and much more YAML

After (Celestra):

from celestra import App

web_app = (App("web-app")
    .image("web-server:latest")
    .port(8080)
    .resources(cpu="500m", memory="512Mi", cpu_limit="1000m", memory_limit="1Gi")
    .replicas(3)
    .expose())

# Generate everything
web_app.generate().to_yaml("./k8s/")                    # Kubernetes manifests
web_app.generate().to_docker_compose("./docker-compose.yml")  # Local development
web_app.generate().to_helm_chart("./charts/")           # Helm packaging

๐ŸŽฏ Key Features

  • ๐Ÿ Python-First: Write infrastructure as code using familiar Python syntax
  • ๐ŸŽญ Multi-Format Output: Generate Kubernetes, Docker Compose, Helm, Kustomize from the same code
  • ๐Ÿ”’ Production-Ready: Built-in security, monitoring, secrets management, and RBAC
  • ๐Ÿš€ Zero-Downtime Deployments: Blue-green, canary, and rolling update strategies
  • ๐Ÿ”ง Extensible: Plugin system for custom requirements and integrations
  • ๐Ÿ’ก Developer Friendly: Start with Docker Compose, deploy to Kubernetes seamlessly

๐Ÿš€ Quick Start

๐Ÿ“– ๐Ÿ“š Full Documentation - Complete guides, tutorials, and API reference

Installation

# install from PyPI 
pip install celestra

# Or from source (recommended for development)
git clone https://github.com/sps014/celestra.git
cd celestra
pip install -e src/

Create Your First App

# app.py
from celestra import App, StatefulApp, Secret

# Database with automatic backups
db = (StatefulApp("database")
    .image("postgres:15")
    .port(5432)
    .storage("20Gi"))

# Database credentials
db_secret = (Secret("db-creds")
    .add("username", "admin")
    .add("password", "secure-password"))

# Web application
app = (App("blog")
    .image("webapp:latest")
    .port(8080)
    .replicas(3)
    .expose())

# Generate and deploy
app.generate().to_yaml("./k8s/")
db.generate().to_yaml("./k8s/")
db_secret.generate().to_yaml("./k8s/")

Deploy Locally

# Generate Kubernetes manifests
python app.py

# Deploy to Kubernetes
kubectl apply -f ./k8s/

๐Ÿ—๏ธ Architecture

Celestra abstracts Kubernetes complexity while maintaining full power:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Python DSL    โ”‚โ”€โ”€โ”€โ–ถโ”‚   Celestra Core  โ”‚โ”€โ”€โ”€โ–ถโ”‚   Output Files  โ”‚
โ”‚                 โ”‚    โ”‚                  โ”‚    โ”‚                 โ”‚
โ”‚ โ€ข Apps          โ”‚    โ”‚ โ€ข Validation     โ”‚    โ”‚ โ€ข Kubernetes    โ”‚
โ”‚ โ€ข StatefulApps  โ”‚    โ”‚ โ€ข Templates      โ”‚    โ”‚ โ€ข Docker Composeโ”‚
โ”‚ โ€ข Secrets       โ”‚    โ”‚ โ€ข Plugins        โ”‚    โ”‚ โ€ข Helm Charts   โ”‚
โ”‚ โ€ข Jobs          โ”‚    โ”‚ โ€ข Optimization   โ”‚    โ”‚ โ€ข Kustomize     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐ŸŽจ Real-World Examples

Microservices Platform

from celestra import AppGroup, App, StatefulApp

platform = AppGroup("ecommerce")

# Shared infrastructure
database = StatefulApp("database").image("postgres:15").port(5432).storage("100Gi")
cache = StatefulApp("cache").image("redis:7").port(6379).storage("10Gi")

# Microservices
user_service = App("users").image("myorg/users:v1.0").port(8080)
product_service = App("products").image("myorg/products:v1.0").port(8081)
order_service = App("orders").image("myorg/orders:v1.0").port(8082)

platform.add([database, cache, user_service, product_service, order_service])
platform.generate().to_yaml("./k8s/")

ML Training Pipeline

from celestra import Job, CronJob

# One-time training job
training = (Job("model-training")
    .image("ml-framework:latest")
    .resources(cpu="4000m", memory="16Gi")
    .timeout("6h"))

# Scheduled retraining
retrain = (CronJob("model-retrain")
    .image("ml-framework:latest")
    .schedule("0 2 * * 0")  # Weekly
    .resources(cpu="8000m", memory="32Gi"))

training.generate().to_yaml("./jobs/")
retrain.generate().to_yaml("./jobs/")

Complete Web Application

from celestra import App, StatefulApp, Secret, Service, Ingress

# Database
db_secret = Secret("db-secret").add("password", "secure-password")
database = (StatefulApp("database")
    .image("postgres:15")
    .port(5432)
    .storage("50Gi")
    .add_secrets([db_secret]))

# Backend API
api = (App("api")
    .image("myapp/api:latest")
    .port(8080)
    .replicas(3)
    .add_secrets([db_secret]))

# Frontend
frontend = (App("frontend")
    .image("myapp/frontend:latest")
    .port(80)
    .replicas(2))

# Services
api_service = Service("api-service").add_app(api)
frontend_service = Service("frontend-service").add_app(frontend)

# Ingress
ingress = (Ingress("app-ingress")
    .domain("myapp.com")
    .route("/api", api_service)
    .route("/", frontend_service))

# Generate all components
for component in [db_secret, database, api, frontend, api_service, frontend_service, ingress]:
    component.generate().to_yaml("./k8s/")

๐Ÿ“š Documentation

๐Ÿ“ฆ Available Components

Core Components

  • App - Stateless applications (Deployments)
  • StatefulApp - Stateful applications (StatefulSets)
  • AppGroup - Group multiple applications together

Workloads

  • Job - One-time tasks
  • CronJob - Scheduled tasks
  • Lifecycle - Lifecycle hooks

Networking

  • Service - Service definitions
  • Ingress - Ingress controllers
  • NetworkPolicy - Network policies

Security

  • Secret - Secret management
  • ServiceAccount - Service accounts
  • Role / ClusterRole - RBAC roles
  • RoleBinding / ClusterRoleBinding - RBAC bindings
  • SecurityPolicy - Security policies

Storage

  • ConfigMap - Configuration management

Advanced Features

  • Observability - Monitoring and logging
  • DeploymentStrategy - Deployment strategies
  • CostOptimization - Resource optimization
  • CustomResource - Custom resource definitions

๐ŸŒŸ Why Choose Celestra?

For Developers

  • No YAML Hell - Write infrastructure in Python
  • Fast Iteration - Start local, deploy anywhere
  • Type Safety - Catch errors before deployment
  • **Familiar Syntax - If you know Python, you know Celestra

For DevOps Teams

  • Standardization - Consistent deployments across teams
  • Security Built-in - RBAC, secrets, policies by default
  • Multi-Environment - Dev, staging, prod from same code
  • Observability Ready - Monitoring and logging included

For Organizations

  • Reduced Complexity - Abstract Kubernetes details
  • Faster Onboarding - Developers focus on business logic
  • Cost Optimization - Built-in resource management
  • Compliance Ready - Security and governance features

๐Ÿงช Running Examples

# Run comprehensive examples
cd src/examples

# Multiple ports showcase
python multiple_ports_showcase.py

# Enterprise validation demo
python enterprise_validation_demo.py

# Complete platform demo
python complete_platform_demo.py

# RBAC security demo
python rbac_security_demo.py

# Kubernetes YAML generation example
python kubernetes_yaml_generation_example.py

โš ๏ธ Format-Specific Methods & Output Awareness

Celestra supports multiple output formats (Kubernetes, Docker Compose, Helm, etc.). Some methods are only meaningful for certain formats. Celestra will automatically warn you if you use a method that is not supported in your chosen output format!

๐Ÿณ Docker Compose-Only Methods

  • .port_mapping(host_port, container_port, ...) โ€” Only for Docker Compose (host:container mapping)
  • .expose_port(port, ..., external_port=...) โ€” Only for Docker Compose

โ˜ธ๏ธ Kubernetes-Only Methods

  • .node_selector({...}) โ€” Only for Kubernetes (pod scheduling)
  • .tolerations([...]) โ€” Only for Kubernetes (taints/tolerations)

๐Ÿ”„ Universal Methods

  • .port(port) โ€” Works everywhere (container port)
  • .image(image) โ€” Works everywhere
  • .replicas(n) โ€” Works everywhere
  • .env(key, value) โ€” Works everywhere

๐Ÿšฆ How It Works

  • If you use .port_mapping() and generate Kubernetes YAML, you will see:
    โš ๏ธ  Method 'port_mapping()' is Docker Compose-specific and will be ignored in Kubernetes output. For Kubernetes, use 'port()' + 'Service' instead of 'port_mapping()'.
    
  • If you use .node_selector() and generate Docker Compose, you will see:
    โš ๏ธ  Method 'node_selector()' is Kubernetes-specific and will be ignored in Docker Compose output.
    

๐Ÿท๏ธ Decorators for Custom Extensions

You can mark your own methods as format-specific using built-in decorators:

from celestra import docker_compose_only, kubernetes_only, output_formats

@docker_compose_only
def my_compose_method(self, ...): ...

@kubernetes_only
def my_k8s_method(self, ...): ...

@output_formats('kubernetes', 'helm')
def my_multi_format_method(self, ...): ...

๐Ÿ’ก Best Practice

  • For Docker Compose: Use .port_mapping() for host:container mapping
  • For Kubernetes: Use .port() and create a Service for exposure
  • Universal: Use .port(), .image(), .replicas(), .env(), etc.

Celestra will always guide you with clear warnings and suggestions if you use a method in the wrong context!

๐Ÿค Contributing

We welcome contributions! Here's how to get started:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and add tests
  4. Run tests: python run_tests.py
  5. Submit a pull request

See our Contributing Guide for detailed guidelines.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐ŸŽ‰ Get Started Now

# Install Celestra from source
git clone https://github.com/your-org/celestra.git
cd celestra
pip install -e src/

# Create your first application
cat > my_app.py << EOF
from celestra import App

app = (App("hello-world")
    .image("nginxdemos/hello:latest")
    .port(80)
    .replicas(2)
    .expose())

app.generate().to_yaml("./k8s/")
print("โœ… Kubernetes manifests generated in ./k8s/")
EOF

# Generate and deploy
python my_app.py
kubectl apply -f ./k8s/

Ready to simplify your Kubernetes deployments? Check out the complete documentation and join thousands of developers already using Celestra! ๐Ÿš€


Documentation โ€ข Examples โ€ข API Reference โ€ข Components

Made with โค๏ธ by the Celestra community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

celestra-0.0.3.tar.gz (183.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

celestra-0.0.3-py3-none-any.whl (220.5 kB view details)

Uploaded Python 3

File details

Details for the file celestra-0.0.3.tar.gz.

File metadata

  • Download URL: celestra-0.0.3.tar.gz
  • Upload date:
  • Size: 183.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for celestra-0.0.3.tar.gz
Algorithm Hash digest
SHA256 eaa799c932c3c108e7d2a0326ea5680e84f1278c26db9d672c524197ddbefa8f
MD5 cc0bdb04d26c4dc10725581f887a7146
BLAKE2b-256 3ab9fe4364dd44c85080290b1e8a7f6d93adaf8259e7944fb5972263c94ba719

See more details on using hashes here.

Provenance

The following attestation bundles were made for celestra-0.0.3.tar.gz:

Publisher: publish-pypi.yml on sps014/celestra

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file celestra-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: celestra-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 220.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for celestra-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5bbf30ac8a70a08debd033cd630218534b65d868f8ada6746c764370c7259769
MD5 b6e7617d789f187eace2c4f834858bc2
BLAKE2b-256 028fc88b662723bb15917c16d123907ee7a287e1425b64dca9387b2b53f9560a

See more details on using hashes here.

Provenance

The following attestation bundles were made for celestra-0.0.3-py3-none-any.whl:

Publisher: publish-pypi.yml on sps014/celestra

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page