kubernetes-sigs / kustomize

Customization of kubernetes YAML configurations
Apache License 2.0
10.7k stars 2.22k forks source link

Kustomize: apply patch results in error "add operation does not apply: doc is missing path" #5695

Open edtshuma opened 1 month ago

edtshuma commented 1 month ago

I am trying to do a kustomize patch to an existing Helm deployment via a CI/CD pipeline. The CI pipeline is failing kustomize checks with error:

`error: accumulating components: accumulateDirectory: "recursed accumulation of path '/runner/_work/ops-infra/ops-infra/current/components/mimir-prod/alertmanager/ops': add operation does not apply: doc is missing path: \"/spec/values/alertmanager/fallbackConfig/receivers/-\": missing value``

The patch is defined in receivers-patch.yaml as follows:

`- op: add path: /spec/chart/spec/values/alertmanager/fallbackConfig/receivers/- value: name: 'slack_receiver' slack_configs:

This patch adds a new "receiver" entry to the Mimir AlertManager Helm deployment. The patch is applied in kustomization.yaml file as:

apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
patches:
  - path: receivers-patch.yaml
    target:
      kind: HelmRelease
      name: mimir-prod

The deployment on which the patch is being applied is defined as below:

apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
  name: mimir-prod
  namespace: monitoring
spec:
  ...
  ...
  values:
    alertmanager:
      fallbackConfig: |
        global:
          pagerduty_url: https://events.pagerduty.com/v2/enqueue
          resolve_timeout: 5m
        receivers:
          - name: 'null'
        route:
          group_by: ['alertname']
          group_interval: 5m
          group_wait: 30s
          receiver: 'null'

I have looked at other questions here of similar nature but I cant quite find a match to my issue.

What am I doing wrong?

stormqueen1990 commented 1 month ago

Hi there, @edtshuma!

Could you please add a minimal kustomization.yaml configuration that reproduces the problem you're describing?

I can't quite verify whether this happens in standalone Kustomize without knowing how it's being configured and processed.

/kind support /triage needs-information