The Simplest Way to Make Kustomize and Lambda Work Like They Should
Teams pair kustomize and lambda to manage Kubernetes manifests that trigger or configure serverless functions. Kustomize patches cluster files per stage while Lambda runs event-driven code outside the cluster. This setup lets one Git repo control both container apps and cloud functions. Platform teams keep base files clean and apply small changes for dev, test, and prod. Each stage gets its own function names, regions, and role rules without copying files. How kustomize and lambda share permi
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 pair kustomize and lambda to manage Kubernetes manifests that trigger or configure serverless functions. Kustomize patches cluster files per stage while Lambda runs event-driven code outside the cluster.
This setup lets one Git repo control both container apps and cloud functions. Platform teams keep base files clean and apply small changes for dev, test, and prod. Each stage gets its own function names, regions, and role rules without copying files.
How kustomize and lambda share permissions and data
Kubernetes pods often need to call serverless functions or manage them through cloud controllers. Kustomize handles the YAML files that define these pods, service accounts, and cloud resources. When a pod runs, it uses a service account to ask for a cloud role.
Kustomize overlays swap out the role ARN and function name for each stage. The dev overlay points pods to test functions with limited rights. The prod overlay updates those values to point to live functions.
Some teams also use Kubernetes operators that manage cloud resources from inside the cluster. In this flow, Kustomize patches custom resource files that define the function settings. The cluster operator reads those patched files and calls the cloud API to update the function.
Data flows between the two systems through event queues, HTTP APIs, or direct SDK calls. Pods send payloads with request data, and the function returns results or writes to storage. Kustomize makes sure each pod gets the right endpoint URLs and environment values at deploy time.
Common failure modes and how to scope roles
A common mistake is sharing one broad cloud role across all cluster stages. If a dev pod uses a prod role, a bug can break live functions. Shared static keys stored in cluster secrets create a major security risk as well.
Static keys do not expire on their own and often leak in build logs. Teams also run into trouble when manifests hardcode function names inside base files. One wrong push can send test events straight into a live database.
Lambda Execution Roles + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
To fix this, bind each Kubernetes service account to one scoped IAM role. Give that role permission to invoke only the specific functions needed for that stage. Use Kustomize patches to inject the right service account annotation for each cluster.
Never store long-lived cloud keys inside Git repos or base secret generators. Instead, rely on short-lived workload identity tokens issued by the cluster identity provider. Scope network paths so only authorized pods can reach the cloud API endpoints.
Keeping audit logs and stage overlays clean
Unlogged calls between cluster workloads and cloud functions make incidents hard to trace. When twenty pods share one role, cloud logs cannot show which pod triggered a bad run. Distinct roles per app and stage make every API call clear in the audit trail.
Keep your Kustomize base files free of account numbers, role strings, and stage URLs. Put all stage-specific values into small patch files inside each overlay folder. Run a check in your build pipeline to verify that overlays set valid role paths.
Teams should also protect sensitive fields when functions return customer data to cluster apps. Data masking rewrites matched fields like emails, phone numbers, card numbers, or national IDs in results. This keeps sensitive values out of app logs during debug work.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
Can Kustomize deploy Lambda functions directly without a cluster operator?
No, Kustomize only builds Kubernetes YAML files and does not talk to cloud APIs. You need a Kubernetes cloud controller or a separate deploy tool to create the actual function.
How should pods authenticate when calling a Lambda function?
Pods should use Kubernetes service account tokens linked to a scoped cloud IAM role. Kustomize overlays set the right role annotation on the service account for each stage.
How do we stop dev workloads from calling production functions?
Create separate IAM roles for dev and prod with strict resource rules on function names. Use Kustomize overlays so dev pods only receive the dev role and dev function URLs.
Related guides
In this post