Delete a manifest from Kustomize base - Kubernetes

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

  - ../base


- |-
  apiVersion: v1
  kind: Namespace
    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.

Powered by Blogger.

Hello, my name is Ahmed AbouZaid and this is my "lite" technical blog!

I'm a passionate DevOps engineer, Cloud/Kubernetes specialist, Free/Open source geek, and an author.

I believe in self CI/CD (Continuous Improvements/Development), also that "the whole is greater than the sum of its parts".

DevOps transformation, automation, data, and metrics are my preferred areas. And I like to help both businesses and people to grow.

Latest Post

🔀Merger🔀, a schemaless strategic merge plugin - Kustomize

Kustomize is a great tool. I've been using Kustomize for almost 4 years and am happy with it. However, it's ...

Popular Posts