How dopplerhq/kubernetes-operator works
Project Type and Purpose
• This is a Kubernetes Operator (a controller built with the Operator SDK in Go).
• Its purpose is to watch custom resources of kind DopplerSecret, fetch secrets from the external Doppler API, and sync those secrets into native Kubernetes Secret objects. It also optionally patches Deployments to trigger rolling updates when secrets change.
File Structure
Top-level directories and files:
• api/v1alpha1: CRD Go types (DopplerSecret) and code generation output.
• controllers: Reconciler logic for DopplerSecret resources.
• config:
– crd/bases: YAML for CRD installation.
– manager: Manager Deployment manifest and patches.
– rbac: ServiceAccount & Roles/RoleBindings for the operator.
– samples: Example DopplerSecret and Deployment specs.
– prometheus/scorecard: Monitoring and testing configs.
• hack/helm: Helm chart assets.
• main.go: Operator entrypoint.
• pkg: Shared libraries—Doppler API client, secret-processing logic, version info.
• tools: Utility scripts (log tailing, secret dumps).
• Dockerfile, Makefile, GitHub workflows: CI/CD, container build, release pipeline.
README for Architecture Clues
• Operator runs as a Deployment in the doppler-operator-system namespace.
• Installs a CRD DopplerSecret.
• Watches both the DopplerSecret custom resource and referenced native Secrets & Deployments.
• Fetches secrets from an external Doppler REST API.
• Updates/creates a managed Kubernetes Secret, and if enabled, patches a Deployment annotation to trigger pod restarts.
Main Components
– API Server & etcd (control plane)
– Operator Deployment (one or more Pods)
– CustomResourceDefinition (DopplerSecret)
– Native Kubernetes Secrets (Doppler Token Secret + Managed Secret)
– Target Deployments (annotated for auto-reload)
b. External Doppler API
Relationships and Data Flows
1. Operator Pod registers with APIServer using RBAC.
2. APIServer serves DopplerSecret CRDs and watches Events on Secrets and Deployments.
3. Reconciler loop:
• On DopplerSecret creation/update → read tokenSecret from native Secret
• Call External Doppler API → fetch secrets payload
• Write/patch Managed Secret in Kubernetes
• If secrets.doppler.com/reload: "true", patch the target Deployment annotation
4. Kubernetes Deployment Controller sees annotation change → rolling update of Pods.
Architectural Patterns & Design Principles
• Controller-pattern (Reconciler loop)
• Custom Resource Definition to extend Kubernetes API
• Separation of concerns:
– api/ folder holds only type definitions
– controllers/ folder holds reconciliation logic
– pkg/ holds shared utility code (Doppler client, name transformers, processors)
• Configuration as code via kustomize (config/*) and Helm (hack/helm)
• Declarative GitOps–style deployment via kubectl or Helm chart
Technologies, Frameworks, Libraries
• Go + Operator SDK
• client-go / controller-runtime
• Kustomize (config/*.yaml)
• Helm (hack/helm)
• GitHub Actions & DockerHub for CI/CD
• Prometheus Operator (scorecard tests)