Failed to find target with or without namespaces being specified [Kustomization]

Asking for help? Comment out what you need so we can get more information to help you!

Cluster information:

Kubernetes version: v1.28.3
Cloud being used: (put bare-metal if not on a public cloud)
Installation method: minikube
Host OS: Ubuntu 20.04
CNI and version:
CRI and version:
Kustomize version: v5.3.0

Hi

I have the following kustomize directory structure for kubernetes manifests.

.
├── base
│   ├── deployment.yaml
│   ├── kustomization.yaml
│   └── service.yaml
└── overlays
    └── environments
        └── prod
            ├── custom-env.yaml
            ├── database-secret.yaml
            ├── ingress.yaml
            ├── kustomization.yaml
            └── replica-and-rollout-strategy.yaml

base/deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: sl-demo-app
spec:
  selector:
    matchLabels:
      app: sl-demo-app
  template:
    metadata:
      labels:
        app: sl-demo-app
    spec:
      containers:
      - name: app
        image: foo/bar:latest
        ports:
        - name: http
          containerPort: 8080
          protocol: TCP

base/kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - service.yaml
  - deployment.yaml

overlays/environments/prod/kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: prod
namePrefix: prod-

secretGenerator:
- literals:
  - db-password=12345
  name: sl-demo-app
  type: Opaque

images:
- name: foo/bar
  newName: foo/bar
  newTag: 3.4.5
labels:
- includeSelectors: true
  pairs:
    app: my-app
    env: prod
patches:
- path: custom-env.yaml
- path: replica-and-rollout-strategy.yaml
- path: database-secret.yaml
resources:
- ../../../base

The kustomization build results in the following error:

Error: no resource matches strategic merge patch "Deployment.v1.apps/sl-demo-app.prod": no matches for Id Deployment.v1.apps/sl-demo-app.prod; failed to find unique target for patch Deployment.v1.apps/sl-demo-app.prod

How to resolve the problem ?