feat(phase1): Karve controller skeleton with Prometheus integration - #8
Merged
Merged
Conversation
- Initialize Go module with controller-runtime, viper, and prometheus client - Create configuration management package following Lumina patterns - Add basic CLI with leader election support - Set up health check endpoints (/healthz, /readyz) - Add comprehensive test coverage (96%) for config package - Create basic CI/CD workflows (test, lint, build) - Add project documentation (README, CLAUDE.md) - Follow RFC-0003 Phase 1 deliverables 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Create testing framework to simulate Lumina metrics without running actual Lumina or Prometheus instances: - MockPrometheusServer: In-memory HTTP server with Prometheus API - Metric fixtures for common scenarios: - LuminaMetricsWithSPCapacity: Available RI/SP capacity - LuminaMetricsWithNoCapacity: Exhausted capacity - LuminaMetricsEmpty: No data (startup state) - LuminaMetricsWithSpotPrices: Spot pricing data - 100% test coverage on testutil package - Comprehensive README with usage examples Design rationale: - Tests actual HTTP code paths (vs config-based mocks) - No test data pollution in production config - Flexible for unit, integration, and E2E tests - Follows Prometheus HTTP API format exactly Related: RFC-0003 Phase 1 - Prometheus integration testing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add Prometheus client package for querying Lumina metrics with full test coverage. The client provides typed methods for querying: - Savings Plans remaining capacity - Reserved Instances - Spot pricing - On-demand pricing - Data freshness Also enhanced the mock Prometheus server to handle both GET and POST requests properly, matching the behavior of the real Prometheus Go client. Test coverage: - pkg/prometheus: 84.8% - internal/testutil: 86.2% (updated) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add metrics reconciler that periodically queries Prometheus for Lumina metrics and logs Savings Plans and Reserved Instances capacity. The reconciler: - Queries every 5 minutes (configurable) - Logs data freshness from Lumina - Logs SP capacity by instance family - Logs RI availability by instance type - Integrates with controller manager as a runnable This completes Phase 1 core functionality for monitoring cost optimization data from Lumina. Test coverage: - pkg/reconciler: 93.9% 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive E2E test framework following Lumina patterns: - Ginkgo/Gomega BDD-style tests with //go:build e2e tags - Native Kubernetes client helpers (LogsClient, ResourceClient) - No kubectl exec or curl - all interactions via client-go - Mock Prometheus deployment for testing metrics reconciler - Tests verify: - Controller startup and health - Metrics reconciler starts and queries Prometheus - Data freshness logging - Graceful handling of empty metrics - Continued periodic reconciliation Test execution: make test-e2e # Requires Kind cluster This completes Phase 1 with both unit and E2E test coverage. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Refactor E2E test suite to use native Kubernetes client-go API instead of kubectl exec commands, following Lumina's patterns: - Replace all kubectl commands with K8s client calls - Add CreateNamespace, DeleteNamespace methods - Add CreateDeployment, CreateService, DeleteDeployment, DeleteService - Add WaitForDeploymentReady helper - Create all resources (Deployments, Services, ConfigMaps) via API - Remove dependency on kubectl for resource management This provides: - Faster test execution (no subprocess overhead) - Better error handling - More idiomatic Go testing - Consistent with Lumina's E2E patterns 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add dedicated GitHub Actions workflow for E2E tests: - Runs on PRs and main branch pushes - Sets up Kind cluster automatically - Executes E2E tests via make test-e2e - Collects pod logs and events on failure - Runs in parallel with unit tests This ensures E2E tests run in CI and catch integration issues before merge. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add Dockerfile for building Karve controller image - Create mock Lumina exporter that serves Prometheus-format metrics - Deploy real Prometheus server in E2E tests to scrape mock exporter - Update E2E suite to wait for Prometheus to scrape metrics before starting controller - All 7 E2E tests now passing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Update test workflow to use 2cpu-linux-x64 runner with magic cache - Update e2e workflow to use 4cpu-linux-x64 runner with magic cache - Install kind manually instead of using helm/kind-action - Pin action versions with commit SHAs for security - Match Lumina's workflow patterns exactly 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Change from cache=/var/cache/magic/extras=magic-cache to extras=s3-cache - Remove unnecessary step name for runs-on/action@v2 - Follow runs-on.com/caching/magic-cache/ documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add error checking for json.Decoder.Decode() calls - Fixes errcheck linter warnings 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add step to create Kind cluster with 5 minute wait - Add cluster verification step - Tests were failing because no cluster existed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add .golangci.yml with explicit linter configuration matching Lumina - Set 5 minute timeout to prevent workflow timeouts - Update lint workflow to use runs-on runner with s3-cache - Upgrade to golangci-lint-action@v9 with version v2.5.0 - Pin action versions with commit SHAs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add error checking for fmt.Fprintf/Fprint calls - Add error checking for resp.Body.Close() calls using defer with blank identifier - Add error checking for os.Setenv/Unsetenv in tests - Fix long line in test/utils/utils.go by splitting fmt.Errorf across multiple lines All linter issues resolved. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Extract common query building and execution logic into helper functions to eliminate duplication flagged by dupl linter. The QuerySpotPrice and QueryOnDemandPrice methods now use shared buildInstanceTypeQuery and executeQuery helpers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements Phase 1 from RFC-0003: Basic controller skeleton with Prometheus integration to query Lumina metrics.
Changes
Architecture
Test Coverage
Configuration
Default configuration:
prometheusURL:http://prometheus:9090(can override withKARVE_PROMETHEUSURL)logLevel:info(can override withKARVE_LOGLEVEL)Next Steps (Phase 2)
Test plan
make test)make test-e2e)🤖 Generated with Claude Code