KubeGuard is a lightweight, self-hosted Kubernetes security scanner for detecting misconfigurations.
2.1K
A lightweight, comprehensive Kubernetes security scanner built with Java and Spring Boot. Provides actionable insights into security misconfigurations for both static manifests and live clusters.
# Pull and run the latest version
docker pull mvrao94/kubeguard:latest
docker run -d -p 8080:8080 --name kubeguard mvrao94/kubeguard:latest
# Access the application
curl http://localhost:8080/actuator/health
# Download docker-compose.yml
curl -O https://raw.githubusercontent.com/mvrao94/KubeGuard/main/scripts/docker-compose.yml
# Start all services (KubeGuard + PostgreSQL + Monitoring)
docker-compose up -d
latest - Latest stable release from main branch1.x.x - Specific version tagsdevelop - Development branch (may be unstable)linux/amd64 - x86_64 / AMD64linux/arm64 - ARM64 / Apple Silicon| Variable | Default | Description |
|---|---|---|
SERVER_PORT | 8080 | Application HTTP port |
SPRING_PROFILES_ACTIVE | docker | Spring profile (docker/prod/dev) |
ENABLE_DEBUG | false | Enable remote debugging on port 5005 |
DEBUG_PORT | 5005 | Remote debug port |
TZ | UTC | Container timezone |
docker run -d \
-p 8080:8080 \
-e SPRING_PROFILES_ACTIVE=prod \
-e TZ=America/New_York \
--memory=1g \
--name kubeguard \
mvrao94/kubeguard:latest
docker run -d \
-p 8080:8080 \
-e SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/kubeguard \
-e SPRING_DATASOURCE_USERNAME=kubeguard \
-e SPRING_DATASOURCE_PASSWORD=your_password \
--link postgres:postgres \
--name kubeguard \
mvrao94/kubeguard:latest
Enable remote debugging for development:
docker run -d \
-p 8080:8080 \
-p 5005:5005 \
-e ENABLE_DEBUG=true \
--name kubeguard \
mvrao94/kubeguard:latest
Connect your IDE debugger to localhost:5005.
The image includes built-in health checks:
# Check health status
docker inspect --format='{{.State.Health.Status}}' kubeguard
# Via API
curl http://localhost:8080/actuator/health
curl http://localhost:8080/actuator/health/liveness
curl http://localhost:8080/actuator/health/readiness
Once running, access:
http://localhost:8080http://localhost:8080/swagger-ui.htmlhttp://localhost:8080/actuator/healthhttp://localhost:8080/actuator/metricshttp://localhost:8080/actuator/prometheus# Scan a Kubernetes manifest
curl -X POST http://localhost:8080/api/v1/scans/manifest \
-H "Content-Type: application/json" \
-d '{
"manifestContent": "apiVersion: v1\nkind: Pod\nmetadata:\n name: test-pod\nspec:\n containers:\n - name: nginx\n image: nginx:latest"
}'
# Get scan results
curl http://localhost:8080/api/v1/scans/{scanId}
# Run with resource limits
docker run -d \
-p 8080:8080 \
--memory=1g \
--cpus=1 \
--name kubeguard \
mvrao94/kubeguard:latest
Mount volumes for persistent data:
docker run -d \
-p 8080:8080 \
-v $(pwd)/logs:/app/logs \
-v $(pwd)/config:/app/config \
-v $(pwd)/manifests:/app/manifests:ro \
--name kubeguard \
mvrao94/kubeguard:latest
Complete stack with PostgreSQL, Prometheus, and Grafana:
version: '3.8'
services:
kubeguard:
image: mvrao94/kubeguard:latest
ports:
- "8080:8080"
environment:
- SPRING_PROFILES_ACTIVE=docker
- SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/kubeguard
- SPRING_DATASOURCE_USERNAME=kubeguard
- SPRING_DATASOURCE_PASSWORD=kubeguard123
depends_on:
- postgres
restart: unless-stopped
postgres:
image: postgres:17-alpine
environment:
- POSTGRES_DB=kubeguard
- POSTGRES_USER=kubeguard
- POSTGRES_PASSWORD=kubeguard123
volumes:
- postgres_data:/var/lib/postgresql/data
restart: unless-stopped
volumes:
postgres_data:
The container runs as a non-root user (UID 1001) for enhanced security.
All images are:
# Run with read-only root filesystem
docker run -d \
-p 8080:8080 \
--read-only \
--tmpfs /tmp \
--tmpfs /app/logs \
--name kubeguard \
mvrao94/kubeguard:latest
# Drop all capabilities
docker run -d \
-p 8080:8080 \
--cap-drop=ALL \
--security-opt=no-new-privileges:true \
--name kubeguard \
mvrao94/kubeguard:latest
Deploy to Kubernetes:
apiVersion: apps/v1
kind: Deployment
metadata:
name: kubeguard
spec:
replicas: 2
selector:
matchLabels:
app: kubeguard
template:
metadata:
labels:
app: kubeguard
spec:
containers:
- name: kubeguard
image: mvrao94/kubeguard:latest
ports:
- containerPort: 8080
env:
- name: SPRING_PROFILES_ACTIVE
value: "prod"
resources:
requests:
memory: "512Mi"
cpu: "500m"
limits:
memory: "1Gi"
cpu: "1000m"
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
initialDelaySeconds: 60
periodSeconds: 30
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
name: kubeguard
spec:
selector:
app: kubeguard
ports:
- port: 80
targetPort: 8080
type: LoadBalancer
The application exposes Prometheus metrics at /actuator/prometheus:
# Scrape metrics
curl http://localhost:8080/actuator/prometheus
Import the pre-built Grafana dashboard from the repository:
# Check logs
docker logs kubeguard
# Common issues:
# - Database not ready (add depends_on with health check)
# - Port already in use (change port mapping)
# - Out of memory (increase container memory)
# Verify database is running
docker ps | grep postgres
# Check network connectivity
docker exec kubeguard ping postgres
# Verify environment variables
docker exec kubeguard env | grep DATASOURCE
# Check current usage
docker stats kubeguard
# Adjust JVM settings
docker run -d -p 8080:8080 \
-e JAVA_OPTS="-XX:MaxRAMPercentage=50.0" \
mvrao94/kubeguard:latest
# Enable debug logging
docker run -d -p 8080:8080 \
-e LOGGING_LEVEL_COM_KUBEGUARD=DEBUG \
mvrao94/kubeguard:latest
# View logs
docker logs -f kubeguard
# Clone repository
git clone https://github.com/mvrao94/KubeGuard.git
cd KubeGuard
# Build with Maven
mvn clean package
# Build Docker image
docker build -t kubeguard:custom -f scripts/Dockerfile .
For issues, questions, or contributions:
MIT License - see LICENSE for details.
Note: This is a security scanning tool. Always review scan results and apply fixes according to your organization's security policies.
Content type
Image
Digest
sha256:da31481f0…
Size
169.8 MB
Last updated
2 months ago
docker pull mvrao94/kubeguard:0.0.4-SNAPSHOT