Run Antbase in Docker and Kubernetes
·4 min read
🐳

Run Antbase in Docker and Kubernetes

Deploy applications that use Antbase in Docker containers and Kubernetes clusters. Covers Dockerfiles, environment variables, and health checks.

dockerkubernetesdevops

Containerizing an AI-powered application sounds straightforward until you hit the operational reality. Your app depends on an external LLM provider, which means you need to handle API key rotation, provider outages, timeout configuration, and health checks that actually verify AI connectivity — not just that your process is running. Most Docker guides for AI apps skip all of this and show you a Dockerfile that hardcodes everything.

Antbase simplifies the operational story significantly. Instead of configuring multiple provider keys, fallback logic, and retry policies in your container, you configure one Antbase API key. Antbase handles the multi-provider routing, failover, and retries server-side. Your container stays thin and stateless — it just talks to one endpoint. This is especially important in Kubernetes, where you want your pods to be as simple as possible and let external services handle complexity.

For teams running AI workloads in Kubernetes, Antbase also eliminates a common scaling headache: provider rate limits. When your HPA scales up to 10 pods and they all hit the same OpenAI endpoint, you can blow through rate limits quickly. Antbase distributes requests across multiple providers automatically, so your cluster can scale without hitting single-provider bottlenecks.

Running your Antbase-powered application in Docker ensures consistent environments from development to production. This guide covers building containers, managing API keys safely, and deploying to Kubernetes.

Dockerfile

dockerfile
FROM node:22-slim
WORKDIR /app

COPY package*.json ./
RUN npm ci --production

COPY . .

# Do NOT bake the API key into the image
# Pass it at runtime via environment variable
ENV ANTBASE_API_KEY=""

EXPOSE 3000
CMD ["node", "server.js"]

Running with Docker

bash
# Build
docker build -t my-ai-app .

# Run with API key
docker run -d \
  --name my-ai-app \
  -p 3000:3000 \
  -e ANTBASE_API_KEY=ant_your-api-key \
  my-ai-app

Kubernetes Deployment

yaml
# Create the secret
# kubectl create secret generic antbase --from-literal=api-key=ant_your-api-key

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-ai-app
spec:
  replicas: 2
  selector:
    matchLabels:
      app: my-ai-app
  template:
    metadata:
      labels:
        app: my-ai-app
    spec:
      containers:
        - name: app
          image: my-ai-app:latest
          ports:
            - containerPort: 3000
          env:
            - name: ANTBASE_API_KEY
              valueFrom:
                secretKeyRef:
                  name: antbase
                  key: api-key

Tips

  • •Never bake API keys into Docker images. Use environment variables or Kubernetes secrets.
  • •Antbase handles retries and failover server-side, so you do not need retry logic in your container.
  • •For health checks, your app should verify it can reach api.antbase.ai. A simple GET to /v1/models works.
  • •In Kubernetes, use a HorizontalPodAutoscaler if your app makes many concurrent AI calls — Antbase handles the backend scaling.

Try ANT routing today

Drop-in OpenAI-compatible API. Change your base URL and every request gets intelligent routing across 30+ providers.