How datum-cloud/infra-provider-gcp works
Project Type and Purpose
• This is a Kubernetes Operator (built with Kubebuilder) written in Go that serves as a GCP Infrastructure Provider.
• It watches custom API types (from the workload-operator and network-services-operator), then uses the Google Config Connector to create and manage GCP resources (Compute instances/MIGs, networking, IAM, etc.).
Top-Level File/Directory Analysis
• cmd/main.go: operator’s entrypoint, sets up the controller-runtime Manager.
• internal/controller/…: one reconcile controller per API type (InstanceDiscovery, WorkloadDeployment, WorkloadGateway, NetworkContext, CloudInit, K8sConfigConnector).
• config/: kustomize overlays and CRD/Role/ServiceAccount manifests for deploying the operator & Config Connector CRDs.
• test/e2e/: end-to-end tests using a real or fake cluster.
• hack/, Makefile, Dockerfile: build, lint, test, and containerization scripts.
Key Technologies & Patterns
• Go + controller-runtime (Kubebuilder): manager, schemes, reconcile loops.
• Kubernetes API server as control plane; watches CRs.
• Kustomize for YAML overlays (config/…).
• GCP Config Connector CRDs as “adapter” to GCP APIs.
• End-to-end testing harness (test/e2e).
Main Components
a. Kubernetes Cluster
• API Server / etcd (central control plane)
• Config Connector controllers (managing GCP CRDs)
• Datum GCP Infrastructure Provider Pod (the operator manager + controllers)
• CRDs & Custom Resources:
– Workload CRs (from workload-operator)
– Network CRs (from network-services-operator)
– Config Connector CRDs (ComputeInstance, MIG, Firewall, IAM bindings, etc.)
b. External Systems
• GCP Control Plane (Compute Engine, Networking, IAM, etc.)
• Container registry (for IMG)
c. Developer Workstation / CI
• kubectl, make, docker build/push, GitHub Actions workflows
Component Interactions & Data Flow
1. Developer pushes code → GitHub Actions builds + tests → Docker image → Registry.
2. Operator Pod (using that image) is deployed via Kustomize (Makefile).
3. Operator’s Manager starts Controllers: each watches its target CR type.
4. When a Workload or Network custom resource is created/updated:
• Reconcile loop runs in the appropriate controller.
• Controller uses the Kubernetes client to create/update Config Connector CRs in the cluster.
5. Config Connector controllers see the new CRs → call the GCP REST API → provision or modify GCP resources.
6. Controller reads status from Config Connector CRs, updates status on the original custom resources.
Architectural Patterns & Principles
• Controller Pattern: each resource type has a dedicated reconcile loop.
• Declarative Infrastructure: uses Kubernetes CRs as the source of truth.
• Separation of Concerns:
• Datum controllers only bridge custom API → Config Connector CRs;
• Config Connector controllers handle GCP API specifics.
• Config-as-Code: all deployment manifests are managed via Kustomize.
Essential Elements Checklist
• Components: API Server, etcd, Datum Operator Pod (Manager & Controllers), Config Connector controllers, GCP.
• Labels: each controller, each CRD group, external systems.
• Deployment artifacts: mention Kustomize overlay, Docker image.