I just start using kustomize. I have the following yaml files for kustomize:
ls -l ./kustomize/base/
816 Apr 18 21:25 deployment.yaml
110 Apr 18 21:31 kustomization.yaml
310 Apr 18 21:25 service.yaml
where deployment.yaml and service.yaml are generated files with jib and they are fine in running. And the content of the kustomization.yaml is the following:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- service.yaml
- deployment.yaml
And in another directory
ls -l ./kustomize/qa
133 Apr 18 21:33 kustomization.yaml
95 Apr 18 21:37 update-replicas.yaml
where
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../base
patchesStrategicMerge:
- update-replicas.yaml
and
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 2
After running "kustomize build ./kustomize/base", I run
~/kustomize build ./kustomize/qa
Error: no matches for OriginalId ~G_~V_Deployment|~X|my-app; no matches for CurrentId ~G_~V_Deployment|~X|my-app; failed to find unique target for patch ~G_~V_Deployment|my-app
I have a look related files and don't see any typo on the application name.
And here is the deployment.yaml file.
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: my-app
name: my-app
spec:
replicas: 1
selector:
matchLabels:
app: my-app
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: my-app
spec:
containers:
- image: docker.io/[my Docker ID]/my-app
name: my-app
resources: {}
readinessProbe:
httpGet:
port: 8080
path: /actuator/health/readiness
livenessProbe:
httpGet:
port: 8080
path: /actuator/health/liveness
lifecycle:
preStop:
exec:
command: ["sh", "-c", "sleep 10"]
status: {}
Again, the above file is generated with jib with some modifications. And it runs on Kubernetes directly.
How to resolve this problem?
my-app
to be patched. Please post the originaldeployment.yaml
, as it's crucial to check for inconsistencies. – Debilityfailed to find unique target for patch
is a really weak and unhelpful error message. Personally I'd welcome any insights into how to get better diagnostic information from kustomize with a view to solving errors more efficiently. – Comport