kubectl shows error You must be logged in to the server (Unauthorized) after Kubernetes upgrade

Written by - 1 comments

Published on - Listed in Kubernetes Containers Rancher


After a Kubernetes cluster was upgraded from K8s 1.13 to 1.15, local kubectl commands could not be executed anymore and failed with the following error:

$ kubectl get nodes
error: You must be logged in to the server (Unauthorized)

This was working fine just before the upgrade and the correct kube config is being used - could it be related to the new version? Let's compare the client (kubectl) and the server versions of Kubernetes:

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.0", GitCommit:"fff5156092b56e6bd60fff75aad4dc9de6b6ef37", GitTreeState:"clean", BuildDate:"2017-03-28T16:36:33Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.12", GitCommit:"e2a822d9f3c2fdb5c9bfbe64313cf9f657f0a725", GitTreeState:"clean", BuildDate:"2020-05-06T05:09:48Z", GoVersion:"go1.12.17", Compiler:"gc", Platform:"linux/amd64"}

The local kubectl command seems pretty outdated, still running with 1.6. Is that it? Is a local client update sufficient? On the local machine, kubectl was upgraded to 1.18:

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.4", GitCommit:"c96aede7b5205121079932896c4ad89bb93260af", GitTreeState:"clean", BuildDate:"2020-06-17T11:41:22Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.12", GitCommit:"e2a822d9f3c2fdb5c9bfbe64313cf9f657f0a725", GitTreeState:"clean", BuildDate:"2020-05-06T05:09:48Z", GoVersion:"go1.12.17", Compiler:"gc", Platform:"linux/amd64"}

And the kubectl commands work again:

$ kubectl get nodes
NAME             STATUS   ROLES                      AGE    VERSION
192.168.253.12   Ready    controlplane,etcd,worker   199d   v1.15.12
192.168.253.13   Ready    controlplane,etcd,worker   199d   v1.15.12
192.168.253.14   Ready    controlplane,etcd,worker   14h    v1.15.12


Add a comment

Show form to leave a comment

Comments (newest first)

Ming from wrote on Nov 23rd, 2020:

this article realy help me very much.^_^


RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Icingaweb   Icingaweb2   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder   


Update cookies preferences