Lab 2.1: Exploring Existing Operators
Related Lesson: Lesson 2.1: The Operator Pattern
Navigation: Module Overview | Next Lab: Kubebuilder Fundamentals →
Objectives
- Explore existing operators in the Kubernetes ecosystem
- Understand operator structure and behavior
- Compare operator vs Helm deployments
- Identify use cases for operators
Prerequisites
- Kind cluster running
- kubectl configured
- Understanding of CRDs from Module 1
Exercise 1: Explore OperatorHub
Task 1.1: Browse OperatorHub
- Visit OperatorHub.io
- Browse available operators
- Look for operators you recognize (Prometheus, PostgreSQL, etc.)
Questions to Answer:
- What categories of operators exist?
- What are some popular operators?
- What problems do they solve?
Task 1.2: Examine Operator Structure
Pick an operator (e.g., Prometheus Operator) and examine:
# Search for operator documentation
# Look at:
# - CRD definitions
# - Operator capabilities
# - Use cases
Exercise 2: Install and Explore an Operator
Task 2.1: Install Prometheus Operator (Optional)
If you want to explore a real operator:
# Install using Helm (for exploration)
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
# Install Prometheus Operator
helm install prometheus prometheus-community/kube-prometheus-stack
Note: This is just for exploration. We’ll build our own operators in this course.
Task 2.2: Examine Operator Resources
# List CRDs created by operator
kubectl get crds | grep prometheus
# Examine a CRD
kubectl get crd prometheuses.monitoring.coreos.com -o yaml | head -50
# See operator deployment
kubectl get deployments -n default | grep prometheus
Exercise 3: Compare Operator vs Helm
Task 3.1: Understand the Difference
Helm Deployment:
# Helm installs once
helm install my-app ./chart
# No ongoing management
Operator Deployment:
# Operator continuously manages
kubectl apply -f custom-resource.yaml
# Operator reconciles continuously
Task 3.2: Identify Use Cases
For each scenario, decide: Operator or Helm?
- Simple web application deployment
- Answer: Helm (one-time setup)
- PostgreSQL database with backups
- Answer: Operator (complex lifecycle)
- Redis cache cluster
- Answer: Operator (stateful, needs management)
- Static website
- Answer: Helm (simple deployment)
Exercise 4: Analyze Operator Patterns
Task 4.1: Operator Components
Based on what you learned in Module 1, operators have:
- CRD - Custom Resource Definition
- Controller - Reconciliation logic
- RBAC - Permissions
# If you installed an operator, examine these:
kubectl get crds
kubectl get deployments
kubectl get clusterroles | grep <operator-name>
Task 4.2: Reconciliation Pattern
Operators follow the same pattern you learned:
graph LR
CR[Custom Resource] --> WATCH[Watch]
WATCH --> RECONCILE[Reconcile]
RECONCILE --> RESOURCES[Resources]
RESOURCES --> STATUS[Update Status]
This is the same pattern from Lesson 1.3!
Exercise 5: Operator Capability Levels
Task 5.1: Identify Capability Levels
For each operator you explored, identify its capability level:
- Level 1: Basic Install
- Level 2: Seamless Upgrades
- Level 3: Full Lifecycle
- Level 4: Deep Insights
- Level 5: Auto Pilot
Task 5.2: Document Findings
Create a simple comparison:
| Operator | Capability Level | Key Features |
|---|---|---|
| Example | Level 3 | Backup, Restore |
Exercise 6: When to Build an Operator
Task 6.1: Decision Tree
Use the decision tree from the lesson:
flowchart TD
START[Need to Deploy App] --> Q1{Complex Lifecycle?}
Q1 -->|No| HELM[Use Helm]
Q1 -->|Yes| Q2{Need Ongoing Management?}
Q2 -->|Yes| OPERATOR[Use Operator]
Task 6.2: Your Use Cases
Think of applications you manage. Which would benefit from operators?
Examples:
- Database with automated backups → Operator
- Simple API service → Helm
- Message queue cluster → Operator
Cleanup
If you installed operators for exploration:
# Remove Helm releases
helm list
helm uninstall <release-name>
# Remove CRDs
kubectl delete crd --all
Lab Summary
In this lab, you:
- Explored existing operators in the ecosystem
- Understood operator structure and components
- Compared operators vs Helm charts
- Identified when to use operators
- Analyzed operator capability levels
Key Learnings
- Operators are controllers that manage Custom Resources
- Operators encode domain knowledge for application management
- Use operators for complex, stateful applications
- Operators follow the same reconciliation pattern as built-in controllers
- Operators provide continuous management vs one-time deployment
Next Steps
Now that you understand what operators are, let’s learn about Kubebuilder - the tool we’ll use to build them!