Tutorial: Your First Cluster
This hands-on tutorial will guide you through creating your first LoKO environment, deploying a database, and connecting to it.
Time required: ~15 minutes
What you’ll learn:
- Install LoKO
- Generate and customize configuration
- Create a Kubernetes cluster
- Deploy a PostgreSQL database
- Connect to the database
- Deploy a web UI (pgAdmin)
Prerequisites
Section titled “Prerequisites”Before starting, ensure you have:
- Python 3.9+
- Docker Desktop running
- 8GB RAM available
- Internet connection
If you haven’t installed prerequisites yet, see the Installation Guide.
Step 1: Install LoKO
Section titled “Step 1: Install LoKO”Install LoKO from PyPI:
pip install getlokoVerify installation:
loko --versionOn first run, LoKO automatically checks prerequisites. You can also check manually:
loko check prerequisitesExpected output:
✓ Docker is installed (version 24.0.0)✓ Git is installed (version 2.x)✓ Kind is installed (version 0.20.0)✓ Helm is installed (version 3.13.0)✓ Helmfile is installed (version 0.158.0)✓ cfssl is installed✓ kubectl is installed (version 1.28.0)
All prerequisites are satisfied!Step 2: Generate Configuration
Section titled “Step 2: Generate Configuration”Create your configuration file:
loko config generateThis creates loko.yaml with auto-detected settings.
Let’s review what was generated:
cat loko.yaml | head -30Key settings:
- Environment name: Based on your hostname
- Domain:
<hostname>.local - Network IP: Your local IP address
- Cluster: 1 control-plane + 2 workers
Step 3: Create Environment
Section titled “Step 3: Create Environment”Create the complete environment:
loko env createThis process takes ~2-3 minutes. LoKO will:
- ✅ Generate configuration files
- ✅ Create TLS certificates with LoKO’s
cfssl-based certificate flow - ✅ Start DNS service
- ✅ Create Kind cluster
- ✅ Deploy Traefik ingress controller
- ✅ Deploy Zot container registry
- ✅ Deploy metrics-server
- ✅ Validate the environment
Watch the progress bars as LoKO sets everything up!
Step 4: Verify Environment
Section titled “Step 4: Verify Environment”Check that everything is running:
loko statusYou should see:
╭─────────────────────────── Cluster Status ────────────────────────────╮│ Cluster: dev-hostname ││ Provider: kind ││ Status: ✓ Running │╰───────────────────────────────────────────────────────────────────────╯
╭─────────────────────────── Node Status ───────────────────────────────╮│ NAME ROLE STATUS AGE ││ dev-hostname-control-plane control-plane Ready 2m ││ dev-hostname-worker worker Ready 2m ││ dev-hostname-worker2 worker Ready 2m │╰───────────────────────────────────────────────────────────────────────╯Excellent! Your cluster is ready.
Step 5: Deploy PostgreSQL
Section titled “Step 5: Deploy PostgreSQL”Let’s deploy a PostgreSQL database.
Add PostgreSQL from Catalog
Section titled “Add PostgreSQL from Catalog”loko workloads add postgresThis adds PostgreSQL to your config but doesn’t deploy it yet.
Enable and Deploy
Section titled “Enable and Deploy”loko workloads enable postgres --nowThe --now flag enables and deploys in one command.
Wait for Deployment
Section titled “Wait for Deployment”Watch the deployment:
loko workloads listExpected output:
┏━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┓┃ Name ┃ Type ┃ Namespace ┃ Status ┃┡━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━┩│ postgres │ system │ common-services │ deployed │└──────────┴────────┴──────────────────┴──────────┘Step 6: Get Connection Details
Section titled “Step 6: Get Connection Details”View Endpoints
Section titled “View Endpoints”loko workloads endpoints postgresOutput:
┏━━━━━━━━┳━━━━━━━━━━┳━━━━━━┳━━━━━━━━━━━━━━━━━━━━┓┃ Name ┃ Protocol ┃ Port ┃ External URL ┃┡━━━━━━━━╇━━━━━━━━━━╇━━━━━━╇━━━━━━━━━━━━━━━━━━━━┩│ client │ tcp │ 5432 │ postgres.dev.me │└────────┴──────────┴──────┴────────────────────┘Get Connection Strings
Section titled “Get Connection Strings”loko workloads connect postgres --show-passwordOutput:
Connection strings for postgres:━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━default: postgresql://postgres:abc123xyz@postgres.dev.me:5432/postgresjdbc: jdbc:postgresql://postgres.dev.me:5432/postgres?user=postgres&password=abc123xyzStep 7: Connect to PostgreSQL
Section titled “Step 7: Connect to PostgreSQL”Using psql (if installed)
Section titled “Using psql (if installed)”psql -h postgres.dev.me -U postgresEnter the password from the connection string.
Using Port Forward
Section titled “Using Port Forward”If DNS isn’t configured yet:
# In one terminalkubectl port-forward svc/postgres 5432:5432 -n common-services
# In another terminalpsql -h localhost -p 5432 -U postgresUsing Docker
Section titled “Using Docker”# Get passwordPASSWORD=$(loko secrets show --format json | jq -r '.postgres.password')
# Connect via Dockerdocker run -it --rm postgres:15 \ psql -h postgres.dev.me -U postgres -WStep 8: Test the Database
Section titled “Step 8: Test the Database”Once connected to psql, try some commands:
-- Create a test databaseCREATE DATABASE testdb;
-- List databases\l
-- Create a table\c testdbCREATE TABLE users ( id SERIAL PRIMARY KEY, name VARCHAR(100), email VARCHAR(100));
-- Insert dataINSERT INTO users (name, email) VALUES ('Alice', 'alice@example.com'), ('Bob', 'bob@example.com');
-- Query dataSELECT * FROM users;Output:
id | name | email----+-------+------------------- 1 | Alice | alice@example.com 2 | Bob | bob@example.comPerfect! Your database is working.
Step 9: Deploy pgAdmin Web UI
Section titled “Step 9: Deploy pgAdmin Web UI”Let’s add a web interface for PostgreSQL.
Check Available Linked Workloads
Section titled “Check Available Linked Workloads”loko workloads info postgresThis shows postgres-ui (pgAdmin) as a linked workload.
Add and Deploy UI
Section titled “Add and Deploy UI”# Add the postgres-ui workloadloko workloads add postgres-ui --nowAccess pgAdmin
Section titled “Access pgAdmin”Open your browser and go to:
https://postgres-ui.dev.meLogin credentials:
- Email:
admin@pgadmin.org - Password: From
loko secrets show
loko secrets show | grep postgres-uiAdd PostgreSQL Server in pgAdmin
Section titled “Add PostgreSQL Server in pgAdmin”- Click “Add New Server”
- General tab:
- Name:
Local Postgres
- Name:
- Connection tab:
- Host:
postgres.common-services.svc.cluster.local - Port:
5432 - Username:
postgres - Password: (from secrets)
- Host:
- Click “Save”
You can now browse your database using the web UI!
Step 10: View Logs
Section titled “Step 10: View Logs”Check what’s happening in PostgreSQL:
# View recent logsloko logs workload postgres --tail 50
# Follow logs in real-timeloko logs workload postgres --followStep 11: Check Health
Section titled “Step 11: Check Health”Run health checks:
# Infrastructure tier (port connectivity, default)loko workloads check postgres
# Client tier (runs a query using psql)loko workloads check postgres --tier clientOutput:
Health check for postgres:━━━━━━━━━━━━━━━━━━━━━━━━━━━━✓ Port 5432 is reachable✓ PostgreSQL is responding✓ Query executed successfully
Status: HealthyStep 12: Deploy More Workloads
Section titled “Step 12: Deploy More Workloads”Let’s add MySQL and Redis:
# Add MySQLloko workloads add mysql --now
# Add Valkey (Redis-compatible)loko workloads add valkey --now
# List all workloadsloko workloads listStep 13: Explore the Registry
Section titled “Step 13: Explore the Registry”LoKO includes a container registry. Let’s use it:
View Registry Status
Section titled “View Registry Status”loko registry statusBuild and Push an Image
Section titled “Build and Push an Image”# Create a simple Dockerfilecat > Dockerfile <<EOFFROM nginx:alpineRUN echo '<h1>Hello from LoKO!</h1>' > /usr/share/nginx/html/index.htmlEOF
# Build imagedocker build -t cr.dev.me/hello:latest .
# Push to registrydocker push cr.dev.me/hello:latest
# Verifyloko registry list-reposStep 14: Manage Your Environment
Section titled “Step 14: Manage Your Environment”Stop Environment (Preserve Data)
Section titled “Stop Environment (Preserve Data)”loko env stopCluster containers stop but data persists.
Start Environment
Section titled “Start Environment”loko env startEverything resumes where you left off!
View All Secrets
Section titled “View All Secrets”loko secrets showWhat You’ve Learned
Section titled “What You’ve Learned”Congratulations! You’ve:
- ✅ Installed LoKO and prerequisites
- ✅ Generated and customized configuration
- ✅ Created a local Kubernetes cluster with Kind
- ✅ Deployed PostgreSQL database
- ✅ Connected to the database via psql
- ✅ Deployed pgAdmin web UI
- ✅ Performed health checks and viewed logs
- ✅ Used the local container registry
- ✅ Managed environment lifecycle
Next Steps
Section titled “Next Steps”Now that you have a working environment:
Tutorials
Section titled “Tutorials”User Guides
Section titled “User Guides”- Workload Management - Deploy more services
- Network & DNS - Configure DNS
- Registry - Use the local registry
- Configuration - Customize your setup
Reference
Section titled “Reference”- CLI Reference - All commands
- Workload Catalog - Available workloads
- Troubleshooting - Common issues
Clean Up
Section titled “Clean Up”When you’re done experimenting:
Soft Cleanup (Keep Configuration)
Section titled “Soft Cleanup (Keep Configuration)”loko env destroyFull Cleanup (Remove Everything)
Section titled “Full Cleanup (Remove Everything)”loko env cleanRemove LoKO
Section titled “Remove LoKO”pip uninstall getlokoQuestions or issues? Check the Troubleshooting Guide or open an issue.