kustomize: Error: json: cannot unmarshal string into Go struct field Kustomization.patches of type types.Patch
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
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (4 by maintainers)
Commits related to this issue
- kustomization: Work with v3 This was probably fine when Chris wrote it in February, but since then the newest release of Kustomization has broken things: https://github.com/kubernetes-sigs/kustomize/... — committed to Krenair/verify-metadata-controller by Krenair 5 years ago
- kustomization.yaml: Use patchesStrategicMerge. Change "patches" to "patchesStrategicMerge". The use of "patches" has been deprecated since v1.0.9: https://github.com/kubernetes-sigs/kustomize/blob/... — committed to russellb/cluster-api-provider-baremetal by russellb 5 years ago
- change from patches to patchesStrategicMerge on kustomize files This is due to https://github.com/kubernetes-sigs/kustomize/issues/1373 — committed to hellomd/kube-ci by JCMais 5 years ago
- Replace obsolete patches with patchesStrategicMerge This was made obsolete in v1.0.9 https://github.com/kubernetes-sigs/kustomize/blob/v1.0.9/pkg/types/kustomization.go#L129 And stopped working in v3... — committed to deepy/intel-device-plugins-for-kubernetes by deepy 2 years ago
- Replace obsolete patches with patchesStrategicMerge This was made obsolete in v1.0.9 https://github.com/kubernetes-sigs/kustomize/blob/v1.0.9/pkg/types/kustomization.go#L129 And stopped working in v3... — committed to deepy/intel-device-plugins-for-kubernetes by deepy 2 years ago
- Update kustomization.yaml https://github.com/kubernetes-sigs/kustomize/issues/1373 — committed to shikn1/argo-examples by shikn1 a year ago
- attempt to implement fix suggested at https://github.com/kubernetes-sigs/kustomize/issues/1373 — committed to pharaofranz/linkerd-website by deleted user 8 months ago
- attempt to implement fix suggested at the very bottom of https://github.com/kubernetes-sigs/kustomize/issues/1373 — committed to pharaofranz/linkerd-website by deleted user 8 months ago
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:
As opposed to pointed out in other comments,
patchesshould be used only, aspatchesStrategicMergefield was deprecated in v5.0.0.The change that worked for me while using
patches:only, was:Adding
path:in patches.Hi since patches is obsolete, this example should be removed or updated.
Yep that’s right
This can be automatically done by running
kustomize edit fix.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:bypatchesStrategicMerge:“patches:” was obsolete. You are supposed to use “patchesStrategicMerge:” instead.
Since “patches:” is used for more extended patching.