31.7 Using Kustomize with kubectl apply -k
Right, so you’ve got your kustomization.yaml file looking sharp, and you’re ready to deploy. You could run kustomize build ./your-dir/ | kubectl apply -f -, piping the rendered YAML to kubectl. It works, but it feels a bit like using a Rube Goldberg machine to butter your toast. There’s a better way, and it’s built right into kubectl itself: kubectl apply -k. This flag is kubectl’s native hook into Kustomize. When you run apply -k, kubectl calls the Kustomize library internally to build the configuration from the specified directory and then immediately applies it. It’s a single, clean, atomic command for your deployment workflow. The -k flag is your signal that you’re not just applying a file, you’re applying a customization.