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

推荐订阅源

博客园 - 【当耐特】
Help Net Security
Help Net Security
P
Proofpoint News Feed
J
Java Code Geeks
爱范儿
爱范儿
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Full Disclosure
Google DeepMind News
Google DeepMind News
H
Help Net Security
G
Google Developers Blog
Jina AI
Jina AI
Vercel News
Vercel News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
Lohrmann on Cybersecurity
S
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
Security Archives - TechRepublic
Security Archives - TechRepublic
阮一峰的网络日志
阮一峰的网络日志
N
News and Events Feed by Topic
GbyAI
GbyAI
B
Blog
O
OpenAI News
博客园_首页
Cisco Talos Blog
Cisco Talos Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hacker News: Ask HN
Hacker News: Ask HN
TaoSecurity Blog
TaoSecurity Blog
腾讯CDC
MongoDB | Blog
MongoDB | Blog
M
MIT News - Artificial intelligence
C
Cybersecurity and Infrastructure Security Agency CISA
Cyberwarzone
Cyberwarzone
Webroot Blog
Webroot Blog
Simon Willison's Weblog
Simon Willison's Weblog
Y
Y Combinator Blog
C
Cisco Blogs
A
Arctic Wolf
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Exploit Database - CXSecurity.com
Security Latest
Security Latest
AI
AI
W
WeLiveSecurity
aimingoo的专栏
aimingoo的专栏
The Register - Security
The Register - Security
Project Zero
Project Zero
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
Netflix TechBlog - Medium
Blog — PlanetScale
Blog — PlanetScale

问题库 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 问题库 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

测试