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

Error on "HelloWorld" example #3479

Closed
EKami opened this issue Jan 17, 2021 · 4 comments
Closed

Error on "HelloWorld" example #3479

EKami opened this issue Jan 17, 2021 · 4 comments
Assignees
Labels
kind/documentation Categorizes issue or PR as related to documentation. kind/support Categorizes issue or PR as a support question.

Comments

@EKami
Copy link

EKami commented Jan 17, 2021

Describe the bug

I'm getting the following error when I try to apply the helloworld example from examples/helloWorld:

$ kubectl apply -k $DEMO_HOME/base
error: json: unknown field "metadata"

Files that can reproduce the issue

Thes files from https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/examples/helloWorld/{configMap,deployment,kustomization,service}.yaml

Expected output

exit 0 with successful application

Actual output

error: json: unknown field "metadata"

Kustomize version

I'm using kubectl -k ... from Docker desktop on Windows with:

$ k version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.12", GitCommit:"7cd5e9086de8ae25d6a1514d0c87bac67ca4a481", GitTreeState:"clean", BuildDate:"2020-11-12T09:18:55Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}

Platform

Linux (Windows WSL)

Resolution

Change kustomization.yaml from:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
metadata:
  name: arbitrary

# Example configuration for the webserver
# at https://github.com/monopole/hello
commonLabels:
  app: hello

resources:
- deployment.yaml
- service.yaml
- configMap.yaml

to

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

# Example configuration for the webserver
# at https://github.com/monopole/hello
commonLabels:
  app: hello

resources:
- deployment.yaml
- service.yaml
- configMap.yaml

I'm posting the issue so that someone may update the kustomization.yaml if it's not an issue related to my own env (I'm not experimented enough with k8s/kustomize to say if that's the case).

@monopole monopole self-assigned this Jan 19, 2021
@Shell32-Natsu
Copy link
Contributor

I think this is a documentation issue in the example. Previously kustomization doesn't have metadata field and we added it months ago. kustomize version shipped with kubectl hasn't been updated for a long time.

@Shell32-Natsu Shell32-Natsu added kind/documentation Categorizes issue or PR as related to documentation. kind/support Categorizes issue or PR as a support question. labels Jan 19, 2021
@monopole
Copy link
Contributor

Please use "bare" kustomize: https://kubectl.docs.kubernetes.io/installation/kustomize/binaries
and pipe the output to kubectl -f -, e.g.

kustomize build $DEMO_HOME/base | kubectl -f -

The hello world example is validated as part of it's release process.

The version in kubectl is very old; work to update it is tracking in #1500

@EKami
Copy link
Author

EKami commented Jan 19, 2021

@monopole in that case you should at least update the docs since the doc uses kubectl, see here

@codetheweb
Copy link

I would also appreciate a documentation update as I stumbled into this today as a new user of kustomize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/documentation Categorizes issue or PR as related to documentation. kind/support Categorizes issue or PR as a support question.
Projects
None yet
Development

No branches or pull requests

4 participants