|
| 1 | +# Ironic Standalone Operator - AI Coding Assistant Instructions |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +Kubernetes operator for deploying and managing standalone Ironic |
| 6 | +services. Provides declarative management of Ironic deployments via |
| 7 | +custom resources, handling configuration, scaling, and lifecycle |
| 8 | +management of Ironic components. |
| 9 | + |
| 10 | +## Architecture |
| 11 | + |
| 12 | +### Custom Resources (CRDs) |
| 13 | + |
| 14 | +Located in `api/v1alpha1/`: |
| 15 | + |
| 16 | +- `Ironic` - Main resource defining an Ironic deployment |
| 17 | + - Configures Ironic API, Conductor, database |
| 18 | + - Manages dnsmasq, httpd, and related services |
| 19 | + - Handles secrets, ConfigMaps, and networking |
| 20 | + |
| 21 | +### Controllers |
| 22 | + |
| 23 | +Located in `internal/controller/`: |
| 24 | + |
| 25 | +- `IronicReconciler` - Manages Ironic deployment lifecycle |
| 26 | + - Creates/updates Deployments, Services, ConfigMaps |
| 27 | + - Handles Ironic configuration rendering |
| 28 | + - Manages database initialization |
| 29 | + - Orchestrates multi-container pods |
| 30 | + |
| 31 | +## Key Features |
| 32 | + |
| 33 | +- **Declarative Configuration** - Define Ironic via CRD instead of manual manifests |
| 34 | +- **Configuration Management** - Auto-generates Ironic configs from spec |
| 35 | +- **Secret Management** - Handles BMC credentials, database passwords |
| 36 | +- **Database Support** - SQLite or MariaDB backends |
| 37 | +- **Networking** - Configures provisioning and external networks |
| 38 | +- **Upgrades** - Manages Ironic version upgrades |
| 39 | + |
| 40 | +## Development Workflows |
| 41 | + |
| 42 | +```bash |
| 43 | +# Generate manifests after API changes |
| 44 | +make manifests |
| 45 | + |
| 46 | +# Run unit tests |
| 47 | +make test |
| 48 | + |
| 49 | +# Run linters |
| 50 | +make lint |
| 51 | + |
| 52 | +# Build manager binary |
| 53 | +make build-manager |
| 54 | + |
| 55 | +# Build container image |
| 56 | +make docker-build IMG=quay.io/metal3-io/ironic-standalone-operator:dev |
| 57 | + |
| 58 | +# Run locally (against cluster) |
| 59 | +make run |
| 60 | + |
| 61 | +# Deploy to cluster |
| 62 | +make deploy |
| 63 | + |
| 64 | +# Run local Ironic using operator's tooling |
| 65 | +make build-run-local-ironic |
| 66 | +./bin/run-local-ironic |
| 67 | +``` |
| 68 | + |
| 69 | +**Ironic Resource Spec:** |
| 70 | + |
| 71 | +```yaml |
| 72 | +apiVersion: ironic.metal3.io/v1alpha1 |
| 73 | +``` |
| 74 | +
|
| 75 | +## Code Patterns |
| 76 | +
|
| 77 | +**Ironic Resource Spec:** |
| 78 | +
|
| 79 | +```yaml |
| 80 | +apiVersion: ironic.metal3.io/v1alpha1 |
| 81 | +kind: Ironic |
| 82 | +metadata: |
| 83 | + name: ironic |
| 84 | + namespace: metal3 |
| 85 | +spec: |
| 86 | + databaseRef: |
| 87 | + name: mariadb-connection |
| 88 | + networking: |
| 89 | + interface: ens3 |
| 90 | + dhcpRange: 172.22.0.10,172.22.0.100 |
| 91 | + images: |
| 92 | + ipa: |
| 93 | + kernel: http://example.com/ipa.kernel |
| 94 | + initramfs: http://example.com/ipa.initramfs |
| 95 | +``` |
| 96 | +
|
| 97 | +**Controller Pattern:** |
| 98 | +
|
| 99 | +- Reconcile creates/updates all Ironic components |
| 100 | +- Status reflects deployment state (Ready, Degraded, etc.) |
| 101 | +- Handles finalizers for cleanup |
| 102 | +- Uses owner references for garbage collection |
| 103 | +
|
| 104 | +## Integration Points |
| 105 | +
|
| 106 | +### With BMO |
| 107 | +
|
| 108 | +- Alternative to BMO's built-in Ironic deployment |
| 109 | +- BMO can use Ironic deployed by this operator |
| 110 | +- More declarative than manual manifests |
| 111 | +
|
| 112 | +### Standalone Use |
| 113 | +
|
| 114 | +- Can deploy Ironic without BMO |
| 115 | +- Useful for non-CAPI use cases |
| 116 | +- Simplified Ironic management |
| 117 | +
|
| 118 | +## Key Files |
| 119 | +
|
| 120 | +- `main.go` - Operator entrypoint |
| 121 | +- `api/v1alpha1/ironic_types.go` - Ironic CRD definition |
| 122 | +- `internal/controller/ironic_controller.go` - Main reconciliation logic |
| 123 | +- `config/` - Deployment manifests and CRDs |
| 124 | +- `tools/run_local_ironic.sh` - Standalone Ironic runner |
| 125 | + |
| 126 | +## Common Pitfalls |
| 127 | + |
| 128 | +1. **Resource Dependencies** - Ironic needs ConfigMaps, Secrets before |
| 129 | + starting |
| 130 | +2. **Network Configuration** - Interface names vary by environment |
| 131 | +3. **Database Initialization** - MariaDB must be ready before Ironic |
| 132 | + starts |
| 133 | +4. **Image Availability** - IPA images must be accessible from Ironic |
| 134 | +5. **Port Conflicts** - Ensure no port conflicts with existing services |
| 135 | + |
| 136 | +## Deployment Example |
| 137 | + |
| 138 | +```bash |
| 139 | +# Install CRDs |
| 140 | +make install |
| 141 | +
|
| 142 | +# Deploy operator |
| 143 | +make deploy |
| 144 | +
|
| 145 | +# Create Ironic instance |
| 146 | +kubectl apply -f config/samples/ironic_v1alpha1_ironic.yaml |
| 147 | +
|
| 148 | +# Check status |
| 149 | +kubectl get ironic -n metal3 |
| 150 | +kubectl describe ironic ironic -n metal3 |
| 151 | +``` |
| 152 | + |
| 153 | +## Status |
| 154 | + |
| 155 | +This operator provides a more Kubernetes-native way to manage Ironic |
| 156 | +compared to manual manifests. It's in active development and may be the |
| 157 | +preferred deployment method in future Metal3 releases. |
| 158 | + |
| 159 | +## Version Compatibility |
| 160 | + |
| 161 | +- Compatible with Ironic 2023.1 (Antelope) and newer |
| 162 | +- Requires Kubernetes 1.25+ |
| 163 | +- Works with BMO v0.5.0+ |
0 commit comments