Skip to content

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)

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.

Install LoKO from PyPI:

Terminal window
pip install getloko

Verify installation:

Terminal window
loko --version

On first run, LoKO automatically checks prerequisites. You can also check manually:

Terminal window
loko check prerequisites

Expected 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!

Create your configuration file:

Terminal window
loko config generate

This creates loko.yaml with auto-detected settings.

Let’s review what was generated:

Terminal window
cat loko.yaml | head -30

Key settings:

  • Environment name: Based on your hostname
  • Domain: <hostname>.local
  • Network IP: Your local IP address
  • Cluster: 1 control-plane + 2 workers

Create the complete environment:

Terminal window
loko env create

This process takes ~2-3 minutes. LoKO will:

  1. ✅ Generate configuration files
  2. ✅ Create TLS certificates with LoKO’s cfssl-based certificate flow
  3. ✅ Start DNS service
  4. ✅ Create Kind cluster
  5. ✅ Deploy Traefik ingress controller
  6. ✅ Deploy Zot container registry
  7. ✅ Deploy metrics-server
  8. ✅ Validate the environment

Watch the progress bars as LoKO sets everything up!

Check that everything is running:

Terminal window
loko status

You 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.

Let’s deploy a PostgreSQL database.

Terminal window
loko workloads add postgres

This adds PostgreSQL to your config but doesn’t deploy it yet.

Terminal window
loko workloads enable postgres --now

The --now flag enables and deploys in one command.

Watch the deployment:

Terminal window
loko workloads list

Expected output:

┏━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Name ┃ Type ┃ Namespace ┃ Status ┃
┡━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ postgres │ system │ common-services │ deployed │
└──────────┴────────┴──────────────────┴──────────┘
Terminal window
loko workloads endpoints postgres

Output:

┏━━━━━━━━┳━━━━━━━━━━┳━━━━━━┳━━━━━━━━━━━━━━━━━━━━┓
┃ Name ┃ Protocol ┃ Port ┃ External URL ┃
┡━━━━━━━━╇━━━━━━━━━━╇━━━━━━╇━━━━━━━━━━━━━━━━━━━━┩
│ client │ tcp │ 5432 │ postgres.dev.me │
└────────┴──────────┴──────┴────────────────────┘
Terminal window
loko workloads connect postgres --show-password

Output:

Connection strings for postgres:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
default: postgresql://postgres:abc123xyz@postgres.dev.me:5432/postgres
jdbc: jdbc:postgresql://postgres.dev.me:5432/postgres?user=postgres&password=abc123xyz
Terminal window
psql -h postgres.dev.me -U postgres

Enter the password from the connection string.

If DNS isn’t configured yet:

Terminal window
# In one terminal
kubectl port-forward svc/postgres 5432:5432 -n common-services
# In another terminal
psql -h localhost -p 5432 -U postgres
Terminal window
# Get password
PASSWORD=$(loko secrets show --format json | jq -r '.postgres.password')
# Connect via Docker
docker run -it --rm postgres:15 \
psql -h postgres.dev.me -U postgres -W

Once connected to psql, try some commands:

-- Create a test database
CREATE DATABASE testdb;
-- List databases
\l
-- Create a table
\c testdb
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR(100),
email VARCHAR(100)
);
-- Insert data
INSERT INTO users (name, email) VALUES
('Alice', 'alice@example.com'),
('Bob', 'bob@example.com');
-- Query data
SELECT * FROM users;

Output:

id | name | email
----+-------+-------------------
1 | Alice | alice@example.com
2 | Bob | bob@example.com

Perfect! Your database is working.

Let’s add a web interface for PostgreSQL.

Terminal window
loko workloads info postgres

This shows postgres-ui (pgAdmin) as a linked workload.

Terminal window
# Add the postgres-ui workload
loko workloads add postgres-ui --now

Open your browser and go to:

https://postgres-ui.dev.me

Login credentials:

  • Email: admin@pgadmin.org
  • Password: From loko secrets show
Terminal window
loko secrets show | grep postgres-ui
  1. Click “Add New Server”
  2. General tab:
    • Name: Local Postgres
  3. Connection tab:
    • Host: postgres.common-services.svc.cluster.local
    • Port: 5432
    • Username: postgres
    • Password: (from secrets)
  4. Click “Save”

You can now browse your database using the web UI!

Check what’s happening in PostgreSQL:

Terminal window
# View recent logs
loko logs workload postgres --tail 50
# Follow logs in real-time
loko logs workload postgres --follow

Run health checks:

Terminal window
# Infrastructure tier (port connectivity, default)
loko workloads check postgres
# Client tier (runs a query using psql)
loko workloads check postgres --tier client

Output:

Health check for postgres:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✓ Port 5432 is reachable
✓ PostgreSQL is responding
✓ Query executed successfully
Status: Healthy

Let’s add MySQL and Redis:

Terminal window
# Add MySQL
loko workloads add mysql --now
# Add Valkey (Redis-compatible)
loko workloads add valkey --now
# List all workloads
loko workloads list

LoKO includes a container registry. Let’s use it:

Terminal window
loko registry status
Terminal window
# Create a simple Dockerfile
cat > Dockerfile <<EOF
FROM nginx:alpine
RUN echo '<h1>Hello from LoKO!</h1>' > /usr/share/nginx/html/index.html
EOF
# Build image
docker build -t cr.dev.me/hello:latest .
# Push to registry
docker push cr.dev.me/hello:latest
# Verify
loko registry list-repos
Terminal window
loko env stop

Cluster containers stop but data persists.

Terminal window
loko env start

Everything resumes where you left off!

Terminal window
loko secrets show

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

Now that you have a working environment:

When you’re done experimenting:

Terminal window
loko env destroy
Terminal window
loko env clean
Terminal window
pip uninstall getloko

Questions or issues? Check the Troubleshooting Guide or open an issue.