The Simplest Way to Make Kustomize and Prefect Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use kustomize and prefect together to deploy workflow workers across different Kubernetes clusters. Kustomize patches cluster manifests while Prefect schedules and runs your data jobs on those pods. This pairing lets engineers keep one base set of deployment files for every cluster. Each stage gets its own CPU limits, namespace rules, and worker queue names without copying files. How keys, roles, and data flow between kustomize and prefect Prefect splits its work between a central serv

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Teams use kustomize and prefect together to deploy workflow workers across different Kubernetes clusters. Kustomize patches cluster manifests while Prefect schedules and runs your data jobs on those pods.

This pairing lets engineers keep one base set of deployment files for every cluster. Each stage gets its own CPU limits, namespace rules, and worker queue names without copying files.

How keys, roles, and data flow between kustomize and prefect

Prefect splits its work between a central server and remote worker pods in your cluster. The central server holds the schedule and sends run alerts to the worker queues. Kustomize builds the Kubernetes manifests that start those worker pods in each cluster space. Your build pipeline runs Kustomize first and sends the final manifests to the cluster API.

Once the worker pod starts, it needs a key to log in to Prefect. Kustomize links a cluster secret to the pod so the worker can read that key. After the worker logs in, it polls the work pool for new tasks to run. When a task starts, the worker creates a new job pod using its local role.

Data flows inside the cluster while status logs go back to the central server. The job pod reads from your data stores and writes results to storage buckets. Kustomize sets the service account name on both the worker pod and the job pod. This service account controls what cluster items the worker can create, read, or delete.

Common failure modes and how to scope roles and network paths

Many teams make the mistake of sharing one service account across all cluster spaces. A test worker with a broad token can then touch production secrets by mistake. Another common failure happens when teams put plain API keys inside their Kustomize patch files. Anyone who reads the source repo can steal that key and trigger false runs.

Unlogged database queries also create big risks when job pods run with shared database passwords. If a job breaks or leaks data, you cannot tell which run caused the mess. You should give each stage its own service account and its own worker key. Kustomize overlays make it easy to swap the role name for test and prod.

End-to-End Encryption + Kustomize Security Overlays: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Your cluster role should only let the worker pod manage jobs in its own namespace. Never grant cluster-wide admin rights to a worker just to fix a permission error. You should also lock down network paths with Kubernetes network rules in your base files. Allow the worker pod to talk only to the Prefect server and required data stores. Block all pod-to-pod traffic between your test space and your production databases.

How to keep overlays clean across test and prod stages

Start with a clean base folder that holds your shared worker deployment and role files. Put only the parts that change inside your stage overlays, like replica counts and names. Keep your resource limits in the overlays so test pods stay small and cheap. Production overlays can request more memory and faster nodes for heavy data runs.

Store your raw API keys in an external secret store instead of your code repo. Have your secret store write the secret straight into the cluster before Kustomize runs. Then your overlay only needs to point to the secret name in that namespace. Review your merged output in your build pipeline before you push changes to the cluster. This check catches bad role bindings and missing secret names before a worker pod crashes.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Should I store Prefect API keys inside Kustomize files?

No, you should never put raw API keys in code repos or patch files. Load keys from a secret manager into the cluster and reference the secret name instead.

How do I match Kustomize overlays to Prefect work pools?

Create one overlay folder for each stage and set the work pool name there. Pass that name to the worker pod as an environment variable during the build step.

Why do my Prefect job pods fail to start in Kubernetes?

Job pods often fail when the worker service account lacks rights to create jobs. Check your Kustomize role binding to make sure it covers the target namespace.

The query runs. The emails stay hidden.