Deploying Kubiya Workflows¶
This guide explains how to deploy Kubiya workflows in various environments.
Local Deployment¶
For local development and testing, you can run Kubiya workflows directly in your Python application.
Python
from kubiya_sdk import Workflow
from kubiya_sdk.tools import tool
@tool()
def hello_world(name: str) -> str:
return f"Hello, {name}!"
workflow = Workflow(
id="hello-workflow",
description="A simple hello world workflow",
tools=[hello_world]
)
result = workflow.execute({"name": "User"})
print(result) # Output: "Hello, User!"
Server Deployment¶
For production environments, you can deploy Kubiya workflows as a service using the Kubiya server component:
1. Install Server Dependencies¶
2. Create a Server Configuration¶
Python
# server.py
from kubiya_sdk.server import KubiyaServer
from kubiya_sdk import Workflow
from kubiya_sdk.tools import tool
@tool()
def hello_world(name: str) -> str:
return f"Hello, {name}!"
# Create a workflow
workflow = Workflow(
id="hello-workflow",
description="A simple hello world workflow",
tools=[hello_world]
)
# Create and start the server
server = KubiyaServer()
server.register_workflow(workflow)
if __name__ == "__main__":
server.start()
3. Start the Server¶
The server will start on http://localhost:8000 by default.
Docker Deployment¶
You can also deploy Kubiya workflows using Docker:
1. Create a Dockerfile¶
Docker
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python", "server.py"]
2. Create a requirements.txt file¶
3. Build and Run the Docker Container¶
Bash
# Build the Docker image
docker build -t kubiya-workflows .
# Run the Docker container
docker run -p 8000:8000 kubiya-workflows
Environment Configuration¶
You can configure your Kubiya deployment using environment variables:
KUBIYA_LOG_LEVEL: Set the logging level (e.g., INFO, DEBUG)KUBIYA_PORT: The port for the server to listen onKUBIYA_HOST: The host address to bind to
Example:
Next Steps¶
- Secure your deployment with API keys and authentication
- Set up monitoring and logging for your deployments
- Consider implementing rate limiting and caching for production workloads