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

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Schneier on Security
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Attack and Defense Labs
Attack and Defense Labs
H
Hacker News: Front Page
Google DeepMind News
Google DeepMind News
雷峰网
雷峰网
C
CXSECURITY Database RSS Feed - CXSecurity.com
Cisco Talos Blog
Cisco Talos Blog
T
Tenable Blog
G
Google Developers Blog
A
About on SuperTechFans
The Cloudflare Blog
S
Securelist
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
C
Cisco Blogs
H
Hackread – Cybersecurity News, Data Breaches, AI and More
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
Forbes - Security
Forbes - Security
腾讯CDC
Application and Cybersecurity Blog
Application and Cybersecurity Blog
V
Vulnerabilities – Threatpost
IT之家
IT之家
博客园_首页
P
Proofpoint News Feed
P
Privacy & Cybersecurity Law Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Project Zero
Project Zero
月光博客
月光博客
NISL@THU
NISL@THU
爱范儿
爱范儿
S
Secure Thoughts
K
Kaspersky official blog
Security Latest
Security Latest
T
Tailwind CSS Blog
博客园 - Franky
D
Darknet – Hacking Tools, Hacker News & Cyber Security
TaoSecurity Blog
TaoSecurity Blog
The GitHub Blog
The GitHub Blog
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
S
SegmentFault 最新的问题
H
Help Net Security
T
Tor Project blog
L
LINUX DO - 热门话题
S
Security @ Cisco Blogs
N
News and Events Feed by Topic
O
OpenAI News
S
Schneier on Security

博客 on 打工人日志

k8s RKE2 cilium L2 + envoy gateway 安装配置 k8s RKE2 vSphere 存储配置 OpenClaw 全能指南:从安装到进阶自动化实战 (2026 最终版) Kubernetes — skywalking + banyanDB APM监控部署 Kubernetes — promtail + loki + grafana 日志系统部署 k8s master 节点 Unauthorized Kubernetes — metalLB + Traefik 部署 Kubernetes — RKE2 + kube-vip + cilium 部署 使用TLSv1.3 升级nginx和openssl Proxmox VE(PVE) 更新到最新版本 kindle 邮件发送失败,错误代码E999 metallb + ingress-nginx + argocd 本地部署 iStoreOS(旁路由)使用openclash实现dns劫持 异常流量分析:图片库服务黑客入侵 openwrt 硬盘扩容 搭建ip地址检索服务 Kubernetes — k8s 手动安装 1.17.9 SELinux 问题:导致端口无法创建,无法访问 【福利】免费!本地部署!去除视频中移动的物体 通知:《打工人日报》迁移到独立板块 KyBook 3 | calibre-web - IOS系统最佳图书伴侣 Tmux 安装和使用教程 DockerHub 加速镜像部署 - 使用cloudflare 代理 docker的零停机部署 SD-webui 批量处理图片 ubuntu 安装 ComfyUI ubuntu 安装 stable-diffusion-webui 测试策略:微服务架构 单元测试:测试单元质量提升 端到端测试:模拟用户体验 Kubernetes — containerd 安装和部署 CI/CD 可观察性-基于grafana Argo cd 安装和部署 linux服务器进程打开文件过多导致服务异常 使用 ElasticSearch Curator 7天定期删除日志 sonarqube docker安装和配置 SSH 通过 443 端口连接 GitHub iOS 17 「待机显示」适配普通 iPhone(非 Pro/Max),屏幕在充电时常亮 GNU/Linux 一键更换系统软件源脚本 解决Elasticsearch索引只读(read-only) 【福利】埃隆·马斯克传 [沃尔特·艾萨克森] 在线下载 【破解】小鹏P5和小鹏G9开启adb和网络adb Kubernetes — kubecost 分析 Kubernetes 成本 3D Gaussian Splatting:3D模型渲染 Linux 系统收包流程以及内核参数优化 2023亚运会电竞门票民购买指南(报名+抽签) Vue3 + vite + nginx项目部署后404问题 大麦抢票辅助软件(福利 TFBOYS十年之约演唱会 2023 全机位 视频) 黑群晖最新安装教程 Ansible部署ceph集群 最好的微信朋友圈集赞神器-福利推荐 推荐一下 容器云资源 2010年的天涯神贴聊房价 如何礼貌回绝不合理的需求 nginx 配置和编译 github 国内代理访问下载 使用scrapy-redis实现增量爬取 逆境和成长-2022年终总结 优雅的使用Conda管理python环境 Jenkins 编译Android apk 流水线 Kubernetes — 更新证书 shell功能脚本集合 Nexus3 使用和部署 githubAction set-output弃用错误 Kubernetes — Rook云存储介绍和部署 Kubernetes — 基于K8S搭建Ceph分布式存储 Kubernetes — 探针和生命周期 Kubernetes — 开放标准(OCI、CRI、CNI、CSI、SMI、CPI)概述 kubernetes 部署插件 (Flannel、Web UI、CoreDNS、Ingress Controller) Cloudflare Zero Trust 内网穿透 k8s CNI 问题 连接认证失效 k8s.gcr.io国内无法连接解决方法 headscale 部署使用 羊了个羊小程序 破解通关 K8S 问题排查:cgroup 内存泄露问题 RocketMQ k8s部署 4主4从集群 docker 问题处理 kubernetes 存储 linux服务器 删除空间却未释放 kubernetes 从1.23.x 升级到 1.24.x 编写 kubernetes 资源描述文件 nginx ssh-key connection exception kubernetes manual expansion VSCode插件推荐=> Code Runner ant build.xml 编写 kubernetes 调度过程 记录一次上门打散工 k8s本地联调神器kt-connect Ant中如何添加第三方jar包依赖 OpenELB:让k8s私有环境对外暴露端口 linux 网络测速 安装 docker 出现 ERROR: Unsupported distribution 'ol' 问题 logrotate 日志滚动的使用 nginx 编译参数详解 nginx 重写规则 rewrite模块 nginx.conf 配置文件详解 rsync 文件同步 nginx 日志格式整理 163企业邮箱设置教程 2021年第50周记
Kubernetes — SSL 证书自动更新
2025-09-29 · via 博客 on 打工人日志

介绍

提供一个在 Kubernetes 中使用 cert-manager + Cloudflare 自动签发并自动更新 Let’s Encrypt 证书的完整思路与示例(DNS-01 验证),方便你在集群内自动化 TLS 证书更新。

前置条件

  • Kubernetes 集群:可正常访问外网。不做网络环境配置的教程,具体可以去看其他文章
  • Cloudflare 账号:已将你的域名托管到 Cloudflare。使用 Cloudflare 做 dns-01 挑战
  • kubectl:已连接到集群。最基本的条件,保证k8s能正常访问
  • helm:推荐用 Helm 安装 cert-manager。使用helm安装,方便干净

安装

官方推荐用 Helm,这里我使用 1.18.2 的版本,在我这个时间点这个版本还是比较新的

安装 cert-manager

1# 安装 cert-manager CRDs
2kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.18.2/cert-manager.crds.yaml
1## Add the Jetstack Helm repository
2helm repo add jetstack https://charts.jetstack.io --force-update
1## Install the cert-manager helm chart
2helm install cert-manager --namespace cert-manager --version v1.18.2 jetstack/cert-manager

验证:

1kubectl get pods -n cert-manager

准备 Cloudflare API Token

  1. 登陆 Cloudflare Dashboard
  • My Profile → API Tokens → Create Token。
  1. 模板选:Edit zone DNS

  2. 权限:

  • Zone → DNS → Edit
  • Zone → Zone → Read
  1. Zone Resources: 选择需要签发证书的域名。

  2. 保存 token,例如:CF_API_TOKEN=xxxxxxxxxx

创建 Secret 存放 Token

1kubectl create secret generic cloudflare-api-token-secret \
2  --from-literal=api-token=CF_API_TOKEN \
3  -n cert-manager

配置 ClusterIssuer

cluster-issuer.yaml

 1apiVersion: cert-manager.io/v1
 2kind: ClusterIssuer
 3metadata:
 4  name: letsencrypt-dns
 5spec:
 6  acme:
 7    # 生产环境地址
 8    server: https://acme-v02.api.letsencrypt.org/directory
 9    email: your-email@example.com        # 接收过期提醒
10    privateKeySecretRef:
11      name: letsencrypt-dns-key
12    solvers:
13    - dns01:
14        cloudflare:
15          email: your-email@example.com  # 或留空(若使用 API token 可不填 email)
16          apiTokenSecretRef:
17            name: cloudflare-api-token-secret
18            key: api-token

部署yaml

1kubectl apply -f cluster-issuer.yaml

申请证书

在需要证书的命名空间下创建 Certificate 对象,例如 Nginx Ingress 的域名 example.com
certificate.yaml

 1apiVersion: cert-manager.io/v1
 2kind: Certificate
 3metadata:
 4  name: example-com
 5  namespace: default
 6spec:
 7  secretName: example-com-tls        # 生成的 secret 名称
 8  issuerRef:
 9    name: letsencrypt-dns
10    kind: ClusterIssuer
11  commonName: example.com
12  dnsNames:
13  - example.com
14  - "*.example.com"                   # 可选:通配符

部署yaml

1kubectl apply -f certificate.yaml

在 Ingress 中引用

 1apiVersion: networking.k8s.io/v1
 2kind: Ingress
 3metadata:
 4  name: example-ingress
 5  annotations:
 6    kubernetes.io/ingress.class: nginx
 7    cert-manager.io/cluster-issuer: letsencrypt-dns # 配置证书自动生成
 8spec:
 9  tls:
10  - hosts:
11    - example.com
12    secretName: example-com-tls #修改成自己要使用的tls名称会自动生成
13  rules:
14  - host: example.com
15    http:
16      paths:
17      - path: /
18        pathType: Prefix
19        backend:
20          service:
21            name: web
22            port:
23              number: 80

cert-manager 会在证书到期前约 30 天 自动续期。

查看状态

1kubectl describe certificate example-com -n default

复用证书

因为证书只能部署在制定的 namespace下,因此我写了一个脚本,把default命名空间下的 example-com-tls Secret复制到 argocdlonghorn-systemcattle-system 等多个命名空间。

 1#!/bin/bash
 2# 文件名:copy-example-cert.sh
 3# 作用:将 default 命名空间下的 example-com-tls Secret
 4#       复制到 argocd、longhorn-system、cattle-system
 5
 6SRC_NS="default"
 7SECRET_NAME="example-com-tls"
 8TARGET_NAMESPACES=("argocd" "longhorn-system" "cattle-system")
 9
10for ns in "${TARGET_NAMESPACES[@]}"; do
11  echo ">>> 正在复制到命名空间: $ns"
12  kubectl get secret "$SECRET_NAME" -n "$SRC_NS" -o yaml \
13    | sed "s/namespace: $SRC_NS/namespace: $ns/" \
14    | kubectl apply -f -
15done
16
17echo "✅ 复制完成"

执行

脚本会依次输出

1>>> 正在复制到命名空间: argocd
2secret/example-com-tls created
3>>> 正在复制到命名空间: longhorn-system
4secret/example-com-tls created
5>>> 正在复制到命名空间: cattle-system
6secret/example-com-tls created
7✅ 复制完成