hanzo-operator

Hanzo Operator is a unified Kubernetes operator that manages all Hanzo production infrastructure declaratively via 7 CRDs under the hanzo.ai/v1alpha1 API group.

Hanzo Operator - Kubernetes Operator for Hanzo Infrastructure

Category: Hanzo Ecosystem Related Skills: hanzo/hanzo-charts.md, hanzo/hanzo-universe.md, hanzo/hanzo-platform.md

Overview

Hanzo Operator is a unified Kubernetes operator that manages all Hanzo production infrastructure declaratively via 7 CRDs under the hanzo.ai/v1alpha1 API group. Built with Kubebuilder v4 and controller-runtime, it reconciles high-level Hanzo resource specs into the full set of underlying K8s objects (Deployments, StatefulSets, Services, Ingress, HPA, PDB, NetworkPolicy, CronJobs, KMSSecret CRs).

Why Hanzo Operator?

Tech Stack

When to use

Hard requirements

  1. Kubernetes v1.11.3+ cluster with CRD support
  2. cert-manager for TLS (used by HanzoIngress)
  3. KMS operator (kms.hanzo.ai) for KMSSecret reconciliation
  4. RBAC permissions: core, apps, autoscaling, batch, networking, policy, hanzo.ai/, kms.hanzo.ai/

Quick reference

| Item | Value | |------|-------| | Language | Go 1.26 | | Framework | Kubebuilder v4, controller-runtime v0.23.1 | | API Group | hanzo.ai/v1alpha1 | | CRD Count | 7 | | Image | ghcr.io/hanzoai/operator:latest | | Namespace | hanzo-operator-system | | Repo | github.com/hanzoai/operator | | Branch | main | | License | Apache 2.0 |

CRD Reference

| CRD | Short Name | Creates | |-----|------------|---------| | HanzoService | hsvc | Deployment, Service, Ingress, HPA, PDB, NetworkPolicy, KMSSecret | | HanzoDatastore | hds | StatefulSet, headless Service, PVC, CronJob (backup), KMSSecret | | HanzoGateway | hgw | Deployment, Service, ConfigMap (KrakenD config), Ingress | | HanzoMPC | hmpc | StatefulSet, headless Service, Dashboard Deployment, Cache Deployment, Ingress | | HanzoNetwork | hnet | StatefulSet (validators), Deployments (bootnode/indexer/explorer/bridge), Services, ConfigMaps | | HanzoIngress | hing | Multiple Ingress resources with cert-manager TLS | | HanzoPlatform | hplat | Child CRDs (composes all of the above) |

Repository Structure

api/v1alpha1/
 common_types.go # Shared types (ContainerSpec, IngressSpec, etc.)
 hanzoservice_types.go # HanzoService CRD spec
 hanzodatastore_types.go # HanzoDatastore CRD spec
 hanzogateway_types.go # HanzoGateway CRD spec
 hanzompc_types.go # HanzoMPC CRD spec
 hanzonetwork_types.go # HanzoNetwork CRD spec
 hanzoingress_types.go # HanzoIngress CRD spec
 hanzoplatform_types.go # HanzoPlatform CRD spec
 types.go # Additional shared types
 zz_generated.deepcopy.go # Generated DeepCopy methods
cmd/
 main.go # Manager entry point
internal/
 controller/
 hanzoservice_controller.go # HanzoService reconciler
 hanzodatastore_controller.go # HanzoDatastore reconciler
 hanzogateway_controller.go # HanzoGateway reconciler
 hanzompc_controller.go # HanzoMPC reconciler
 hanzonetwork_controller.go # HanzoNetwork reconciler
 hanzoingress_controller.go # HanzoIngress reconciler
 hanzoplatform_controller.go # HanzoPlatform reconciler
 predicates.go # Event filters (createOrUpdatePred, etc.)
 helpers.go # Shared controller utilities
 manifests/ # K8s object builders (builder, labels, mutate)
 status/ # Condition management
 metrics/ # Prometheus metrics
 config/ # Feature gates
config/
 crd/bases/ # Generated CRD YAML (13k lines)
 rbac/ # ClusterRole, bindings
 manager/ # Deployment template
 samples/ # Sample CRs for all 7 CRDs
Dockerfile # Multi-stage Go build (Alpine)
Makefile # Build, test, deploy targets

Build and Deploy

# Regenerate CRDs and DeepCopy
make manifests generate

# Build local binary
make build

# Run tests
make test

# Build Docker image
make docker-build IMG=ghcr.io/hanzoai/operator:latest

# Build and push (multi-platform)
docker buildx build --platform linux/amd64 --push -t ghcr.io/hanzoai/operator:latest .

# Install CRDs into cluster
make install

# Deploy operator
make deploy IMG=ghcr.io/hanzoai/operator:latest

# Apply sample CRs
kubectl apply -k config/samples/

Production Deployment

Universe manifests at ~/work/hanzo/universe/infra/k8s/hanzo-operator/:

kubectl apply -k universe/infra/k8s/hanzo-operator/

Key Patterns

Troubleshooting

| Issue | Cause | Solution | |-------|-------|----------| | RBAC errors on deploy | Missing cluster-admin | Grant cluster-admin or use make deploy | | CRD not found | CRDs not installed | make install first | | KMSSecret not syncing | KMS operator not running | Deploy KMS operator to cluster | | Reconcile loop | Spec drift | Check object mutate functions in manifests/ | | Image pull errors | GHCR auth | Ensure imagePullSecrets configured |

Related Skills


Last Updated: 2026-03-13 Category: Hanzo Ecosystem Related: kubernetes, operator, crds, kubebuilder, infrastructure, go Prerequisites: Kubernetes, Go, Kubebuilder concepts