Skip to content
rohIta-kPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

React TypeScript Vite Go Kubernetes MySQL Zustand Tailwind CSS

K8lab

A visual Kubernetes lab for inspecting cluster state, understanding resource relationships, and reproducing Kubernetes failure scenarios.

K8lab is a Kubernetes visualization and experimentation platform that provides a higher-level interface over the Kubernetes API.

It brings resource inspection, topology visualization, workload state, experiment execution, logs, and operational activity into a single interface, while keeping the underlying Kubernetes objects and their behaviour visible.

The project is designed around a simple idea: make Kubernetes behaviour observable and reproducible without requiring every interaction to begin with a kubectl command.


🎯 Why I Built This

Working with Kubernetes often requires correlating information from multiple sources: resource specifications, object relationships, container states, events, logs, and controller behaviour.

K8lab provides a visual layer over these primitives so that this information can be inspected together rather than reconstructed manually from individual commands.

The experimentation layer extends this further by allowing common Kubernetes failure modes to be reproduced on demand, making the resulting Kubernetes state directly observable.


πŸŽ₯ Demo

▢️ Watch the K8lab Demo


Core Capabilities

Cluster Management

  • Connect to configured Kubernetes clusters
  • Switch between available clusters
  • View cluster health and workload statistics
  • Inspect cluster-level activity
  • Use the selected cluster as the execution context for resource and experiment operations

Resource Explorer

The Resources page provides an inventory view over Kubernetes objects.

  • Browse workloads and Kubernetes resources
  • Filter resources by resource type
  • Inspect resource metadata and status
  • View detailed resource information
  • Inspect generated YAML representations
  • Delete resources directly from the interface

Topology Visualization

The topology service transforms Kubernetes resources into a graph representation consumed by the frontend.

Relationships between resources such as:

Node
  └── Deployment
        └── ReplicaSet
              └── Pod
                    └── Container

can be explored visually alongside networking resources such as Services and Ingresses.

The frontend uses React Flow to provide interactive graph navigation

Kubernetes Experiments

The experiment subsystem provides reproducible scenarios for common Kubernetes lifecycle and scheduling failures.

Experiment Kubernetes behaviour
CrashLoopBackOff Container repeatedly terminates and is restarted
ImagePullBackOff Container image cannot be pulled
OOMKilled Container exceeds its memory limit
Pending Pod Pod cannot be scheduled due to resource requirements
Failed Liveness Probe Kubelet repeatedly restarts an unhealthy container

Each execution receives a unique runID and is associated with the target cluster and experiment.

The backend uses Kubernetes labels to isolate resources belonging to a particular execution:

k8lab.io/experiment=<experiment-id>
k8lab.io/run=<run-id>

This allows resources created by different experiment runs to be identified, monitored, stopped, and removed independently.

Live Experiment Observability

Experiment execution is asynchronous. The backend creates the Kubernetes resources and immediately returns an ExperimentRun. The frontend then polls the logs endpoint while the experiment is active.

The returned log stream combines:

  • Experiment-level messages generated by the backend
  • Raw Kubernetes container logs retrieved through the Kubernetes API

Polling stops automatically when the run reaches a terminal state.

Activities Storage

Important operations are recorded through the activity service rather than directly writing to the database from individual handlers.

Cluster operation
       ↓
Domain Service
       ↓
recordActivity()
       ↓
Activity Service
       ↓
MySQL

This provides a consistent activity trail for cluster operations, resource operations, and experiment lifecycle events.

πŸ—οΈ Architecture

K8lab follows a layered frontend β†’ API β†’ service β†’ infrastructure architecture.

flowchart LR
    User[User]

    subgraph Frontend["React + Vite"]
        UI[React UI]
        Store[Zustand Store]
        Hooks[Custom Hooks]
        Services[API Services]
    end

    subgraph Backend["Go Backend"]
        Router[HTTP Router]
        Handlers[HTTP Handlers]
        Cluster[Cluster Service]
        Resource[Resource Service]
        Topology[Topology Service]
        Experiment[Experiment Service]
        Activity[Activity Service]
    end

    K8s[(Kubernetes API)]
    MySQL[(MySQL)]

    User --> UI
    UI --> Hooks
    Hooks --> Store
    Store --> Services
    Services --> Router
    Router --> Handlers

    Handlers --> Cluster
    Handlers --> Resource
    Handlers --> Topology
    Handlers --> Experiment

    Cluster --> K8s
    Resource --> K8s
    Topology --> K8s
    Experiment --> K8s

    Cluster --> Activity
    Resource --> Activity
    Topology --> Activity
    Experiment --> Activity

    Activity --> MySQL
Loading

Request Flow

React Component
      ↓
Custom Hook
      ↓
Zustand Store
      ↓
Frontend Service
      ↓
Go HTTP Handler
      ↓
Domain Service
      ↓
Kubernetes client-go
      ↓
Kubernetes API Server

Experiment Execution Flow

Start Experiment
      ↓
POST /api/clusters/{clusterId}/experiments/{experimentId}/run
      ↓
Experiment Service
      ↓
Create ExperimentRun
      ↓
KubernetesRunner.Run()
      ↓
Create Kubernetes resources
      ↓
Return runID
      ↓
Frontend polling
      ↓
GET /api/clusters/{clusterId}/experiments/runs/{runId}/logs
      ↓
ExperimentService.GetLogs()
      ↓
KubernetesRunner.Logs()
      ↓
Kubernetes API
      ↓
Status + experiment messages + pod logs
      ↓
Frontend

πŸ› οΈ Tech Stack

Layer Technology
Frontend React, TypeScript, Vite
State Zustand
Styling Tailwind CSS
Routing React Router
Visualization React Flow
Backend Go, net/http
Kubernetes Kubernetes client-go
Database MySQL
Data JSON / YAML
Development Make, Git

πŸ“ Project Structure

k8lab/
β”œβ”€β”€ README.md
β”œβ”€β”€ Makefile
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ Makefile
β”‚   β”œβ”€β”€ go.mod
β”‚   β”œβ”€β”€ cmd/
β”‚   β”‚   └── server/
β”‚   β”‚       └── main.go
β”‚   └── internal/
β”‚       β”œβ”€β”€ activity/
β”‚       β”œβ”€β”€ api/
β”‚       β”œβ”€β”€ cluster/
β”‚       β”œβ”€β”€ config/
β”‚       β”œβ”€β”€ database/
β”‚       β”œβ”€β”€ experiment/
β”‚       β”œβ”€β”€ resource/
β”‚       └── topology/
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ Makefile
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ vite.config.ts
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ public/
β”‚   └── src/
β”‚       β”œβ”€β”€ App.tsx
β”‚       β”œβ”€β”€ components/
β”‚       β”œβ”€β”€ constants/
β”‚       β”œβ”€β”€ data/
β”‚       β”œβ”€β”€ hooks/
β”‚       β”œβ”€β”€ layouts/
β”‚       β”œβ”€β”€ pages/
β”‚       β”œβ”€β”€ routes/
β”‚       β”œβ”€β”€ services/
β”‚       β”œβ”€β”€ store/
β”‚       β”œβ”€β”€ styles/
β”‚       β”œβ”€β”€ types/
β”‚       └── utils/
└── .gitignore

πŸš€ Setup

Prerequisites

  • Node.js 18+
  • Go 1.26+
  • MySQL
  • A Kubernetes cluster
  • A valid Kubernetes kubeconfig

1. Clone

git clone <repository-url>
cd k8lab

2. Install frontend dependencies and start frontend

cd frontend
npm install
npm run dev

Frontend:

http://localhost:5173

3. Configure and Start backend

In another terminal:

cd backend
##Set the MySQL connection string:
export K8LAB_MYSQL_DSN="user:password@tcp(localhost:3306)/k8lab?parseTime=true"
##Run database migrations
##Create the database if it does not already exist:
##The backend uses the available Kubernetes kubeconfig to connect to the target cluster.
mysql -u root -p -e "CREATE DATABASE IF NOT EXISTS k8lab;"
##Apply the initial migration:
mysql -u root -p k8lab < internal/database/migrations/001_create_activities.up.sql
go run ./cmd/server

Backend will be available at:

http://localhost:8080

Optional Make commands

From the project root:

make frontend
make backend
make build

Built with React, Go, Kubernetes, and a lot of kubectl debugging.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages