Module 4: Advanced Reconciliation Patterns

Overview

Now that you can build basic operators (Module 3), it’s time to learn advanced patterns that make operators production-ready. This module covers status management, finalizers, watching, and sophisticated reconciliation patterns that handle real-world complexity.

Duration: 6-7 hours
Prerequisites:

Learning Objectives

By the end of this module, you will:

  • Implement proper status management with conditions
  • Use finalizers for graceful resource cleanup
  • Set up watches and indexes for efficient controllers
  • Implement multi-phase reconciliation and state machines
  • Handle external dependencies and ensure idempotency

Module Structure

  1. Lesson 4.1: Conditions and Status Management
  2. Lesson 4.2: Finalizers and Cleanup
  3. Lesson 4.3: Watching and Indexing
  4. Lesson 4.4: Advanced Patterns

Prerequisites Check

Before starting, ensure you’ve completed:

If you haven’t completed Module 3, start with Module 3: Building Custom Controllers.

What You’ll Build

Throughout this module, you’ll enhance your PostgreSQL operator from Module 3 with:

  • Proper status conditions (Ready, Progressing, Failed)
  • Finalizers for graceful cleanup
  • Watches for dependent resources
  • Multi-phase deployment patterns
  • State machine for complex workflows

Setup

Before starting this module:

  1. Have your PostgreSQL operator from Module 3:
    • You should have a working database operator
    • It should create StatefulSets and Services
    • Basic reconciliation should be working
  2. Ensure development environment is ready:
    ./scripts/setup-dev-environment.sh
    
  3. Have a kind cluster running:
    ./scripts/setup-kind-cluster.sh
    

Hands-on Labs

Each lesson includes hands-on exercises that enhance your operator.

Solutions

Complete working solutions for all labs are available in the solutions directory: