Home/Guides/Infrastructure

Infrastructure & Kubernetes Architecture Guide

System Administrator reference manual: Minikube, NetBox and the Hardware Asset Inventory — how they're built, how traffic flows and how to operate them day to day.

Host: Garuda Linux · 192.168.0.193 Minikube v1.35.1 Beginner → Intermediate

Executive summary & high-level architecture

This server hosts two infrastructure management platforms inside a local Kubernetes cluster:

NetBox v4.6.4The network source of truth (IPAM & DCIM): IP addresses, VLANs, racks, devices and cabling.
Hardware Asset InventoryCustom PHP 8.2 + Apache app using external PostgreSQL and FreeIPA LDAP to track equipment, serials and invoices.

How Kubernetes (Minikube) operates on this server

What is Minikube?

Unlike a bare-metal multi-node cluster (k3s or kubeadm), Minikube runs the entire Kubernetes cluster inside a single Docker container called minikube (image gcr.io/k8s-minikube/kicbase). That container emulates a full Linux node with its own:

kubeletKubernetes node agent
kube-apiserverCluster REST API gateway
etcdCluster state database
containerd / dockerInternal container runtime

The network layers explained

Because Kubernetes is containerised inside Docker, packets cross several subnets:

LayerSubnetExample
Physical host network192.168.0.0/24Host 192.168.0.193 on the office switch
Minikube bridge192.168.49.0/24Bridge br-feecf5216366, node 192.168.49.2
Pod network10.244.0.0/16NetBox pod 10.244.0.246
Service network10.96.0.0/12svc/netbox → 10.98.218.25

Why can't LAN computers reach cluster IPs directly?

The 10.244.x.x and 10.96.x.x ranges exist only inside Minikube — the office router and laptops know nothing about them. Two mechanisms expose apps on 192.168.0.193:

Port forwardersAuto-restarting scripts that bind 0.0.0.0 on the host and tunnel into a Service with kubectl port-forward --address 0.0.0.0.
NodePort ServicesOpen a fixed port on the Minikube node, e.g. 30080 for the Hardware app.

Deep dive: NetBox deployment

NetBox is the single source of truth for physical and logical network infrastructure, deployed in the netbox namespace via Helm (release netbox, chart netbox-8.3.34, app v4.6.4 on Python 3.12).

The five key workloads

ComponentResourceReplicasPurpose
Web frontenddeployment/netbox1Django app served by Granian (Rust WSGI server). UI and REST/GraphQL APIs on container port 8080.
Workerdeployment/netbox-worker1Django-RQ worker: async tasks, webhooks, cable-path recalculation, scheduled scripts.
PostgreSQLstatefulset/netbox-postgresql1Internal PostgreSQL 16 holding all IPAM, DCIM and tenant data.
Valkeystatefulset/netbox-valkey-*1 + 3Redis-compatible cache and task-queue broker.
Housekeepingcronjob/netbox-housekeepingNightlyRuns manage.py housekeeping at midnight to purge expired sessions, tokens and old changelog.

Persistent storage (PVCs)

  • data-netbox-postgresql-0 (8 GB) — database files at /bitnami/postgresql/data
  • netbox-media (1 GB) — image attachments, rack diagrams, PDF exports
  • valkey-data-netbox-valkey-* (8 GB each) — AOF logs and RDB snapshots

How NetBox reaches the LAN

# service/netbox listens on :80 (ClusterIP 10.98.218.25)
# ~/.netbox-port-forward.sh runs in the background:
kubectl port-forward --address 0.0.0.0 svc/netbox -n netbox 8080:80

LAN URL: http://192.168.0.193:8080

Deep dive: Hardware Asset Inventory

A web app (source in /home/sensei/workspace/Sysadmin-TheOne) that manages hardware lifecycles, user assignments, warranty tracking and invoice attachments. Stack: PHP 8.2 + Apache (php:8.2-apache).

Source code structure

FileRole
hardware/index.phpMain frontend and asset dashboard
hardware/auth.phpLDAP authentication against FreeIPA
hardware/db.phpPDO PostgreSQL connector
hardware/api.phpJSON endpoints for CRUD and search
hardware/uploads/Uploaded PDF/JPG invoices

Kubernetes manifests

k8s/
├── namespace.yaml      # isolated 'hardware-inventory' namespace
├── configmap.yaml      # non-secret config (DB host/port, LDAP settings)
├── secret.yaml         # database password
├── pvc.yaml            # 2 GB persistent storage for invoices
├── deployment.yaml     # image, health probes and mounts
├── service.yaml        # NodePort 30080
└── ingress.yaml        # hostname routing for hardware.local

ConfigMap

Injects environment variables so the code never hard-codes IP addresses:

apiVersion: v1
kind: ConfigMap
metadata:
  name: hardware-config
  namespace: hardware-inventory
data:
  DB_HOST: "192.168.0.10"
  DB_PORT: "5433"
  DB_NAME: "mangesh_hardware"
  DB_USER: "mangesh_hardware_user"
  LDAP_HOST: "ipa.theonetech.lab"
  LDAP_PORT: "389"
  LDAP_BASE_DN: "dc=theonetech,dc=lab"
  LDAP_REALM: "THEONETECH.LAB"

Secrets: the database password lives in secret.yaml and has been left out of this page on purpose. Keep it out of Git (use Sealed Secrets, SOPS or an external secret store) and rotate it if it was ever committed.

Storage & health checks

PVC (2 GB)Mounted at /var/www/html/hardware/uploads, so pod updates never delete invoices.
Liveness probeGET /index.html every 20 s. If Apache hangs, Kubernetes restarts the container.
Readiness probeGET /index.html must pass before the pod receives traffic.

Two ways the app can run

Primary — KubernetesPod hardware-app-deployment-* in hardware-inventory. Reach it at http://192.168.49.2:30080 or via port-forward.
Secondary — Docker ComposeContainer hardware-inventory-app bound to host port 8090: http://192.168.0.193:8090.

External dependencies & network topology

A · External PostgreSQLServer 192.168.0.10, port 5433, DB mangesh_hardware. Stores hardware records, serials, warranty dates, statuses and invoice metadata.
B · FreeIPA / LDAPipa.theonetech.lab (fallback 192.168.0.194), port 389, realm THEONETECH.LAB. auth.php authenticates users against company credentials.

Network path from a pod to the database

Pod 10.244.x.x→Minikube gateway 192.168.49.1→Host ens18 192.168.0.193→LAN 192.168.0.10:5433

Daily operations & sysadmin runbook

1 · Check general cluster health

minikube status
kubectl get nodes
kubectl get pods -A

Healthy: all pods Running and READY 1/1 (or 3/3 for Valkey).

2 · After a system reboot

Minikube isn't a systemd service by default, so bring everything up manually:

# Step 1: start Minikube
minikube start

# Step 2: start the Hardware Inventory container (Docker Compose)
cd /home/sensei/workspace/Sysadmin-TheOne
docker compose up -d

# Step 3: start the background port forwarders for LAN access
setsid /home/sensei/.netbox-port-forward.sh </dev/null >/dev/null 2>&1 &
setsid /home/sensei/.dashboard-port-forward.sh </dev/null >/dev/null 2>&1 &

Improvement idea: wrap these three steps in a systemd unit (After=docker.service) so the stack starts automatically after a reboot.

3 · View application logs

# NetBox web server
kubectl logs -n netbox -l app.kubernetes.io/name=netbox -c netbox --tail=50 -f

# NetBox worker (background tasks)
kubectl logs -n netbox -l app.kubernetes.io/component=worker --tail=50 -f

# Hardware app — Kubernetes pod
kubectl logs -n hardware-inventory -l app=hardware-app --tail=50 -f

# Hardware app — Docker container
docker logs -f hardware-inventory-app

4 · Open a shell inside a container

# NetBox pod
kubectl exec -it -n netbox deployment/netbox -c netbox -- bash

# Hardware Inventory pod
kubectl exec -it -n hardware-inventory deployment/hardware-app-deployment -- bash

# Test the DB connection from inside the Hardware app pod
php /var/www/html/hardware/test_db.php

5 · Restart an application gracefully

# Zero-downtime rolling restart
kubectl rollout restart deployment netbox -n netbox
kubectl rollout restart deployment hardware-app-deployment -n hardware-inventory

6 · Persistent storage

kubectl get pvc -A

Service & port reference

ServicePortAccessAuthentication
NetBox Web UIHTTP 8080http://192.168.0.193:8080NetBox superuser / DB users
Hardware Asset AppHTTP 8090http://192.168.0.193:8090FreeIPA credentials
Hardware App (NodePort)HTTP 30080http://192.168.49.2:30080FreeIPA credentials
Kubernetes DashboardHTTP 8443http://192.168.0.193:8443Bearer token: kubectl -n kubernetes-dashboard create token kubernetes-dashboard
External PostgreSQLTCP 5433192.168.0.10:5433User mangesh_hardware_user
FreeIPA LDAPTCP 389192.168.0.194:389Realm THEONETECH.LAB

Source document: /home/sensei/workspace/INFRASTRUCTURE_ARCHITECTURE_GUIDE.md · Repository: git@github.com:mangesh4694/Sysadmin-TheOne.git