The Simplest Way to Make Consul Connect and Kustomize Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Using consul connect and kustomize together lets teams manage service mesh rules across clusters. Kustomize patches deployment manifests, while Consul Connect secures traffic between apps with mutual TLS. This pairing removes the need to copy YAML files for each stage. Teams write one base manifest and apply small patches for dev, staging, or production. The service mesh then reads those patched manifests to set up sidecars and check app identities. How consul connect and kustomize handle ide

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.

Using consul connect and kustomize together lets teams manage service mesh rules across clusters. Kustomize patches deployment manifests, while Consul Connect secures traffic between apps with mutual TLS.

This pairing removes the need to copy YAML files for each stage. Teams write one base manifest and apply small patches for dev, staging, or production. The service mesh then reads those patched manifests to set up sidecars and check app identities.

How consul connect and kustomize handle identity and traffic

Each tool owns a clear job in your deployment flow. Kustomize runs during the build step before pods start on the cluster. It merges base YAML files with stage overlays to add labels and pod annotations.

Consul Connect takes over once those manifests hit the Kubernetes API. The mesh admission controller reads the pod annotations that Kustomize added. It then injects a sidecar container into each pod during startup.

Every app pod gets a service account from Kubernetes. Consul checks this service account token when the sidecar starts up. It issues a short TLS certificate tied to that specific service identity.

When one app talks to another, the sidecars check these certificates. Consul intentions act as allow or deny rules between services. You can store these intention definitions as custom resources inside your Kustomize folders. This keeps network rules and app manifests in the same version control repo.

Common failure modes and how to scope roles

Many teams fail by sharing one service account across several apps. If five apps use the same account, the mesh treats them as one service. Any compromised pod can then talk to every database or backend in that group.

Fix this by creating a unique service account in your Kustomize base. Let each overlay change the account name to match the stage and app. This gives every workload a distinct identity inside the mesh.

Broad mesh intentions cause another big risk in production clusters. Teams often write wildcard rules in dev to make testing fast. When they copy manifests by hand, those wide rules slip into production.

End-to-End Encryption + Consul Service Mesh: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Use Kustomize overlays to keep wildcard rules only in local dev folders. Set the base folder to deny all traffic by default. Then add explicit allow rules in your staging and production overlays.

Annotation drift also breaks sidecar injection across different teams. One missing annotation stops the sidecar from starting, leaving traffic open or broken. Put common mesh annotations into a shared Kustomize component. Every team can pull that component without editing raw pod specs.

Finally, watch out for unlogged human queries to mesh services. Engineers often port-forward straight into a pod to run quick checks. This bypasses mesh rules and leaves no record of who ran which query.

Keeping base manifests and stage overlays clean

A clean repo splits app definitions from stage settings. Keep your core deployment, service, and service account in the base folder. Do not put stage names, replica counts, or port numbers in the base.

Use overlays to set resource limits for the sidecar containers. Dev clusters need tiny CPU and memory limits to save money. Production overlays should raise those limits so heavy traffic does not drop packets.

You should also track mesh custom resources alongside your app code. When an app needs to call a payment service, add the intention in Git. Reviewers can check both the code change and the network rule in one pull request. This stops teams from making manual clicks in a dashboard that nobody tracks.

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

Should mesh annotations live in the Kustomize base or overlays?

Put core sidecar injection annotations in the base so every stage runs the mesh. Use overlays only to change stage settings like sidecar CPU limits or upstream service names.

How do we stop dev intentions from reaching production?

Set a default deny rule in your base folder. Place permissive testing rules only inside the dev overlay folder so production builds ignore them.

Why do pods fail to talk after Kustomize applies changes?

Check that the service account name matches the deployment name after Kustomize adds name prefixes. A mismatch stops the mesh from issuing a valid TLS certificate to the pod.

The query runs. The emails stay hidden.