This was working file with v3.0.0, I've updated to v3.0.3 and I'm getting the error:
Error: json: cannot unmarshal string into Go struct field Kustomization.patches of type types.Patch
This is the kustomization file:
# Adds namespace to all resources.
namespace: marquis-system
# Value of this field is prepended to the
# names of all resources, e.g. a deployment named
# "wordpress" becomes "alices-wordpress".
# Note that it should also match with the prefix (text before '-') of the namespace
# field above.
namePrefix: marquis-
# Labels to add to all resources and selectors.
#commonLabels:
# someName: someValue
# Each entry in this list must resolve to an existing
# resource definition in YAML. These are the resource
# files that kustomize reads, modifies and emits as a
# YAML string, with resources separated by document
# markers ("---").
resources:
- ./rbac/rbac_role.yaml
- ./rbac/rbac_role_binding.yaml
- ./manager/manager.yaml
- ./rbac/auth_proxy_service.yaml
- ./rbac/auth_proxy_role.yaml
- ./rbac/auth_proxy_role_binding.yaml
patches:
- manager_image_patch.yaml
# Protect the /metrics endpoint by putting it behind auth.
# Only one of manager_auth_proxy_patch.yaml and
# manager_prometheus_metrics_patch.yaml should be enabled.
- manager_auth_proxy_patch.yaml
# If you want your controller-manager to expose the /metrics
# endpoint w/o any authn/z, uncomment the following line and
# comment manager_auth_proxy_patch.yaml.
# Only one of manager_auth_proxy_patch.yaml and
# manager_prometheus_metrics_patch.yaml should be enabled.
#- manager_prometheus_metrics_patch.yaml
"patches:" was obsolete. You are supposed to use "patchesStrategicMerge:" instead.
Since "patches:" is used for more extended patching.
thanks, I guess that was it. I think the readme should be updated.
+1, I hit the same error. My yaml files were generated by kubebuilder, they worked with Kustomize v2, but upgrading Kustomize to v3.0.3 breaks it.
Interesting...Was looking at the log. patches has been deprecated last year v1.0.9.
I guess we will have to check if kubebuilder needs to be updated. Meanwhile the easiest workaround is
replaced patches: by patchesStrategicMerge:
@functicons Created a PR in kubebuilder
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
@fejta-bot: Closing this issue.
In response to this:
Rotten issues close after 30d of inactivity.
Reopen the issue with/reopen.
Mark the issue as fresh with/remove-lifecycle rotten.Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/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.
Hi since patches is obsolete, this example should be removed or updated.
I think "patches" means something else - not obsolete as of today.
It is used for patching multiple objects at once via the same patch file.
Okay so the use of "patches" above is not working because it's missing target? And with target specified it's still working/valid use?
I think the problem is kubectl uses a much older version of kustomize. It appears the "multiple patching" support was added in v3.1.0 of kustomize (based on when examples/patchMultipleObjects.md was added in this commit).
kustomize 3.5.4❯ kustomize version
{Version:3.5.4 GitCommit:3af514fa9f85430f0c1557c4a0291e62112ab026 BuildDate:2020-01-17T14:23:25+00:00 GoOs:darwin GoArch:amd64}
overlays/my-overlay/kustomization.yaml
patches:
- patch: |
apiVersion: apps/v1
kind: Deployment
metadata:
name: does-not-matter
spec:
template:
spec:
priorityClassName: my-priority-class
target:
kind: Deployment
This works:
kustomize build overlays/my-overlay
kubectl (1.18) with kustomize (2.0.3)❯ kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.1", GitCommit:"7879fc12a63337efff607952a323df90cdc7a335", GitTreeState:"clean", BuildDate:"2020-04-10T21:53:51Z", GoVersion:"go1.14.2", Compiler:"gc", Platform:"darwin/amd64"}
_Currently the only way to know which version of kustomize is used in kubectl is to consult the README, which currently states its using v2.0.3._
So this does not work:
❯ kubectl kustomize overlays/my-overlay
Error: AccumulateTarget: couldn't make target for {redacted}: cannot unmarshal object into Go struct field Kustomization.patchesStrategicMerge of type patch.StrategicMerge
Yep that’s right
Most helpful comment
I think the problem is
kubectluses a much older version ofkustomize. It appears the "multiple patching" support was added inv3.1.0ofkustomize(based on whenexamples/patchMultipleObjects.mdwas added in this commit).Works in
kustomize3.5.4overlays/my-overlay/kustomization.yamlThis works:
But not in
kubectl(1.18) withkustomize(2.0.3)_Currently the only way to know which version of
kustomizeis used inkubectlis to consult the README, which currently states its usingv2.0.3._So this does not work: