The Simplest Way to Make Kustomize and Longhorn Work Like They Should
You use Kustomize and Longhorn together to manage block storage across Kubernetes clusters. Kustomize patches your storage manifests, while Longhorn builds and runs the disk volumes. This workflow lets platform teams keep one base storage layout in version control. Then teams apply small overlays for dev, staging, and production clusters. You do not need to duplicate YAML files or edit live cluster settings by hand. Every disk rule stays in Git so your team can review changes before deployment.
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.
You use Kustomize and Longhorn together to manage block storage across Kubernetes clusters. Kustomize patches your storage manifests, while Longhorn builds and runs the disk volumes.
This workflow lets platform teams keep one base storage layout in version control. Then teams apply small overlays for dev, staging, and production clusters. You do not need to duplicate YAML files or edit live cluster settings by hand. Every disk rule stays in Git so your team can review changes before deployment.
How Kustomize and Longhorn handle permissions and data flow
Kustomize reads your base YAML files and applies environment patches during the build step. It outputs plain Kubernetes manifests that define storage classes, volume claims, and backup rules. Kustomize does not run inside the cluster or hold any active storage keys. Instead, your deployment tool sends the rendered manifests to the Kubernetes API server.
Longhorn runs inside the cluster as a set of controllers and node engines. It watches the API server for new storage classes and persistent volume claims. When a manifest arrives, Longhorn provisions block storage across the local disks on your nodes. It also uses Kubernetes secrets to log in to external backup stores.
Because Kustomize outputs plain text, you must never put raw backup keys in overlays. Teams use external secret tools to load keys into the cluster at runtime. Your Kustomize files only hold the secret name so Longhorn knows which key to read.
Common failure modes and how to scope roles
Many teams fail by using one broad service account to apply every Kustomize overlay. If that token leaks, an attacker can delete storage classes or wipe volume replicas. Another common mistake is letting every app namespace read the backup secret in the storage namespace. Unlogged edits to live storage classes also cause drift between Git and the cluster.
You can fix these risks by scoping Kubernetes roles for both build and runtime steps. Give your deployment tool a role that only writes storage classes during stack runs. App teams should only have permission to create volume claims inside their own namespaces. They should never have rights to edit the Longhorn system namespace or its secrets.
End-to-End Encryption + Kustomize Security Overlays: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
You should also lock down network paths between app pods and the storage system. Use network policies so only cluster nodes and storage pods talk to each other. Block regular app pods from reaching the Longhorn UI or internal manager endpoints. This setup keeps a compromised app from changing replica counts or deleting snapshots.
Managing environment overlays for stateful workloads
Stateful apps need different storage rules in dev than they do in production. A dev cluster might need one disk replica and no automated remote backups. Production clusters often need three replicas across separate zones and daily backup schedules. Kustomize makes this split clean without changing the app deployment files.
Your base folder holds the app deployment and a standard persistent volume claim. Each environment overlay patches the storage class name or the requested disk size. You can also patch labels on the volume claims to trigger specific backup groups. When you promote an app from staging to production, the base claim stays the same. The production overlay simply points that claim to a safer storage class.
Always test your rendered manifests in a staging cluster before updating production storage rules. Kubernetes does not let you edit most fields on an existing volume claim. If Kustomize changes an immutable field, the deployment step will fail right away. Catching this in staging saves your team from broken rollouts during production maintenance windows.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Should I deploy the Longhorn system itself with Kustomize?
Yes, you can wrap the upstream deployment manifests or Helm output inside a Kustomize base. This lets you patch node selectors, resource limits, and default settings per cluster.
How do I keep backup keys out of my Kustomize Git repo?
Store only the secret reference name in your Kustomize patches and storage class files. Create the actual Kubernetes secret in the cluster using a secret manager or encrypted controller.
Can Kustomize resize an existing Longhorn volume without downtime?
If your storage class allows volume expansion, you can patch the size in your overlay. Longhorn will grow the volume, though some file systems require a quick pod restart.
Short role checks help teams work fast. Simple rules make each review clear. Good logs keep every team safe. Scoped keys stop bad changes early.
Related guides
In this post