Skip to content

A basic container image with lmsensors. The container hosts a script that runs lmsensors every 60 seconds and ouputs it to a html file.

License

Notifications You must be signed in to change notification settings

MichaelTrip/lmsensors-container

Repository files navigation

๐ŸŒก๏ธ LMSensors Kubernetes Monitor

Real-time hardware monitoring for Kubernetes clusters with dynamic configuration and beautiful web interface

Build Status License Latest Release Container Registry

LMSensors Dashboard

โœจ Features

  • ๐Ÿ”ฅ Real-time Monitoring: Live hardware sensor data from all cluster nodes
  • ๐ŸŽจ Modern UI: Beautiful terminal-style web interface with dark theme
  • โš™๏ธ Dynamic Configuration: ConfigMap-based node management with hot-reload
  • ๐Ÿš€ Cloud Native: Kubernetes-first design with DaemonSet architecture
  • ๐Ÿ“ฑ Responsive: Works perfectly on desktop and mobile devices
  • ๐Ÿ”„ Smart Discovery: Configurable auto-discovery with manual node control
  • ๐Ÿ“Š Multi-Node: Monitor temperature, voltage, and system info across your entire cluster
  • ๐Ÿ› ๏ธ Management Tools: CLI tools for easy configuration management
  • โšก Lightweight: Optimized containers with minimal resource footprint

๐Ÿ—๏ธ Architecture

This project uses a dynamic configuration microservice architecture:

Component Purpose Image Deployment
Sensor DaemonSet Hardware data collection ghcr.io/michaeltrip/lmsensors-daemonset-container Runs on every node
Web Dashboard Modern web interface ghcr.io/michaeltrip/lmsensors-web Centralized deployment
ConfigMap Dynamic node configuration Built-in Kubernetes Configuration storage

๐Ÿ”ง Sensor DaemonSet

  • Purpose: Collects hardware sensor data from each node
  • Technology: Ubuntu + lm_sensors + fastfetch
  • Deployment: Runs on every node via DaemonSet
  • Data: Temperature, voltage, fan speeds, system information
  • Schedule: Updates every 60 seconds
  • Output: Standardized file format (lmsensors-{node}.txt, fastfetch-{node}.txt)

๐ŸŒ Web Dashboard

  • Purpose: Modern web interface with dynamic configuration
  • Technology: nginx + responsive HTML/CSS/JS + ConfigMap integration
  • Features: Real-time updates, configurable nodes, mobile-friendly
  • Configuration: Loads node definitions from ConfigMap endpoint
  • Access: Single deployment with service endpoint

โš™๏ธ Dynamic Configuration

  • Purpose: Centralized node management without code changes
  • Technology: Kubernetes ConfigMap + custom nginx endpoints
  • Features: Hot-reload, CLI management, backup/restore
  • Control: Define which nodes to display with metadata

๐Ÿš€ Quick Start

Get up and running in under 2 minutes with dynamic configuration:

# Clone the repository
git clone https://github.com/MichaelTrip/lmsensors-container.git
cd lmsensors-container

# Deploy with dynamic configuration
./deploy-dynamic.sh

# Access the dashboard
kubectl port-forward service/sensordash-service 8080:80 -n sensordash

Then open http://localhost:8080 in your browser! ๐ŸŽ‰

โš™๏ธ Configuration Management

๐ŸŽ›๏ธ Node Configuration

Define your nodes in the ConfigMap with rich metadata:

{
  "nodes": [
    {
      "name": "virt1",
      "displayName": "Virtual Node 1",
      "description": "Primary virtual machine",
      "status": "online"
    },
    {
      "name": "worker-01",
      "displayName": "Production Worker 01",
      "description": "Main production workload node",
      "status": "online"
    }
  ],
  "settings": {
    "refreshInterval": 30000,
    "fallbackNodes": ["node-001", "node-002"],
    "autoDiscovery": true,
    "displayMode": "terminal"
  }
}

๐Ÿ› ๏ธ Management Tools

Interactive Configuration Manager

# View current configuration
./config-manager.sh view

# Add a new node
./config-manager.sh add worker-02 "Production Worker 02"

# Remove a node
./config-manager.sh remove old-node

# Edit configuration interactively
./config-manager.sh edit

# Backup configuration
./config-manager.sh backup

# Show example configuration
./config-manager.sh example

Direct kubectl Management

# View current node configuration
kubectl get configmap sensordash-config -n sensordash -o jsonpath='{.data.nodes\.json}' | jq .

# Edit configuration directly
kubectl edit configmap sensordash-config -n sensordash

# Apply new configuration
kubectl apply -f deployment-files/configmap.yaml -n sensordash

๐Ÿ”ง Configuration Options

Setting Description Default Example
refreshInterval Update frequency (ms) 30000 60000
fallbackNodes Placeholder nodes when no data [] ["node-001", "node-002"]
autoDiscovery Auto-add discovered nodes true false
displayMode UI theme "terminal" "terminal"

๐Ÿท๏ธ Node Properties

Property Required Description Example
name โœ… Node identifier (matches sensor files) "worker-01"
displayName โŒ Human-readable name "Production Worker 01"
description โŒ Node description (shown in tooltips) "Main production node"
status โŒ Default status indicator "online"

๐Ÿ“ฆ Container Images

Container Registry Latest Version
DaemonSet ghcr.io/michaeltrip/lmsensors-daemonset-container:latest Sensor
Web UI ghcr.io/michaeltrip/lmsensors-web:latest Web

๐Ÿ”ง Requirements

  • Kubernetes cluster (1.19+)
  • Persistent volume support (ReadWriteMany)
  • Privileged container support (for hardware access)
  • jq command-line tool (for config-manager.sh)

๐Ÿ“‹ What You'll Monitor

  • ๐ŸŒก๏ธ CPU Temperature - Real-time thermal monitoring
  • โšก Voltage Rails - Power supply monitoring
  • ๐ŸŒ€ Fan Speeds - Cooling system status
  • ๐Ÿ’พ System Info - Hardware specifications
  • ๐Ÿ“Š Node Status - Health indicators with custom metadata
  • ๐Ÿ”„ Live Updates - Configurable auto-refresh intervals
  • ๐Ÿท๏ธ Custom Labels - User-defined display names and descriptions

๐Ÿ› ๏ธ Deployment Options

๐Ÿš€ Dynamic Configuration (Recommended)

# Deploy with ConfigMap-based dynamic configuration
./deploy-dynamic.sh

# Manage nodes with CLI tool
./config-manager.sh view
./config-manager.sh add worker-03 "Worker Node 03"

๐Ÿ“ Project Structure

โ”œโ”€โ”€ sensor-container/         # DaemonSet container source
โ”œโ”€โ”€ web-container/           # Web interface container source
โ”œโ”€โ”€ deployment-files/        # Kubernetes manifests
โ”‚   โ”œโ”€โ”€ configmap.yaml      # Dynamic node configuration
โ”‚   โ”œโ”€โ”€ webserver-modern.yaml # Web deployment with ConfigMap
โ”‚   โ”œโ”€โ”€ daemonset.yaml      # Sensor collection DaemonSet
โ”‚   โ””โ”€โ”€ pvc.yaml           # Persistent volume claim
โ”œโ”€โ”€ deploy-dynamic.sh        # Quick deployment with ConfigMap
โ”œโ”€โ”€ config-manager.sh        # Configuration management CLI
โ”œโ”€โ”€ .github/workflows/       # CI/CD pipelines
โ””โ”€โ”€ cleanup.sh              # Cleanup script

๐Ÿ› ๏ธ Manual Deployment

Click to expand manual deployment steps
# 1. Create namespace
kubectl create namespace sensordash

# 2. Deploy dynamic configuration
kubectl apply -f deployment-files/configmap.yaml -n sensordash

# 3. Deploy persistent volume claim
kubectl apply -f deployment-files/pvc.yaml -n sensordash

# 4. Deploy sensor collection DaemonSet
kubectl apply -f deployment-files/daemonset.yaml -n sensordash

# 5. Deploy web dashboard with ConfigMap integration
kubectl apply -f deployment-files/webserver-modern.yaml -n sensordash

# 6. Access the dashboard
kubectl port-forward service/sensordash-service 8080:80 -n sensordash

๐ŸŽฏ Configuration Examples

Basic Node Setup

{
  "nodes": [
    {
      "name": "control-plane",
      "displayName": "Control Plane",
      "description": "Kubernetes master node",
      "status": "online"
    },
    {
      "name": "worker-01",
      "displayName": "Worker Node 01",
      "description": "Production workload node",
      "status": "online"
    }
  ]
}

Advanced Configuration

{
  "nodes": [
    {
      "name": "gpu-node-01",
      "displayName": "๐ŸŽฎ GPU Worker 01",
      "description": "NVIDIA RTX 4090 - ML Training Node",
      "status": "online"
    },
    {
      "name": "storage-node",
      "displayName": "๐Ÿ’พ Storage Node",
      "description": "High-capacity storage with NVMe arrays",
      "status": "warning"
    }
  ],
  "settings": {
    "refreshInterval": 15000,
    "fallbackNodes": ["placeholder-01", "placeholder-02"],
    "autoDiscovery": false,
    "displayMode": "terminal"
  }
}

kubectl apply -f deployment-files/webserver-modern.yaml

4. Access the dashboard

kubectl port-forward service/sensordash-service 8080:80


</details>

## ๐Ÿงน Cleanup

Remove all components safely:

```bash
./cleanup.sh

# Or manual cleanup
kubectl delete namespace sensordash --cascade=foreground

The cleanup script will:

  • Remove all deployments and services
  • Delete the sensordash namespace
  • Optionally preserve your sensor data
  • Confirm before destructive operations

๐Ÿ”„ Configuration Updates

Hot Reload Configuration

Changes to the ConfigMap are automatically picked up by the web interface:

# Method 1: Use the management tool
./config-manager.sh add new-node "New Node Display Name"

# Method 2: Edit directly
kubectl edit configmap sensordash-config -n sensordash

# Method 3: Apply updated file
kubectl apply -f deployment-files/configmap.yaml -n sensordash

Backup and Restore

# Backup current configuration
./config-manager.sh backup
# Creates: sensordash-config-backup-YYYYMMDD-HHMMSS.json

# Restore from backup
./config-manager.sh restore sensordash-config-backup-20250910-143022.json

๐Ÿš€ CI/CD Pipeline

This project uses semantic versioning with conventional commits:

  • ๐ŸŽฏ Automatic versioning based on commit messages
  • ๐Ÿ—๏ธ Parallel container builds for optimal speed
  • ๐Ÿ“ฆ Multi-platform support (linux/amd64)
  • ๐Ÿ”„ Auto-deployment file updates
  • ๐Ÿท๏ธ Smart tagging with semantic versions

Commit Convention

feat: add new sensor support     # โ†’ Minor version bump
fix: resolve memory leak         # โ†’ Patch version bump
feat!: breaking API change       # โ†’ Major version bump

๐Ÿ‘จโ€๐Ÿ’ป Development

Local Development

# Build containers locally
docker build -t lmsensors-daemonset:dev sensor-container/
docker build -t lmsensors-web:dev web-container/

# Test with docker-compose (if available)
docker-compose up

# Test configuration changes
kubectl apply -f deployment-files/configmap.yaml -n sensordash
./config-manager.sh view

Contributing

  1. ๐Ÿด Fork the repository
  2. ๐ŸŒฟ Create a feature branch
  3. ๐Ÿ“ Use conventional commits
  4. ๐Ÿงช Test your changes
  5. ๏ฟฝ Test ConfigMap functionality
  6. ๏ฟฝ๐Ÿ“ค Submit a pull request

Testing Configuration Changes

# Test configuration manager
./config-manager.sh example
./config-manager.sh add test-node "Test Node"
./config-manager.sh view
./config-manager.sh remove test-node

# Test web interface updates
kubectl port-forward service/sensordash-service 8080:80 -n sensordash
# Visit http://localhost:8080 and verify changes

๐Ÿ“– Advanced Usage

Custom nginx Configuration

The ConfigMap includes nginx configuration for serving the node configuration:

# Custom endpoint in ConfigMap
location /config/nodes.json {
    alias /etc/sensordash/nodes.json;
    add_header Content-Type application/json;
    add_header Cache-Control "no-cache, no-store, must-revalidate";
}

Integration with Monitoring Tools

Export configuration for external tools:

# Get configuration in various formats
kubectl get configmap sensordash-config -n sensordash -o jsonpath='{.data.nodes\.json}' | jq .

# Export for Prometheus labels
kubectl get configmap sensordash-config -n sensordash -o jsonpath='{.data.nodes\.json}' | jq -r '.nodes[] | "\(.name)=\(.displayName)"'

Multi-Environment Setup

Use different ConfigMaps per environment:

# Development
kubectl apply -f configmaps/dev-config.yaml -n sensordash-dev

# Production
kubectl apply -f configmaps/prod-config.yaml -n sensordash-prod

๐Ÿ“ธ Screenshots

๐Ÿ–ฅ๏ธ Desktop View

Desktop Dashboard

Modern terminal-style interface with real-time sensor data

๐Ÿค Support

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

โญ Show Your Support

If this project helped you, please consider:

  • โญ Starring the repository
  • ๐Ÿด Forking for your own use
  • ๐Ÿ“ข Sharing with others
  • ๐Ÿ› Contributing improvements

Built with โค๏ธ for the Kubernetes community

Caution

Running containers with privileged access can pose security risks. Be cautious where and how you use such configurations.

About

A basic container image with lmsensors. The container hosts a script that runs lmsensors every 60 seconds and ouputs it to a html file.

Resources

License

Contributing

Stars

Watchers

Forks

Packages