Skip to main content

CLI tool and Python library for automating Couchbase Capella infrastructure setup

Project description

Couchbase Infrastructure

A Python CLI tool and library for automating Couchbase Capella infrastructure setup, including projects, clusters, databases, and AI models.

Features

  • 🚀 One-Command Setup: Deploy complete Capella infrastructure with a single command
  • 🔧 CLI & Library: Use as a command-line tool or import as a Python library
  • 🤖 AI Model Support: Automated deployment of embedding and LLM models
  • 📦 Sample Data Loading: Automatically load sample datasets like travel-sample
  • 🔐 Credential Management: Secure API key and database user management
  • ⚙️ Configurable: Customize via environment variables or config files
  • 🎨 Rich Output: Beautiful CLI with progress indicators and colored output

Installation

From PyPI

pip install couchbase-infrastructure

From Source

git clone https://github.com/couchbase/couchbase-infrastructure.git
cd couchbase-infrastructure
pip install -e .

Prerequisites

Before using this tool, you need:

  1. Couchbase Capella Account: Sign up at cloud.couchbase.com
  2. Management API Key: Generate from Capella Console → Settings → API Keys
    • Required permissions: Organization Admin
  3. Organization ID (optional, will auto-detect if not provided)

Get Your Management API Key

  1. Log in to Couchbase Capella Console
  2. Navigate to Settings → API Keys
  3. Create a new API key with Organization Admin permissions
  4. Add your current IP address to the allowlist
  5. Copy the API key (you'll only see it once!)

Quick Start

1. Set Environment Variables

Create a .env file:

# Required
MANAGEMENT_API_KEY=your_api_key_here

# Optional (will auto-detect if not provided)
ORGANIZATION_ID=your_org_id_here

# Optional customizations
PROJECT_NAME=Agent-Hub-Project
CLUSTER_NAME=agent-hub-cluster
DB_USERNAME=agent_app_user
EMBEDDING_MODEL_NAME=nvidia/nv-embedqa-mistral-7b-v2
LLM_MODEL_NAME=meta/llama-3.1-8b-instruct

2. Run Full Setup

couchbase-infra setup --env-file .env

This will:

  1. ✅ Create or find a Capella project
  2. ✅ Deploy a free tier cluster
  3. ✅ Configure network access (allowlist)
  4. ✅ Load travel-sample dataset
  5. ✅ Create database credentials
  6. ✅ Deploy embedding and LLM models
  7. ✅ Create API key for models

CLI Usage

Test Connection

Test your API credentials:

couchbase-infra test-connection --env-file .env

Full Setup

Deploy complete infrastructure:

# Basic setup
couchbase-infra setup --env-file .env

# Skip AI model deployment
couchbase-infra setup --env-file .env --skip-models

# Skip sample data loading
couchbase-infra setup --env-file .env --skip-sample-data

# Set custom timeout (in seconds)
couchbase-infra setup --env-file .env --timeout 3600

List Resources

# List all projects
couchbase-infra list-projects

# List all clusters
couchbase-infra list-clusters

Get Help

# General help
couchbase-infra --help

# Command-specific help
couchbase-infra setup --help

Programmatic Usage

Use as a Python library in your own scripts:

from couchbase_infrastructure import (
    CapellaClient,
    CapellaConfig,
    create_project,
    create_cluster,
    deploy_ai_model,
)

# Load configuration from environment
config = CapellaConfig.from_env(".env")

# Initialize client
client = CapellaClient(config)
org_id = client.get_organization_id()

# Test connection
if client.test_connection(org_id):
    print("Connected successfully!")

# Create project
project_id = create_project(client, org_id, "My Project")

# Create cluster
cluster_id = create_cluster(client, org_id, project_id, "my-cluster", config)

# Deploy AI model
model_id = deploy_ai_model(
    client,
    org_id,
    "nvidia/nv-embedqa-mistral-7b-v2",
    "my-embedding-model",
    "embedding",
    config,
)

Configuration Options

All options can be set via environment variables:

Required

  • MANAGEMENT_API_KEY: Your Capella Management API key

Optional

  • ORGANIZATION_ID: Organization ID (auto-detected if not provided)
  • API_BASE_URL: API base URL (default: cloudapi.cloud.couchbase.com)

Project & Cluster

  • PROJECT_NAME: Project name (default: Agent-Hub-Project)
  • CLUSTER_NAME: Cluster name (default: agent-hub-flight-cluster)
  • CLUSTER_CLOUD_PROVIDER: Cloud provider (default: aws)
  • CLUSTER_REGION: AWS region (default: us-east-2)
  • CLUSTER_CIDR: CIDR block (default: 10.1.30.0/23)

Database

  • DB_USERNAME: Database username (default: agent_app_user)
  • SAMPLE_BUCKET: Sample bucket name (default: travel-sample)

AI Models

  • EMBEDDING_MODEL_NAME: Embedding model (default: nvidia/nv-embedqa-mistral-7b-v2)
  • LLM_MODEL_NAME: LLM model (default: meta/llama-3.1-8b-instruct)
  • AI_MODEL_REGION: AI model region (default: us-east-1)
  • EMBEDDING_MODEL_CPU: Embedding CPU cores (default: 4)
  • EMBEDDING_MODEL_GPU_MEMORY: Embedding GPU memory GB (default: 24)
  • LLM_MODEL_CPU: LLM CPU cores (default: 4)
  • LLM_MODEL_GPU_MEMORY: LLM GPU memory GB (default: 48)

Network & Timeouts

  • ALLOWED_CIDR: Allowed CIDR for cluster access (default: 0.0.0.0/0)
  • RESOURCE_TIMEOUT: Timeout in seconds (default: no timeout)

Model Compute Sizes

Available compute sizes for AI models:

Size CPU (vCPUs) GPU Memory (GB)
Extra Small 4 24
Small 4 48
Medium 48 192
Large 192 320
Extra Large 192 640

Note: Extra Large may not be available in sandbox environments.

Troubleshooting

Authentication Failed (401)

  1. Verify your API key is correct and not expired
  2. Check if your current IP is in the API key allowlist
  3. Ensure the API key has Organization Admin permissions

Get your current IP:

curl -s https://api.ipify.org

Free Tier Cluster Already Exists

Capella free tier allows only one cluster. The tool will automatically detect and use the existing cluster.

Timeout Issues

For slower provisioning, increase the timeout:

couchbase-infra setup --timeout 7200  # 2 hours

Or remove timeout completely (wait indefinitely) by not setting the --timeout flag.

Connection Issues

Test your connection first:

couchbase-infra test-connection

Development

Setup Development Environment

# Clone repository
git clone https://github.com/couchbase/couchbase-infrastructure.git
cd couchbase-infrastructure

# Install with dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black couchbase_infrastructure/
ruff check couchbase_infrastructure/

# Type check
mypy couchbase_infrastructure/

Project Structure

couchbase-infrastructure/
├── couchbase_infrastructure/
│   ├── __init__.py       # Package initialization
│   ├── cli.py            # CLI interface
│   ├── client.py         # API client
│   ├── config.py         # Configuration
│   └── resources.py      # Resource management
├── tests/                # Unit tests
├── pyproject.toml        # Package metadata
└── README.md             # Documentation

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

Apache License 2.0. See LICENSE for details.

Support

Related Projects

Changelog

0.1.0 (2024-10-15)

  • Initial release
  • Full infrastructure automation
  • CLI and library support
  • AI model deployment
  • Sample data loading

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

couchbase_infrastructure-0.1.7.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

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

couchbase_infrastructure-0.1.7-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file couchbase_infrastructure-0.1.7.tar.gz.

File metadata

  • Download URL: couchbase_infrastructure-0.1.7.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for couchbase_infrastructure-0.1.7.tar.gz
Algorithm Hash digest
SHA256 594748bffa443de2fcb9f4c5f33fc8ef4abb9c59087815cac63386d53dcf5149
MD5 c2edc6be0a245a8442d974b5dd05527e
BLAKE2b-256 eb7a349d500a39633d30da4ce39b78b70b66f0a2f5bf6a7034d4ea4e145ff53d

See more details on using hashes here.

File details

Details for the file couchbase_infrastructure-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for couchbase_infrastructure-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b1a24a8ad667a19bd9ae1d918d337bd89e9b027cb78f96f0c006e5a43b40679c
MD5 4c85fb8151fc155798cc7f59f5c9e532
BLAKE2b-256 15b697a376b282af473bf04d60739eff6d2806c7cff04547c002ec7730395cdc

See more details on using hashes here.

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