A Kubernetes controller that manages nginx deployments through custom resources.
The MyNginx Controller creates and manages nginx deployments based on MyNginx custom resources. It supports configurable replicas, optional ConfigMap integration for custom HTML content, and optional Secret integration for TLS certificates.
- ✅ Custom Resource Management: Define nginx deployments via
MyNginxCRD - ✅ Scalable Deployments: Configurable replica count
- ✅ Lifecycle Management: Proper cleanup with finalizers
- 🔄 ConfigMap Integration: Mount custom HTML content (planned)
- 🔄 TLS Support: Mount TLS certificates from Secrets (planned)
- 🔄 Status Reporting: Rich error and status information (planned)
- Kubernetes cluster (1.32+)
- kubectl configured
- Go 1.23.0+ (for development)
# Deploy the controller
make deploy
# Create a sample MyNginx resource
kubectl apply -f examples/basic-mynginx.yaml
# Check the deployment
kubectl get mynginx
kubectl get deploymentapiVersion: webapp.mynginx.amandahla.xyz/v1
kind: MyNginx
metadata:
name: my-nginx
spec:
replicas: 3- 📘 Claude AI Guide - Comprehensive guide for AI assistants
- 🚀 Examples - Usage examples and scenarios
- 🛠 Contributing - Development guidelines
- 📋 TODO - Planned features and tasks
- 🤖 AI Prompts - AI assistant prompts and examples
- 🏗 Architecture Decisions - Design decisions and rationale
-
The controller should read a CRD with definitions of:
-
Number of replicas (default: 1)
-
Name of ConfigMap to use as content for the file "/usr/share/nginx/html/index.html" (optional)
-
Name of Secret to set TLS (optional)
-
Then will create a deployment with NGINX image.
-
If ConfigMap or Secret don't exist, update status field with failure message.
-
If CRD changes, reconcile.
-
If ConfigMap changes, ignore.
-
If Secret changes, reconcile.
# Clone and setup
git clone <repository>
cd mynginx-controller
make install-tools
# Run tests
make test
# Run locally
make runmake- Generate code and buildmake test- Run testsmake deploy- Deploy to clustermake undeploy- Remove from cluster
See CONTRIBUTING.md for detailed development guidelines.
MyNginx CRD → Controller → Nginx Deployment
↓ ↓ ↓
ConfigMap ────────┴─────────→ Volume Mount
↓ ↓ ↓
Secret ───────────┴─────────→ TLS Config
Current: Basic controller with replica management
Next: ConfigMap and Secret integration, status reporting
Refactor finalizer and ensureDeployment.
Controller creates, updates and deletes deployment based on CRD mynginx.