Kustomize#

Omitting a resource#

When the source of resources is not under direct control it may be required to omit specific resources, e.g. a PersistentVolumeClaim from a Helm chart.

Using a strategic merge patch#

patches:
  - target:
      annotationSelector: "config.fluxcd.io/remove-review-overlay=true"
    patch: |
      $patch: delete
      kind: Kustomization
      metadata:
        name: DOES NOT MATTER
  - patch: |
      $patch: delete
      apiVersion: v1
      kind: Namespace
      metadata:
        name: some-namespace

Using an annotation#

Adding the following annotation does lead to Kustomize ignoring this resource:

config.kubernetes.io/local-config: "true"

Details are in the related Kubernetes documentation at https://kubernetes.io/docs/reference/labels-annotations-taints/#config-kubernetes-io-local-config.

Local execution#

Some Kustomizations refer to resources outside of their base, which lead to an error “is not in or below” when evaluating this locally.

The --load-restrictor parameter is needed to allow this:

kubectl kustomize --load-restrictor=LoadRestrictionsNone

See also

Related GitHub issue: kubernetes-sigs/kustomize#1593

Pointers#