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

Quotes are dropped from namespace in kustomization resource #4386

Closed
shanalily opened this issue Jan 12, 2022 · 2 comments · Fixed by #4421
Closed

Quotes are dropped from namespace in kustomization resource #4386

shanalily opened this issue Jan 12, 2022 · 2 comments · Fixed by #4421
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.

Comments

@shanalily
Copy link
Contributor

shanalily commented Jan 12, 2022

When adding 'namespace' with only numeric characters to kustomization resource to be applied to all resources, quotes are dropped somewhere during the namespace transformation and the k8s resource becomes invalid when trying to apply.
This works fine in an older versions of kustomize where enable_kyaml was false by default.

Similar to #3412 and #3440 but for namespace field, so the kyaml fix is probably similar.

Example:

kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: "01234"
resources:
- resources.yaml

resources.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: test
data:
  key: "val"

Expected output

apiVersion: v1
data:
  key: val
kind: ConfigMap
metadata:
  name: test
  namespace: "01234"

Actual output

apiVersion: v1
data:
  key: val
kind: ConfigMap
metadata:
  name: test
  namespace: 668

Kustomize version

{Version:kustomize/v4.4.1 GitCommit:b2d65ddc98e09187a8e38adc27c30bab078c1dbf BuildDate:2021-11-11T23:27:14Z GoOs:darwin GoArch:amd64}

Platform

macOS

Additional context

@shanalily shanalily added the kind/bug Categorizes issue or PR as related to a bug. label Jan 12, 2022
@k8s-ci-robot
Copy link
Contributor

@shanalily: 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 Jan 12, 2022
@shanalily
Copy link
Contributor Author

I realized there are similar issues with bool "true" and "false" values in some cases.

Example with bool map key:

kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- resources.yaml
commonLabels:
  key: "01234"

resources.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: test
data:
  key: "val"
  yes: y 
  n: no
  true: trueval

Expected output

apiVersion: v1
data:
  key: val
  "n": "no"
  true: trueval
  "yes": "y"
kind: ConfigMap
metadata:
  labels:
    key: "01234"
  name: test

Actual output

Error: map[string]interface {}{"apiVersion":"v1", "data":map[interface {}]interface {}{true:"trueval", "key":"val", "n":"no", "yes":"y"}, "kind":"ConfigMap", "metadata":map[string]interface {}{"labels":map[string]interface {}{"key":"01234"}, "name":"test"}}: json: unsupported type: map[interface {}]interface {}

Example with bool map key:

kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- resources.yaml
commonLabels:
  key: "01234"

resources.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: test
data:
  key: "val"
  yes: y 
  n: no
  truekey: true

Expected output

apiVersion: v1
data:
  key: val
  "n": "no"
  truekey: "true"
  "yes": "y"
kind: ConfigMap
metadata:
  labels:
    key: "01234"
  name: test

Actual output

apiVersion: v1
data:
  key: val
  "n": "no"
  truekey: true
  "yes": "y"
kind: ConfigMap
metadata:
  labels:
    key: "01234"
  name: test

output of kustomize build . | kubectl apply -f - and kubectl apply -k .:

The request is invalid: patch: Invalid value: "map[data:map[truekey:true truth:<nil>] metadata:map[annotations:map[kubectl.kubernetes.io/last-applied-configuration:{\"apiVersion\":\"v1\",\"data\":{\"key\":\"val\",\"n\":\"no\",\"truekey\":true,\"yes\":\"y\"},\"kind\":\"ConfigMap\",\"metadata\":{\"annotations\":{},\"labels\":{\"key\":\"01234\"},\"name\":\"test\",\"namespace\":\"default\"}}\n]]]": unrecognized type: string

Kustomize version

{Version:kustomize/v4.4.1 GitCommit:b2d65ddc98e09187a8e38adc27c30bab078c1dbf BuildDate:2021-11-11T23:27:14Z GoOs:darwin GoArch:amd64}

kubectl version:

Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.3", GitCommit:"ca643a4d1f7bfe34773c74f79527be4afd95bf39", GitTreeState:"clean", BuildDate:"2021-07-15T20:58:09Z", GoVersion:"go1.16.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.7", GitCommit:"1f86634ff08f37e54e8bfcd86bc90b61c98f84d4", GitTreeState:"clean", BuildDate:"2021-11-18T00:11:23Z", GoVersion:"go1.16.10", Compiler:"gc", Platform:"linux/amd64"}

Platform

macOS

Additional context

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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants