kustomize version
Version: {KustomizeVersion:3.0.0 GitCommit:e0bac6ad192f33d993f11206e24f6cda1d04c4ec BuildDate:2019-07-03T18:21:24Z GoOs:linux GoArch:amd64}
Observed that a jsonPatch that works for bundled kustomize 2.0.3 and 2.1.0 fails to build with 3.0.0. The error returned is
Error: no matches for OriginalId extensions_v1beta1_Deployment|~X|external-dns; no matches for CurrentId extensions_v1beta1_Deployment|~X|external-dns; failed to find unique target for patch extensions_v1beta1_Deployment|external-dns
My deployment base contains:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: external-dns
namespace: kube-system
spec:
strategy:
type: Recreate
template:
metadata:
labels:
app: external-dns
annotations:
iam.amazonaws.com/role: changeme
spec:
serviceAccountName: external-dns
containers:
- name: external-dns
image: registry.opensource.zalan.do/teapot/external-dns:latest
args:
- --source=service
- --source=ingress
My overlay kustomization
resources:
- ../base
patchesJson6902:
- target:
group: extensions
version: v1beta1
kind: Deployment
name: external-dns
path: deployment-patch.yaml
My jsonPatch
- op: replace
path: /spec/template/metadata/annotations/iam.amazonaws.com~1role
value: arn:aws:iam::123456:role/ExternalDNS
Try
patchesJson6902:
- target:
group: extensions
version: v1beta1
kind: Deployment
name: external-dns
+ namespace: kube-system
path: deployment-patch.yaml
Thanks so much for this - this does resolve my issue. Adding the namespace to the patch target
I'm getting the same bug trying to follow through the MNIST example in the end-to-end Kubeflow Guide. How would I change that file? Simply adding "namespace: kube-system" didn't do it :(
Oops I figured it out. The correct namespace is kubeflow, as specified in the base - now I'm on to the next bug :)
That's _funny_ because with kustomize v2.1.0, if you specify the namespace on the patch, and the namespace isn't specified in the resource but only in the kustomization.yml (or if you specify a namespace in the resource that is not the same as the one in the kustomization.yml, like a place holder for instance), then you get an error
Error: couldn't find target apps_v1_Deployment|resourceFoo|namespaceBar for json patch
With kustomize v3.0.0 :
Error: no matches for OriginalId apps_v1_Deployment|~X|resourceFoo; no matches for CurrentId apps_v1_Deployment|~X|resourceFoo; failed to find unique target for patch apps_v1_Deployment|resourceFoo
I didn't see anything related to that change in the patch behaviour regarding namespaces in the changelog (but I may have missed it)
kustomize version Version: {KustomizeVersion:3.0.0 GitCommit:e0bac6ad192f33d993f11206e24f6cda1d04c4ec BuildDate:2019-07-03T18:21:24Z GoOs:linux GoArch:amd64}Observed that a jsonPatch that works for bundled kustomize 2.0.3 and 2.1.0 fails to build with 3.0.0. The error returned is
Error: no matches for OriginalId extensions_v1beta1_Deployment|~X|external-dns; no matches for CurrentId extensions_v1beta1_Deployment|~X|external-dns; failed to find unique target for patch extensions_v1beta1_Deployment|external-dnsMy deployment base contains:
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: external-dns namespace: kube-system spec: strategy: type: Recreate template: metadata: labels: app: external-dns annotations: iam.amazonaws.com/role: changeme spec: serviceAccountName: external-dns containers: - name: external-dns image: registry.opensource.zalan.do/teapot/external-dns:latest args: - --source=service - --source=ingressMy overlay kustomization
resources: - ../base patchesJson6902: - target: group: extensions version: v1beta1 kind: Deployment name: external-dns path: deployment-patch.yamlMy jsonPatch
- op: replace path: /spec/template/metadata/annotations/iam.amazonaws.com~1role value: arn:aws:iam::123456:role/ExternalDNS
Sorry my ignorance, I don't know what is the "deployment base" or the "overlay kustomization" or the "jsonPatch". Inside the mnist/training/GCS example folder I have the following:
...examples-master/mnist/training/GCS$ ls
Chief_patch.yaml kustomization.yaml params.yaml Ps_patch.yaml Worker_patch.yaml
After adding namespace: kubeflow (different namespace as defined here) to kustomization.yaml at the patchesJson6902 section and applying the command kustomize build . I got the following error:
Error: var '{batchSize ~G_v1_ConfigMap {data.batchSize}}' cannot be mapped to a field in the set of known resources
Try
patchesJson6902: - target: group: extensions version: v1beta1 kind: Deployment name: external-dns + namespace: kube-system path: deployment-patch.yaml
I don't see the namespace addition anywhere in the documentation.
this is still an issue in:
kustomize version
Version: {Version:kustomize/v3.2.3 GitCommit:f8412aa3d39f32151525aff97a351288f5a7470b BuildDate:2019-10-08T23:30:25Z GoOs:linux GoArch:amd64}
```kustomization.yaml
patchesJson6902:
```patch-deployment.yaml
- op: add
path: '/spec/template/spec/imagePullSecrets/-'
value:
name: docker-regcred
- op: add
path: '/spec/template/spec/volumes/-'
value:
name: appname-volume-client-config-service
configMap:
name: client-config-service-appname-file-cfm
- op: add
path: '/spec/template/spec/containers/0/volumeMounts/-'
value:
name: appname-volume-client-config-service
mountPath: '/opt/appds/appname-config'
Error: failed to apply json patch '[{"op":"add","path":"/spec/template/spec/imagePullSecrets/-","value":{"name":"docker-regcred"}},{"op":"add","path":"/spec/template/spec/volumes/-","value":{"configMap":{"name":"client-config-service-appname-file-cfm"},"name":"appname-volume-client-config-service"}},{"op":"add","path":"/spec/template/spec/containers/0/volumeMounts/-","value":{"mountPath":"/opt/appds/appname-config","name":"appname-volume-client-config-service"}}]': add operation does not apply: doc is missing path: "/spec/template/spec/imagePullSecrets/-": missing value
everywhere we have the /- notation for lists but.. completely breaks. I make the change below.... and its working.... but does not generate a list :(
still broken
- op: add
path: /spec/template/spec/imagePullSecrets/-
- op: add
path: /spec/template/spec/imagePullSecrets
- op: add
path: /spec/template/spec/imagePullSecrets
value:
name: docker-regcred
- op: add
path: /spec/template/spec/volumes
value:
name: appname-volume-client-config-service
configMap:
name: client-config-service-appname-file-cfm
- op: add
path: /spec/template/spec/containers/0/volumeMounts
value:
name: appname-volume-client-config-service
mountPath: '/opt/appds/appname-config'
ok so turns out that
imagePullSecrets: []
volumes: []
...
this .. could be a bit clearer
@rosscdh I've had success adding a imagePullSecrets to all Deployments using Kustomize 3.5.1 using the syntax described here
For reference in case it helps you:
$> cat kustomization.yaml
bases:
- ../../base
patches:
- path: deployment_pull_secret.yaml
target:
kind: Deployment
$> cat deloyment_pull_secret.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: not-important-but-required
spec:
template:
spec:
imagePullSecrets:
- name: my-registry-secret
Why is this issue closed. This is still happening in 3.5
still broken for me as well
/reopen
@Shell32-Natsu: Reopened this issue.
In response to this:
/reopen
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
@pyramation Please create a new issue with your issue information. The behavior in the description of this issue is expected.
/close
@Shell32-Natsu: Closing this issue.
In response to this:
@pyramation Please create a new issue with your issue information. The behavior in the description of this issue is expected.
/close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Most helpful comment
Try