The Problem


I noticed my Kubernetes cluster would sometimes have unbalanced pod distribution across nodes. This led to resource hotspots and inefficiency.


The Solution: Rebalancer Operator


I built a Kubernetes operator that:


  1. Watches pod and node resource usage
  2. Calculates optimal pod distribution
  3. Safely migrates pods to balance the cluster
  4. Respects PodDisruptionBudgets and node affinities

  5. Architecture


    Built with:

    • controller-runtime: Kubernetes controller framework
    • Custom Resources: RebalancingPolicy CRD
    • Webhooks: Admission validation
    • Metrics: Prometheus integration

    What I Learned


    1. Kubernetes Internals

    Understanding controllers, reconciliation loops, and the API server was crucial.


    2. Concurrency Patterns

    Managing multiple workers and handling race conditions required careful design.


    3. Testing Strategies

    Testing operators requires mocking the Kubernetes API - I used envtest.


    4. Operational Concerns

    • Leader election for high availability
    • Graceful degradation
    • Comprehensive logging and metrics

    Current Status


    The operator is in active development. Next steps:


    • Add cost-aware rebalancing
    • Implement dry-run mode
    • Create comprehensive dashboards
    • Write operator hub integration

    This project taught me more about Kubernetes than any certification could.