05/05/2021

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

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.

Powered by Blogger.

Hello, my name is Ahmed AbouZaid, I'm a passionate Tech Lead DevOps Engineer. 👋

With 16+ years of open-source contributions, 12+ years of professional hands-on experience in DevOps, and an M.Sc. in Data Engineering from Edinburgh Napier University (UK), I enjoy facilitating the growth of both businesses and individuals.

I specialize in Cloud-Native and Kubernetes. I'm also a Free/Open source geek and book author. My favorite topics are DevOps transformation, automation, data, and metrics.

Contact Me

Name

Email *

Message *

Start Your DevOps Engineer Journey!

Start Your DevOps Engineer Journey!
Start your DevOps career for free the Agile way in 2024 with the Dynamic DevOps Roadmap ⭐

Latest Post

2023 Highlights

Image generated with Craiyon . Finally, 2023 is over! What a year! One more crazy year, but it was the culmination ...

Popular Posts

Blog Archive