kubectl-kustomize
Customize Kubernetes configurations
TLDR
Build resources from the current directory
Build resources from a specific directory
Build resources from a remote URL
Build resources and save to a file
Build resources with load restrictor disabled
SYNOPSIS
kubectl kustomize <directory-or-URL> [<flags>]
PARAMETERS
<directory-or-URL>
The path to a directory containing a kustomization.yaml file, or a URL pointing to a remote kustomization.
-o, --output=<format>
Output format. Options include 'json' and 'yaml'. Defaults to 'yaml'.
--enable-helm[=true]
Enables Kustomize to process Helm charts during resource generation, allowing integration of Helm-managed resources into kustomizations.
--load-restrictor=<LoadRestrictorKind>
Controls how remote files are loaded. Valid values: LoadRestrictionsNone, LoadRestrictionsLocalOne, LoadRestrictionsRootOnly.
--reorder=<ReorderOption>
Reorders the list of generated resources. Valid values: legacy, natural, none.
--helm-command=<path>
Specifies the path to the Helm binary. Defaults to 'helm'.
--enable-alpha-plugins[=false]
Enables support for Kustomize alpha plugins, which extend Kustomize's functionality through custom executables.
--enable-exec[=false]
Enables Kustomize exec functions, allowing command execution within kustomizations for dynamic content generation.
DESCRIPTION
kubectl kustomize is a built-in subcommand of the Kubernetes command-line tool, kubectl, that integrates the functionality of Kustomize directly into the client. Kustomize provides a template-free way to customize application configuration for Kubernetes, leaving the original YAML files untouched. It achieves this by using a declarative approach based on a 'base' configuration and 'overlays' that define modifications for specific environments or use cases.
The primary function of kubectl kustomize is to generate customized Kubernetes YAML manifests. Users specify a directory containing a kustomization.yaml file, which outlines the base resources and all the patches, transformations, and other alterations to be applied. The command processes these instructions and outputs the resulting, ready-to-deploy YAML to standard output. This output is typically piped to other kubectl commands, most commonly kubectl apply -f -, to deploy the customized resources to a Kubernetes cluster.
CAVEATS
kubectl kustomize only generates Kubernetes manifests to standard output; it does not directly apply them to a cluster. Users must typically pipe its output to kubectl apply -f - or a similar command to deploy the resources.
A valid kustomization.yaml file must exist in the specified directory or be accessible via the provided URL. The behavior and supported features of kubectl kustomize are dependent on the version of Kustomize embedded within your kubectl client, which evolves with Kubernetes releases.
KUSTOMIZATION FILE (<I>KUSTOMIZATION.YAML</I>)
This file is the core of any Kustomize project. It's a YAML file that declares the base resources, patches, generators, transformers, and other modifications Kustomize should apply to produce the final set of manifests. It acts as the blueprint for customization.
BASE AND OVERLAYS
Kustomize operates on the principle of having a base set of YAML manifests (the 'base') which defines the core application. For different environments (e.g., development, staging, production), 'overlays' are created. Overlays contain directives to modify the base without altering the original base files, enabling environment-specific configurations to be managed declaratively and cleanly.
OUTPUT TO STANDARD OUTPUT
A key characteristic of kubectl kustomize is that it prints the generated, customized YAML manifests to standard output (stdout). This design allows for flexible integration with other command-line tools, enabling users to pipe the output to commands like kubectl apply -f -, use it for validation, or integrate it into CI/CD pipelines.
HISTORY
Kustomize originated as an independent command-line tool for managing Kubernetes configuration. Its declarative, template-free approach quickly gained significant traction within the Kubernetes community for its flexibility and ease of use in managing environment-specific configurations. Recognizing its utility, Kustomize was officially integrated into kubectl as a subcommand (kubectl kustomize) starting with Kubernetes version 1.14. This integration solidified its status as a de-facto standard for configuration customization within the Kubernetes ecosystem, making it readily available to all kubectl users without requiring a separate installation.
SEE ALSO
kubectl(1), kubectl-apply(1), kustomize(1)


