kubernetes / kubeadm

Aggregator for issues filed against kubeadm
Apache License 2.0
3.76k stars 716 forks source link

kubeadm kubeconfig user command fails with invalid configuration #2629

Closed sitilge closed 2 years ago

sitilge commented 2 years ago

BUG REPORT

Versions

kubeadm version: &version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.1", GitCommit:"86ec240af8cbd1b60bcc4c03c20da9b98005b92e", GitTreeState:"clean", BuildDate:"2021-12-16T11:39:51Z", GoVersion:"go1.17.5", Compiler:"gc", Platform:"linux/amd64"}

Environment:

What happened?

Was following the kubeadm docs, setting up a new control plane. Then kubeadm kubeconfig user --client-name=abc --config=/etc/kubernetes/admin.conf --v=5 fails with the logs provided below. Basically, it says: invalid configuration for GroupVersionKind /v1, Kind=Config: kind and apiVersion is mandatory information that must be specified. The kubeadm config file is as follows:

kind: ClusterConfiguration
apiVersion: kubeadm.k8s.io/v1beta3
kubernetesVersion: v1.23.0
clusterName: xx
---
kind: KubeletConfiguration
apiVersion: kubelet.config.k8s.io/v1beta1
kubernetesVersion: v1.23.0

What you expected to happen?

The previous command to work.

How to reproduce it (as minimally and precisely as possible)?

Initialize a new control-plane node, then run the command above.

Anything else we need to know?

root@master-1:~# kubeadm kubeconfig user --client-name=abc --config=/etc/kubernetes/admin.conf --v=5
I1218 15:15:22.095073   14488 initconfiguration.go:248] loading configuration from "/etc/kubernetes/admin.conf"
invalid configuration for GroupVersionKind /v1, Kind=Config: kind and apiVersion is mandatory information that must be specified
k8s.io/kubernetes/cmd/kubeadm/app/util.SplitYAMLDocuments
    /workspace/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kubeadm/app/util/marshal.go:101
k8s.io/kubernetes/cmd/kubeadm/app/util/config.BytesToInitConfiguration
    /workspace/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kubeadm/app/util/config/initconfiguration.go:278
k8s.io/kubernetes/cmd/kubeadm/app/util/config.LoadInitConfigurationFromFile
    /workspace/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kubeadm/app/util/config/initconfiguration.go:255
k8s.io/kubernetes/cmd/kubeadm/app/util/config.LoadOrDefaultInitConfiguration
    /workspace/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kubeadm/app/util/config/initconfiguration.go:267
k8s.io/kubernetes/cmd/kubeadm/app/cmd.newCmdUserKubeConfig.func1
    /workspace/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kubeadm/app/cmd/kubeconfig.go:86
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).execute
    /workspace/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:856
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).ExecuteC
    /workspace/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:974
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).Execute
    /workspace/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/vendor/github.com/spf13/cobra/command.go:902
k8s.io/kubernetes/cmd/kubeadm/app.Run
    /workspace/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/cmd/kubeadm/app/kubeadm.go:50
main.main
    _output/dockerized/go/src/k8s.io/kubernetes/cmd/kubeadm/kubeadm.go:25
runtime.main
    /usr/local/go/src/runtime/proc.go:255
runtime.goexit
    /usr/local/go/src/runtime/asm_amd64.s:1581

Seems like related to not being able to split Yaml documents?

neolit123 commented 2 years ago

/kind support

--config=/etc/kubernetes/admin.conf

You seem to be passing a kubeconfig file (admin.conf), and not a kubeadm config file.

sitilge commented 2 years ago

@neolit123 you're right, don't know what I was thinking.

SataQiu commented 2 years ago

as per above response /close

k8s-ci-robot commented 2 years ago

@SataQiu: Closing this issue.

In response to [this](https://github.com/kubernetes/kubeadm/issues/2629#issuecomment-997318259): >as per above response >/close > Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.