0

Say I have kustomize directory like this:

|_base
  |_ deployment.yaml
  |_ kustomisation.yaml
|_patches
  |_dev
    |_ patch.yaml
  |_prod
    |_ patch.yaml

In base/deployment.yaml there exists a CRD object i.e

apiVersion: some.provider.crd
kind: CustomResource
metadata:
  name: customresource
spec:
  preserveDataOnDelete: false

In my dev patch I would like to first patch CustomResource.spec.preserveDataOnDelete to true and then once that's been patched, delete the object.

apiVersion: some.provider.crd
kind: CustomResource
metadata:
  name: customresource
spec:
  preserveDataOnDelete: false
---
$patch: delete
apiVersion: some.provider.crd
kind: CustomResource
metadata:
  name: customresource

I know I can't rely on kustomize to apply both steps serially and atomically since it's just a yaml generator. I'm curious if there any other tools at my disposal I could use to do both steps in one swoop, mostly so I can do everything in one PR instead of splitting it up.

user3805884
  • 125
  • 2
  • 8
  • You mean, patch the CRD and then delete the objects that have the spec on false? – Hackerman Jul 11 '23 at 21:36
  • I guess it depends on how you apply manifests. Are you using GitOps? Do you run kubectl manually? Anyway that's indeed not Kustomize scope to do this. – Gaël J Jul 12 '23 at 18:50

0 Answers0