This guide explains how to set up and run kubechronicle locally for development.
- Go 1.25 or later: Install Go
- kubectl: For testing with Kubernetes (optional)
- PostgreSQL: Optional, for testing storage layer
- openssl: For generating TLS certificates
# Using Makefile (recommended)
make deps
# Or manually
go mod download
go mod tidy# Using Makefile
make build
# Or manually
go build -o bin/webhook ./cmd/webhookFor local development, you need TLS certificates:
# Option 1: Use the deployment script
cd deploy/webhook
./generate-certs.sh
# Copy certificates to project root
mkdir -p ../certs
cp tls.crt ../certs/
cp tls.key ../certs/
cd ../..
# Option 2: Generate manually
mkdir -p certs
openssl req -x509 -newkey rsa:4096 -keyout certs/tls.key -out certs/tls.crt -days 365 -nodes \
-subj "/CN=localhost" \
-addext "subjectAltName=DNS:localhost,DNS:127.0.0.1"# Using Makefile
make run
# Or manually
./bin/webhook \
-port=8443 \
-cert=./certs/tls.crt \
-key=./certs/tls.keyIn another terminal, test the health endpoint:
curl -k https://localhost:8443/healthYou can configure the webhook using environment variables:
export DATABASE_URL="postgres://user:password@localhost:5432/kubechronicle?sslmode=disable"
export TLS_CERT_PATH="./certs/tls.crt"
export TLS_KEY_PATH="./certs/tls.key"
export LOG_LEVEL="debug"make fmt
# or
go fmt ./...make test
# or
go test ./...# Install golangci-lint first
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Run linter
make lintmake docker-build
# or
docker build -t kubechronicle/webhook:latest .If you have a local Kubernetes cluster (minikube, kind, etc.):
# Build and push image (or use local registry)
docker build -t kubechronicle/webhook:latest .
# For kind:
kind load docker-image kubechronicle/webhook:latest
# Deploy
cd deploy/webhook
make deploy# Create a test resource
kubectl create deployment test --image=nginx
# Check webhook logs
kubectl logs -n kubechronicle -l app.kubernetes.io/name=kubechronicle -f.
├── cmd/webhook/ # Main application entry point
├── internal/
│ ├── admission/ # Webhook handler and decoder
│ ├── diff/ # RFC 6902 diff engine
│ ├── store/ # Storage layer
│ ├── model/ # Data models
│ └── config/ # Configuration
├── deploy/webhook/ # Kubernetes manifests
├── bin/ # Build output (gitignored)
└── certs/ # TLS certificates (gitignored)
This is normal for self-signed certificates. Use -k flag with curl or configure your client to skip verification.
Another process is using port 8443. Change the port:
./bin/webhook -port=8444 -cert=./certs/tls.crt -key=./certs/tls.keyMake sure you've generated the certificates and they're in the certs/ directory.