Module 3: Building Custom Controllers
Overview
Now that you’ve built your first operator in Module 2, it’s time to dive deeper into building sophisticated controllers. This module teaches you the advanced patterns and techniques needed to build production-ready operators that manage complex applications.
Duration: 6-7 hours
Prerequisites:
- Completion of Module 1: Kubernetes Architecture Deep Dive
- Completion of Module 2: Introduction to Operators
- Understanding of the basic operator pattern
Learning Objectives
By the end of this module, you will:
- Understand controller-runtime architecture in depth
- Design well-structured APIs for your operators
- Implement robust reconciliation logic
- Work effectively with the Kubernetes client
- Build a database operator that manages PostgreSQL
Module Structure
- Lesson 3.1: Controller Runtime Deep Dive
- Lesson 3.2: Designing Your API
- Lesson 3.3: Implementing Reconciliation Logic
- Lesson 3.4: Working with Client-Go
Prerequisites Check
Before starting, ensure you’ve completed:
- ✅ Module 1: Understand CRDs, controllers, and reconciliation
- ✅ Module 2: Built your first “Hello World” operator
- ✅ Can scaffold kubebuilder projects
- ✅ Understand the Reconcile function basics
If you haven’t completed Module 2, start with Module 2: Introduction to Operators.
What You’ll Build
Throughout this module, you’ll build a PostgreSQL operator that:
- Manages PostgreSQL database instances
- Handles database creation and configuration
- Manages StatefulSets and Services
- Implements proper reconciliation logic
- Uses owner references for resource management
This builds on your “Hello World” operator from Module 2, adding complexity and real-world patterns.
Setup
Before starting this module:
- Verify Module 2 completion:
- You should have built a “Hello World” operator
- You understand kubebuilder project structure
- You can run operators locally
- Ensure development environment is ready:
./scripts/setup-dev-environment.sh - Have a kind cluster running:
./scripts/setup-kind-cluster.sh
Hands-on Labs
Each lesson includes hands-on exercises building toward a complete PostgreSQL operator.
- Lab 3.1: Exploring Controller Runtime
- Lab 3.2: API Design for Database Operator
- Lab 3.3: Building PostgreSQL Operator
- Lab 3.4: Advanced Client Operations
Solutions
Complete working solutions for all labs are available in the solutions directory:
- Lab 3.3 Solutions - Complete Database operator (types, controller with StatefulSet/Service)