惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
Hugging Face - Blog
Hugging Face - Blog
L
LINUX DO - 热门话题
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
D
Docker
C
Cyber Attacks, Cyber Crime and Cyber Security
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
T
Tenable Blog
P
Privacy International News Feed
Google DeepMind News
Google DeepMind News
小众软件
小众软件
Cisco Talos Blog
Cisco Talos Blog
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
A
Arctic Wolf
C
Cybersecurity and Infrastructure Security Agency CISA
C
Cisco Blogs
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
The Hacker News
The Hacker News
Project Zero
Project Zero
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Threatpost
V
Visual Studio Blog
The GitHub Blog
The GitHub Blog
The Cloudflare Blog
Last Week in AI
Last Week in AI
Jina AI
Jina AI
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
Vercel News
Vercel News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
MongoDB | Blog
MongoDB | Blog
U
Unit 42
Scott Helme
Scott Helme
A
About on SuperTechFans
WordPress大学
WordPress大学
F
Fortinet All Blogs
大猫的无限游戏
大猫的无限游戏
G
GRAHAM CLULEY
Latest news
Latest news
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
Schneier on Security

error on 打工人日志

kindle 邮件发送失败,错误代码E999 SELinux 问题:导致端口无法创建,无法访问 linux服务器进程打开文件过多导致服务异常 解决Elasticsearch索引只读(read-only) Linux 系统收包流程以及内核参数优化 Vue3 + vite + nginx项目部署后404问题 githubAction set-output弃用错误 k8s CNI 问题 连接认证失效 k8s.gcr.io国内无法连接解决方法 K8S 问题排查:cgroup 内存泄露问题 docker 问题处理 安装 docker 出现 ERROR: Unsupported distribution 'ol' 问题
k8s master 节点 Unauthorized
2025-12-03 · via error on 打工人日志

故障

多master集群的k8s其中一台master 出现 You must be logged in to the server (Unauthorized),说明当前节点上的 kubectl 无法认证到 apiserver。
共有三台master:

  • master1 正常
  • master2 异常
  • master3 异常

排查问题

用 admin 证书直接用 curl 测试认证

1curl --cert /etc/kubernetes/pki/admin.crt --key /etc/kubernetes/pki/admin.key -k https://10.10.10.68:6443/healthz
  • 结果 HTTP/1.1 200 OK → TLS + 认证成功(client cert 被接受)。
  • 若返回 401/403 → TLS 成功但授权失败(RBAC 或 client cert 虽被接受但没有权限)。把完整返回贴来。
  • 若 curl 报 TLS 错误 → client cert/CA 有问题(贴错误信息)。

把 kubeconfig 中的 client cert/key 解码到临时文件并检查它们(确认 kubectl 用的是这个证书、并检查证书 Subject/CN/到期日)

1# 解码证书与私钥
2awk '/client-certificate-data/ {print $2}' ~/.kube/config | base64 -d > /tmp/kube_client.crt
3awk '/client-key-data/ {print $2}' ~/.kube/config | base64 -d > /tmp/kube_client.key
4chmod 600 /tmp/kube_client.key
5
6# 检查证书主体与到期日
7openssl x509 -in /tmp/kube_client.crt -noout -text | egrep "Subject:|Not Before|Not After"

如果看到 Not After 在过去 → 证书过期(那就说明证书过期了)。 Subject 的 CN 通常是 kubernetes-admin 或 admin / system:admin,我们要确认 CN 是否合理。

我这边发现证书过期了,所以导致认证失败了。

解决

使用 kubeadm 重新生成 admin kubeconfig.

在任意 master 上执行:

 1# 备份旧配置
 2mv ~/.kube/config ~/.kube/config.bak
 3
 4# 重新生成 admin kubeconfig
 5kubeadm init phase kubeconfig admin
 6
 7# 拷贝到用户目录
 8mkdir -p ~/.kube
 9cp /etc/kubernetes/admin.conf ~/.kube/config
10chmod 600 ~/.kube/config

测试