Deploy Guide · Python

Deploy a FastAPI App

Go from `uvicorn main:app` to a public HTTPS URL in under 2 minutes.

Overview

FastAPI is the modern Python framework for building high-performance REST and async APIs. It starts fast, runs fast, and deserves an equally fast deployment experience. Kubeletto containerizes your FastAPI app, manages TLS, and scales it to zero when idle.

Prerequisites

  • A FastAPI app with requirements.txt
  • uvicorn or gunicorn[uvicorn] as the ASGI server
  • A Kubeletto account

Step-by-Step Guide

Deploying FastAPI to Kubeletto is done by configuring a Dockerfile, connecting your GitHub repository, and setting environment variables. Follow this step-by-step checklist to deploy your code:

  1. 1

    Create a Dockerfile

    Use the official Python slim image and uvicorn as your ASGI server.

    dockerfile
    FROM python:3.12-slim
    WORKDIR /app
    COPY requirements.txt .
    RUN pip install --no-cache-dir -r requirements.txt
    COPY . .
    EXPOSE 8000
    CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
  2. 2

    Push to GitHub and connect

    Install the Kubeletto GitHub App, select your repo, and every push deploys automatically.

    bash
    git add Dockerfile
    git commit -m "add production Dockerfile"
    git push origin main
    # Kubeletto detects the push and starts building
  3. 3

    Inject environment variables

    Use Pydantic Settings to read config from environment — never hardcode secrets.

    bash
    kubeletto env set DATABASE_URL=postgresql+asyncpg://... --app fastapi-app
    kubeletto env set SECRET_KEY=your-key --app fastapi-app

Sample Environment Variables

To configure your FastAPI application, set these key-value pairs in the environment variables tab of the Kubeletto console or CLI. Ensure production secrets are flagged as write-only:

.env
DATABASE_URL=postgresql+asyncpg://user:pass@host:5432/dbname
SECRET_KEY=your-secret
REDIS_URL=redis://...
ENVIRONMENT=production

Related Kubeletto Features

Kubeletto offers automatic SSL certificate provisioning, zero-downtime rollbacks, and scale-to-zero autoscaling for FastAPI container workloads:

PaaS Platform Comparisons

See how Kubeletto compares directly against other cloud platforms and PaaS providers when deploying Python workloads:

Frequently Asked Questions

Find direct answers to common questions about hosting, building, scaling, and managing FastAPI containerized apps on Kubeletto:

Does Kubeletto support async FastAPI endpoints?

Yes. Kubeletto runs your container as-is. Use uvicorn or hypercorn for full async support — the platform places no restrictions on your ASGI server.

Can I run Alembic migrations on deploy?

Yes. Wrap your CMD in an entrypoint.sh that runs `alembic upgrade head` before launching uvicorn.

How many workers should I configure?

Kubeletto handles horizontal scaling via Knative autoscaler. Keep 1–2 uvicorn workers per container and let the platform scale out pods instead of up.

Deploy your FastAPI app today

Free during our active beta. No credit card required.

Start Deploying Free