Welcome to the Linux Foundation Forum!

kubectl get node error

Hello,

I'm trying to attach my node to the master and get the following error:

Kubectl on host returns error: couldn't get version/kind; json parse error: json: cannot unmarshal string into Go value of type struct { APIVersion string "json:\"apiVersion,omitempty\""; Kind string "json:\"kind,omitempty

It looks like it's having an issue with .kube/config

.kube/config is fine on master.

Any ideas?

Thanks!

Reg

Comments

  • chrispokorni
    chrispokorni Posts: 2,606

    Hi @rdancy,

    Once the worker node successfully joined the master/cluster, you should see that confirmation message at the end of the output produced by the join phase.
    Then, the kubectl get node command is expected to be run on (or against) the master node.

    Regards,
    -Chris

  • rdancy
    rdancy Posts: 14

    Here's the command I ran:
    kubectl get nodes
    error: error loading config file "/home/reg_dancy01/.kube/config": couldn't get version/kind; json parse error:
    json: cannot unmarshal string into Go value of type struct { APIVersion string "json:\"apiVersion,omitempty\"";
    Kind string "json:\"kind,omitempty\"" }

    Yes it runs without an issue on the master

    I was following the lab, the part it says grow your cluster

  • chrispokorni
    chrispokorni Posts: 2,606
    edited August 2020

    The lab does not guide you to configure kubectl with the expected .kube/config file on the worker node, and, as a result, kubectl is not expected to work from the worker node.

    However, if you want to configure it yourself, then separately you would need to setup the .kube/config file on the worker node, by copying it over from the master node, and ensuring it has the same owner/permissions as found on the master node.

    Regards,
    -Chris

  • rdancy
    rdancy Posts: 14

    Hi ,

    I also ran the join command before running the get nodes command:

    root@instance-1:~# kubeadm join 10.128.0.3:6443 --token W0817 13:16:19.690275 --discovery-token-ca-cert-hash sha
    256:0d9acb893d4ff0c34ebfd8c02644796a3924ffeca20799ca018553a7e411ce26
    accepts at most 1 arg(s), received 2
    To see the stack trace of this error execute with --v=5 or higher
    root@instance-1:~#

  • chrispokorni
    chrispokorni Posts: 2,606

    The value of your token does not look right. It seems to be the prefix of a Warning message, with today's date and time.

    The value of the token has a different structure.

    Try re-creating the token, run kubectl reset on the worker node, then run the kubeadm join ... command again on the worker, with the value of the new token instead.

    Regards,
    -Chris

  • rdancy
    rdancy Posts: 14

    Hello

    I took your advice and restarted with two new VMs. I have re-configured the master and joined the worker successfully.

    Thanks for the help

    Reg

Categories

Upcoming Training