Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubectl kustomize v. 1.21 not supporting YAML references #1043

Closed
ZhilinS opened this issue Apr 27, 2021 · 5 comments
Closed

kubectl kustomize v. 1.21 not supporting YAML references #1043

ZhilinS opened this issue Apr 27, 2021 · 5 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/duplicate Indicates an issue is a duplicate of other open issue.

Comments

@ZhilinS
Copy link

ZhilinS commented Apr 27, 2021

What happened:
After upgrading kubectl to version 1.21 kustomize command fails when YAML anchors are references by '<<'

What you expected to happen:
As it was in v. 1.20, command should provide correct output, but not the erorr

How to reproduce it (as minimally and precisely as possible):
Given this 2 files:

kustomization.yaml
api.yaml

kustomization.yaml:

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

resources:
  - api.yaml

api.yaml:

apiVersion: v1
kind: Service
metadata:
  name: service
  labels: &labels
    label: test
spec:
  selector:
    <<: *labels

Execute kubectl kustomize . and see the following output:
v. 1.20:

apiVersion: v1
kind: Service
metadata:
  labels:
    label: test
  name: service
spec:
  selector:
    label: test

v. 1.21:

Error: map[string]interface {}{"apiVersion":"v1", "kind":"Service", "metadata":map[string]interface {}{"labels":map[string]interface {}{"label":"test"}, "name":"service"}, "spec":map[string]interface {}{"selector":map[interface {}]interface {}{"label":"test"}}}: json: unsupported type: map[interface {}]interface {}

So, now kubectl cannot recognize << while parsing yaml. Replacement with any string fixes the issue. Even "<<" fixes it.

Environment:

  • Server version doesn't matter, 'cause it's happening on a client command step
@ZhilinS ZhilinS added the kind/bug Categorizes issue or PR as related to a bug. label Apr 27, 2021
@k8s-ci-robot
Copy link
Contributor

@ZhilinS: This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Apr 27, 2021
@ZhilinS
Copy link
Author

ZhilinS commented Apr 28, 2021

It can be fixed by changing api.yaml to

apiVersion: v1
kind: Service
metadata:
  name: service
  labels: &labels
    label: test
spec:
  selector: *labels

but it's strange to see that previous version of tool was working with standard YAML syntax and the newest one isn't

@sameersbn
Copy link

sameersbn commented Apr 28, 2021

We have been experiencing a lot of issues with regard to the use of anchors. Following YAML that used to work with kubectl v1.20.4 no longer seems to be working and errors out with the message : node must be a scalar, sequence or map.

 apiVersion: rbac.authorization.k8s.io/v1
 kind: ClusterRoleBinding
 metadata:
   name: &app my-app
 subjects:
 - kind: ServiceAccount
   name: *app
 roleRef:
   apiGroup: rbac.authorization.k8s.io
   kind: ClusterRole
   name: *app

Also rendering https://github.com/knative-sandbox/eventing-kafka-broker/releases/download/v0.22.1/eventing-kafka-controller.yaml using kubectl kustomize errors out due to the following usage:

          livenessProbe:
            !!merge <<: *probe
            initialDelaySeconds: 20

Similarly rendering https://github.com/knative-sandbox/eventing-kafka/releases/download/v0.22.3/source.yaml errors out due to the use of YAML anchors.

edit: none of the above issues are experienced with kubectl 1.20.4

@KnVerey
Copy link
Contributor

KnVerey commented Apr 28, 2021

Kubectl 1.21 contains a large version bump to Kustomize, from v2 to v4. There are already several issues open on the Kustomize repo about problems with YAML anchors. Please follow along there. I believe the most relevant to this particular case is kubernetes-sigs/kustomize#3614.

/triage duplicate
/close

@k8s-ci-robot k8s-ci-robot added the triage/duplicate Indicates an issue is a duplicate of other open issue. label Apr 28, 2021
@k8s-ci-robot
Copy link
Contributor

@KnVerey: Closing this issue.

In response to this:

Kubectl 1.21 contains a large version bump to Kustomize, from v2 to v4. There are already several issues open on the Kustomize repo about problems with YAML anchors. Please follow along there. I believe the most relevant to this particular case is kubernetes-sigs/kustomize#3614.

/triage duplicate
/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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/duplicate Indicates an issue is a duplicate of other open issue.
Projects
None yet
Development

No branches or pull requests

4 participants