Kustomize: Provide for omission of resources.

Created on 13 Jun 2018  路  11Comments  路  Source: kubernetes-sigs/kustomize

I'm new to kustomize, so let me know if this even makes sense.

Use case: I'm transforming an all-in-one YAML (--- delimited). This works well, except I want to skip one of the resources in the upstream YAML stream.

Something like this:

omissionPatches:
- svc.some-public-service.yaml

Where svc.some-public-service.yaml contains:

apiVersion: v1
kind: Service
metadata:
  name: some-public-service

In the example scenario, kustomize should not include svc/some-public-service in the output stream.

prioritbacklog

Most helpful comment

I think that providing for omission of resources is necessary to avoid some kind of workaround. (e.g. make many directions)

Does kustomize have a plan to support this?

All 11 comments

Here is my understanding. By omissionPatches, you want kustomize to delete certain resources declared in the base.
This is a good feature to have.

As a workaround, you can remove the declaration for some-public-service from the all-in-one YAML.

I'd also like to you how you get the all-in-one YAML. You can split it and group the resources into different files.
Then create kustomization based on the new files.

That's correct. I'm working around by forking the upstream artifact to my own repo and removing that resource in my fork. I really want the ability to avoid that though. The upstream file can be used directly via git submodule or curl.

Thanks!

@jmdots - i just think this is hard to do in the general case, and want to think carefully and get more experience before we try it.

You're workaround - fork the upstream - is exactly the right thing to do.

Apologies for commenting on a closed issue, please let me know if I should open a new one. I think I ran into what this issue was about by trying something like this:

apiVersion: v1
kind: Service
metadata:
  name: some-public-service
$patch: delete

It works sometimes, but not others, maybe depending on whether the resource is a CRD. Would supporting that be useful? Or maybe it only works sometimes because I'm misunderstanding the patch interaction somehow.

This indeed works, but the resulting yaml bundle is not usable by kubernetes anymore.
This is what the yaml looks like in the bundle now:

{}

applying this to kubernetes results in:
error: error validating "STDIN": error validating data: [apiVersion not set, kind not set]; if you choose to ignore these errors, turn validation off with --validate=false
turning off validation is not a feasible solution. Also i'd like to be able to directly call kustomize without any scripts in between, because i am using argocd for rollout

I think that providing for omission of resources is necessary to avoid some kind of workaround. (e.g. make many directions)

Does kustomize have a plan to support this?

Being able to patch a resource with a top-level $patch: delete would be really useful and sensible way of allowing this.

IMHO, using annotation of omission can be useful.

kind: Deployment
metadata:
     name: ingress-nginx
     annotations:
          kustomize.config.k8s.io/overlay-behavior:  delete

In https://github.com/kubernetes-sigs/kustomize/blob/master/docs/eschewedFeatures.md you can see that kustomize has specifically listed this as something it will not support.

Was this page helpful?
0 / 5 - 0 ratings