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

YAML Anchor Override Support #4747

Closed
BorisO opened this issue Aug 3, 2022 · 3 comments
Closed

YAML Anchor Override Support #4747

BorisO opened this issue Aug 3, 2022 · 3 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/resolved Indicates an issue has been resolved or doesn't need to be resolved.

Comments

@BorisO
Copy link

BorisO commented Aug 3, 2022

Kustomize can't build manifests in some situations when YAML anchors are used. I know that this has been previously addressed in #3675 which fixes anchors in some cases but I'm still having an issue when an anchor overrides are used. I'm using kubectl v1.23 to run the kustomize build. This kubectl version uses kustomize v4.4.1 which should have the mentioned anchor fix.

Note that in the below example the name and label anchors work as expected. Only the default anchor causes issues.
This build works as expected using kubectl v1.20

kustomization.yaml

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

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: &name test-app
  labels:
    app.kubernetes.io/name: test-app
    app.kubernetes.io/part-of: test-app
    app.kubernetes.io/instance: test-app
spec:
  selector:
    matchLabels: &labels
      app.kubernetes.io/instance: test-app
  replicas: 1
  template:
    metadata:
      name: *name
      labels: *labels
    spec:
      restartPolicy: Always
      containers:
        - &default
          name: default
          image: test-app
          imagePullPolicy: Always
          resources:
            limits:
              memory: 4Gi
              cpu: 1
          command: ["/bin/sh"]
          args: ["-c", "echo 'test app'"]
        - <<: *default
          name: second
          resources:
            limits:
              memory: 200Mi
              cpu: 0.1
          command: ["/bin/sh"]
          args: ["-c", "echo 'test app 2'"]

Actual output

E0803 14:30:11.589029   58695 run.go:120] "command failed" err="map[string]interface {}{\"apiVersion\":\"apps/v1\", \"kind\":\"Deployment\", \"metadata\":map[string]interface {}{\"labels\":map[string]interface {}{\"app.kubernetes.io/instance\":\"test-app\", \"app.kubernetes.io/name\":\"test-app\", \"app.kubernetes.io/part-of\":\"test-app\"}, \"name\":\"test-app\"}, \"spec\":map[string]interface {}{\"replicas\":1, \"selector\":map[string]interface {}{\"matchLabels\":map[string]interface {}{\"app.kubernetes.io/instance\":\"test-app\"}}, \"template\":map[string]interface {}{\"metadata\":map[string]interface {}{\"labels\":map[string]interface {}{\"app.kubernetes.io/instance\":\"test-app\"}, \"name\":\"test-app\"}, \"spec\":map[string]interface {}{\"containers\":[]interface {}{map[string]interface {}{\"args\":[]interface {}{\"-c\", \"echo 'test app'\"}, \"command\":[]interface {}{\"/bin/sh\"}, \"image\":\"test-app\", \"imagePullPolicy\":\"Always\", \"name\":\"default\", \"resources\":map[string]interface {}{\"limits\":map[string]interface {}{\"cpu\":1, \"memory\":\"4Gi\"}}}, map[interface {}]interface {}{\"args\":[]interface {}{\"-c\", \"echo 'test app'\"}, \"command\":[]interface {}{\"/bin/sh\"}, \"image\":\"test-app\", \"imagePullPolicy\":\"Always\", \"livenessProbe\":interface {}(nil), \"name\":\"second\", \"resources\":map[string]interface {}{\"limits\":map[string]interface {}{\"cpu\":0.1, \"memory\":\"200Mi\"}}}}, \"restartPolicy\":\"Always\"}}}}: json: unsupported type: map[interface {}]interface {}"

Kustomize version

v4.4.1

Platform

macOS

@BorisO BorisO added the kind/bug Categorizes issue or PR as related to a bug. label Aug 3, 2022
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Aug 3, 2022
@k8s-ci-robot
Copy link
Contributor

@BorisO: 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.

@BorisO BorisO changed the title YAML Anchor in list YAML Anchor Override Support Aug 9, 2022
@KnVerey
Copy link
Contributor

KnVerey commented Aug 16, 2022

I tried your sample with the latest release (4.5.7) and it expands just fine. I think you may need the fix in #4383, which is included in v4.5.3+, so more recent than you're using.

/close
/triage resolved

@k8s-ci-robot k8s-ci-robot added the triage/resolved Indicates an issue has been resolved or doesn't need to be resolved. label Aug 16, 2022
@k8s-ci-robot
Copy link
Contributor

@KnVerey: Closing this issue.

In response to this:

I tried your sample with the latest release (4.5.7) and it expands just fine. I think you may need the fix in #4383, which is included in v4.5.3+, so more recent than you're using.

/close
/triage resolved

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/resolved Indicates an issue has been resolved or doesn't need to be resolved.
Projects
None yet
Development

No branches or pull requests

3 participants