简体   繁体   English

kubectl错误:您必须登录到服务器(未经授权)

[英]kubectl error: You must be logged in to the server (Unauthorized)

Today I met a strange issue about my Windows kubectl client suddenly raise authorization issue in connecting ICp. 今天我遇到了一个奇怪的问题,关于我的Windows kubectl客户端在连接ICp时突然提出授权问题。

I was using ICP with a Widows configured kubectl.exe. 我正在使用带有Widows配置的kubectl.exe的ICP。 Then, after a while, due to laptop automatic sleeping, my VPN connection was disconnected, hence lose connection to remote ICP. 然后,一段时间后,由于笔记本电脑自动睡眠,我的VPN连接断开,因此失去了与远程ICP的连接。 Later I came back and re-connect the ICP. 后来我回来重新连接了ICP。 I use kubectl command again and faced: 我再次使用kubectl命令并遇到:

error: You must be logged in to the server (Unauthorized) 错误:您必须登录到服务器(未授权)

On ICP master node, nothing wrong if I used: 在ICP主节点上,如果我使用的话没有错:

kubectl -s 127.0.0.1:8888 -n kube-system get pods -o wide kubectl -s 127.0.0.1:8888 -n kube-system get pods -o wide

I went back to re-configure client (pasted the code copied from admin -> configure kubectl), commands executed successful but when I issue 我回去重新配置客户端(粘贴从admin复制的代码 - >配置kubectl),命令执行成功但是当我发出时

kubectl get pods kubectl获得pods

still error. 还是错误。

I checked article: 我查了一下文章:

kubectl - error: You must be logged in to the server kubectl - 错误:您必须登录到服务器

kubectl error: "You must be logged in to the server (the server has asked for the client to provide credentials)" kubectl错误:“您必须登录到服务器(服务器已要求客户端提供凭据)”

error: You must be logged in to the server (the server has asked for the client to provide credentials) 错误:您必须登录到服务器(服务器已要求客户端提供凭据)

It looks like didn't much helpful 看起来好像没多大帮助

It turns out that the tokens was invalid (not sure if it because of 12 hours expiration). 事实证明,令牌无效(不确定是否因为12小时到期)。 If you simply F5 the browser page you didn't re-authenticated but still can access the console page, but actually the token should be updated by re-login ICP Portal again. 如果您只是F5浏览器页面,您没有重新进行身份验证,但仍然可以访问控制台页面,但实际上应该通过重新登录ICP门户来更新令牌。

The issue was fixed by re-access the ICP portal: 通过重新访问ICP门户来解决该问题:

https://<master host>:8443/console/

This will re-allow you authenticate. 这将重新允许您进行身份验证。 After that, go to admin -> configure client, paste the latest commands you will find the token might be updated. 之后,转到admin - > configure client,粘贴最新的命令,您会发现令牌可能会更新。 Executing the new commands solved the issue. 执行新命令解决了问题。

2 Question still left: 2问题仍然存在:

a) If the page was long opened and token expired, ICP portal page may not auto refreshed to force you re-login, that means the token in set-credentials command are still old. a)如果页面长时间打开且令牌过期,ICP门户页面可能不会自动刷新以强制您重新登录,这意味着set-credentials命令中的令牌仍然是旧的。

b) Even setting old tokens are accepted and command never complain an error even warning. b)即使设置旧令牌也被接受,命令永远不会抱怨错误甚至警告。 This may mislead us when token are changed on servers, eg, If I saved the commands to a local txt file and re-execute it again (even after token expired), the commands still finished successful, but actually I still didn't get authenticated correctly when I try to login. 当在服务器上更改令牌时,这可能会误导我们,例如,如果我将命令保存到本地txt文件并再次重新执行(即使在令牌过期后),命令仍然成功完成,但实际上我仍然没有得到我尝试登录时正确验证。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 kubectl: error You must be logged in to the server (Unauthorized) - kubectl: error You must be logged in to the server (Unauthorized) kubectl:错误:您必须登录到服务器(未经授权) - kubectl : error: You must be logged in to the server (Unauthorized) kubectl 错误您必须登录服务器(未授权)- EKS 集群 - kubectl error You must be logged in to the server (Unauthorized) - EKS cluster Kubectl 与 Gitlab EKS 集群错误:您必须登录到服务器(未经授权) - Kubectl with Gitlab EKS Cluster Error: You must be logged in to the server (Unauthorized) kubectl &quot;error: You must be login to the server (Unauthorized)&quot; 使用 kubectx, 而如果直接使用相同的配置没有错误 - kubectl "error: You must be logged in to the server (Unauthorized)" using kubectx, while no error if used the same config directly kubectl 错误:您必须登录到服务器 - kubectl Error: You must be logged in to the server kubectl 顶级节点无法工作,它显示:“错误:您必须登录到服务器(未经授权)” - kubectl top node cannot work, it shows: "error: You must be logged in to the server (Unauthorized)" kubectl error 访问EKS集群时必须登录服务器(未授权) - kubectl error You must be logged in to the server (Unauthorized) when accessing EKS cluster 设备登录后 kubectl 返回错误 您必须登录到服务器(未经授权) - kubectl after device login returns error you must be logged in to the server (Unauthorized) kubectl 错误:您必须在 AKS 中一段时间后登录到服务器(未经授权) - kubectl error: You must be logged in to the server (Unauthorized) after some time in AKS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM