Repository Management
Overview
Hyve uses Git repositories as the single source of truth for all infrastructure state. It supports multiple repositories, allowing you to isolate environments (dev/staging/prod) with separate configurations and credentials.
Multi-Environment
Separate repositories for different environments
Version Control
Full Git history for audit trails and rollbacks
Team Collaboration
Pull requests and code reviews for infrastructure changes
SQLite Backend
Local database tracks repository configurations
Repository Structure
Each repository follows a standard structure:
my-hyve-repo/├── clusters/ # Cluster definitions│ ├── production.yaml│ ├── staging.yaml│ └── development.yaml├── workflows/ # Workflow definitions│ ├── deploy-app.yaml│ ├── setup-monitoring.yaml│ └── backup-db.yaml└── templates/ # Cluster templates ├── prod-template.yaml └── dev-template.yamlAdding Repositories
Basic Repository
# Add a repositoryhyve git add production --repo-url https://github.com/company/hyve-prod.git
# This will:# 1. Clone the repository to ~/.hyve/repositories/production/# 2. Create standard directories (clusters/, workflows/, templates/)# 3. Set it as the active repositoryPrivate Repository
For private repositories, configure Git credentials first:
# Set global Git credentialshyve git credentials --username myuser --password ghp_xxxxxxxxxxxx
# Then add the repositoryhyve git add production --repo-url https://github.com/company/hyve-prod.gitSSH Repository
# Ensure SSH key is loadedeval $(ssh-agent)ssh-add ~/.ssh/id_rsa
# Add repository with SSH URLhyve git add production --repo-url git@github.com:company/hyve-prod.gitManaging Repositories
List Repositories
# List all configured repositorieshyve git listOutput:
Repositories: * production (https://github.com/company/hyve-prod.git) [active] staging (https://github.com/company/hyve-staging.git) development (https://github.com/company/hyve-dev.git)Switch Active Repository
# Switch to different repositoryhyve git use staging
# All subsequent commands use the staging repositoryhyve cluster listView Current Repository
# Show currently active repositoryhyve git currentOutput:
Current repository: productionURL: https://github.com/company/hyve-prod.gitPath: ~/.hyve/repositories/productionRemove Repository
# Remove repository configuration and local clonehyve git remove development
# This deletes:# - Repository configuration from database# - Local clone at ~/.hyve/repositories/development/Multi-Repository Workflows
Environment Isolation
Separate repositories for each environment:
# Production repositoryhyve git add production \ --repo-url https://github.com/company/hyve-prod.git
hyve git use production
# Production clusterhyve cluster add prod-app \ --provider civo \ --region NYC1 \ --nodes g4s.kube.large,g4s.kube.large,g4s.kube.large# Staging repositoryhyve git add staging \ --repo-url https://github.com/company/hyve-staging.git
hyve git use staging
# Staging clusterhyve cluster add staging-app \ --provider civo \ --region PHX1 \ --nodes g4s.kube.medium,g4s.kube.medium# Development repositoryhyve git add development \ --repo-url https://github.com/company/hyve-dev.git
hyve git use development
# Development clusterhyve cluster add dev-app \ --provider civo \ --region LON1 \ --nodes g4s.kube.smallTeam Collaboration
Multiple team members work on the same repository:
Clone repository
# Team member Ahyve git add shared \ --repo-url https://github.com/company/hyve-shared.gitCreate feature branch
# Team member A creates branchcd ~/.hyve/repositories/sharedgit checkout -b add-monitoring-clusterMake changes
# Add cluster definitionhyve cluster add monitoring --provider civo --region NYC1Commit and push
# Commit changesgit add clusters/monitoring.yamlgit commit -m "Add monitoring cluster"git push origin add-monitoring-clusterCreate pull request
Create PR on GitHub/GitLab for team review
Team member B reviews
# Pull changescd ~/.hyve/repositories/sharedgit fetch origingit checkout add-monitoring-cluster
# Review changescat clusters/monitoring.yaml
# Approve PRMerge and reconcile
# After merge, pull main branchgit checkout maingit pull origin main
# Apply changeshyve reconcileRepository Storage
Repositories are stored in ~/.hyve/repositories/:
~/.hyve/repositories/├── production/│ ├── .git/│ ├── clusters/│ │ ├── prod-app.yaml│ │ └── prod-db.yaml│ ├── workflows/│ │ └── deploy-app.yaml│ └── templates/│ └── prod-template.yaml├── staging/│ └── ...└── development/ └── ...Database Storage
Repository configurations are stored in SQLite:
~/.hyve/repositories.db
Tables: - repositories (name, url, path, active)Synchronization
Pull Changes
# Pull latest changes from remotecd ~/.hyve/repositories/productiongit pull origin main
# Or use Hyve commandhyve git sync productionPush Changes
# Hyve commands automatically commit changeshyve cluster add new-cluster --provider civo --region PHX1# Creates clusters/new-cluster.yaml and commits
# Push to remotecd ~/.hyve/repositories/productiongit push origin mainAdvanced Patterns
Monorepo Pattern
Single repository for all environments with subdirectories:
hyve-infra/├── production/│ ├── clusters/│ ├── workflows/│ └── templates/├── staging/│ ├── clusters/│ ├── workflows/│ └── templates/└── development/ ├── clusters/ ├── workflows/ └── templates/# Add with subdirectorieshyve git add production --repo-url https://github.com/company/hyve-infra.git --path productionhyve git add staging --repo-url https://github.com/company/hyve-infra.git --path stagingPer-Team Repositories
Different teams manage separate repositories:
# Platform teamhyve git add platform --repo-url https://github.com/company/platform-infra.git
# Application teamhyve git add application --repo-url https://github.com/company/app-infra.git
# Data teamhyve git add data --repo-url https://github.com/company/data-infra.gitFeature Branch Workflows
Use Git branches for experimental changes:
# Create feature branchcd ~/.hyve/repositories/productiongit checkout -b experiment-new-region
# Make experimental changeshyve cluster add test-cluster --provider civo --region FRA1
# Test reconciliationhyve reconcile --dry-run
# If successful, merge to maingit checkout maingit merge experiment-new-regionhyve reconcileBest Practices
1. Separate Environments
Use different repositories for production, staging, and development:
hyve git add production --repo-url https://github.com/company/hyve-prod.githyve git add staging --repo-url https://github.com/company/hyve-staging.githyve git add development --repo-url https://github.com/company/hyve-dev.gitThis provides isolation and prevents accidental cross-environment changes.
2. Use Protected Branches
Configure branch protection on production repositories:
- Require pull request reviews
- Require status checks to pass
- Require signed commits
- Prevent force pushes
3. Document Repository Purpose
Add README to each repository:
# Hyve Production Infrastructure
This repository contains Kubernetes cluster definitions for production.
## Clusters- prod-app: Main application cluster- prod-db: Database cluster
## Workflows- deploy-app: Application deployment pipeline4. Regular Synchronization
Keep repositories synchronized with remotes:
# Pull before making changescd ~/.hyve/repositories/productiongit pull origin main
# Push after changesgit push origin main5. Use .gitignore
Exclude sensitive or temporary files:
.env.env.**.tmp*.logTroubleshooting
No repository configured
Error: No active repository configured
Solution:
# Add a repositoryhyve git add production --repo-url https://github.com/company/hyve-prod.gitGit authentication fails
Error: Failed to authenticate with repository
Solution:
# Configure credentialshyve git credentials --username myuser --password ghp_xxxxxxxxxxxx
# Or use SSHeval $(ssh-agent)ssh-add ~/.ssh/id_rsaRepository already exists
Error: Repository 'production' already exists
Solution:
# Remove existing repository firsthyve git remove production
# Then add againhyve git add production --repo-url https://github.com/company/hyve-prod.gitMerge conflicts
Error: Merge conflict in clusters/production.yaml
Solution:
# Resolve manuallycd ~/.hyve/repositories/productiongit status# Edit conflicting filesgit add .git commit -m "Resolve merge conflict"