Kustomize is a template-free declarative management tool for Kubernetes resources. One of the important primitives of Kustomize is patchesStrategicMerge. It allows you to customize the base manifests according to your needs.
For example, if you have multi env (e.g. dev, stage, and prod), it could be used to set different values for each env. It's also useful to customize off-the-shelf Helm charts.
One of the use cases is when you need to delete a manifest, not just patch (manipulate) it. Hence, Kustomize via Strategic Merge Patch provides some patch options like replace, merge, and delete.
Here are interested in the delete option. Let's assume you have a base, and in of the overlays you want to don't apply a certain manifest for one reason or another; you can do that as following
apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - ../base [...] patchesStrategicMerge: - |- apiVersion: v1 kind: Namespace metadata: name: unwanted-namespace $patch: delete
That's it, the namespace that's called unwanted-namespace will not be applied when this Kustomization file is applied.