<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Kubeadm on 维克的博客</title><link>https://blogs.wuvikr.top/tags/kubeadm/</link><description>Recent content in Kubeadm on 维克的博客</description><generator>Hugo</generator><language>en</language><lastBuildDate>Wed, 09 Sep 2026 10:54:51 +0800</lastBuildDate><atom:link href="https://blogs.wuvikr.top/tags/kubeadm/index.xml" rel="self" type="application/rss+xml"/><item><title>Kubeadm 部署高可用 K8s 集群</title><link>https://blogs.wuvikr.top/posts/kubeadm%E9%83%A8%E7%BD%B2%E9%AB%98%E5%8F%AF%E7%94%A8k8s%E9%9B%86%E7%BE%A4/</link><pubDate>Wed, 09 Sep 2026 10:54:51 +0800</pubDate><guid>https://blogs.wuvikr.top/posts/kubeadm%E9%83%A8%E7%BD%B2%E9%AB%98%E5%8F%AF%E7%94%A8k8s%E9%9B%86%E7%BE%A4/</guid><description>&lt;p>&lt;a href="https://kubernetes.io/zh/docs/setup/production-environment/tools/kubeadm/">kubeadm 安装官方文档&lt;/a>&lt;/p>
&lt;h1 id="0-引言">0. 引言&lt;/h1>
&lt;p>Kubernetes 高可用架构的核心在于保障 API Server 的访问连续性与 etcd 的数据可靠性。通常通过部署多 Master 节点并前置负载均衡来实现，本方案采用 &lt;code>kube-vip&lt;/code> 承担此角色。为节省资源，本文将负载均衡与 etcd 集群复用部署于 Master 节点；&lt;strong>生产环境请务必将其独立部署，以确保集群稳定性。&lt;/strong>&lt;/p>
&lt;p>本文基于 Ubuntu 24.04 环境编写。若使用其他 Linux 发行版，请根据实际情况自行调整相关命令。&lt;/p>
&lt;hr>
&lt;h1 id="1-环境架构">1. 环境架构&lt;/h1>
&lt;h2 id="11-角色划分">1.1 角色划分&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>主机名&lt;/th>
&lt;th style="text-align: center">IP&lt;/th>
&lt;th style="text-align: center">角色&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>master01&lt;/td>
&lt;td style="text-align: center">192.168.69.11&lt;/td>
&lt;td style="text-align: center">master01、Etcd-node01、kube-vip 节点&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>master02&lt;/td>
&lt;td style="text-align: center">192.168.69.12&lt;/td>
&lt;td style="text-align: center">master02、Etcd-node02、kube-vip 节点&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>master03&lt;/td>
&lt;td style="text-align: center">192.168.69.13&lt;/td>
&lt;td style="text-align: center">master03、Etcd-node03、kube-vip 节点&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>worker01&lt;/td>
&lt;td style="text-align: center">192.168.69.21&lt;/td>
&lt;td style="text-align: center">worker01&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>worker02&lt;/td>
&lt;td style="text-align: center">192.168.69.22&lt;/td>
&lt;td style="text-align: center">worker02&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>worker03&lt;/td>
&lt;td style="text-align: center">192.168.69.23&lt;/td>
&lt;td style="text-align: center">worker03&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>虚拟IP&lt;/td>
&lt;td style="text-align: center">10.0.0.100&lt;/td>
&lt;td style="text-align: center">kube-vip 提供&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="12-拓扑图">1.2 拓扑图&lt;/h2>
&lt;p>&lt;img alt="k8s集群架构拓扑" loading="lazy" src="https://blogs.wuvikr.top/posts/kubeadm%E9%83%A8%E7%BD%B2%E9%AB%98%E5%8F%AF%E7%94%A8k8s%E9%9B%86%E7%BE%A4/%E6%8B%93%E6%89%91%E5%9B%BE.png">&lt;/p>
&lt;hr>
&lt;h1 id="2-操作系统初始化">2. 操作系统初始化&lt;/h1>
&lt;h2 id="21-linux-基础配置">2.1 Linux 基础配置&lt;/h2>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># 关闭防火墙&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ufw disable
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># 关闭 swap&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>swapoff -a &lt;span style="color:#f92672">&amp;amp;&amp;amp;&lt;/span> sysctl -w vm.swappiness&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#ae81ff">0&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sed -ri &lt;span style="color:#e6db74">&amp;#39;s/.*swap.*/#&amp;amp;/&amp;#39;&lt;/span> /etc/fstab
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># 配置主机名和 hosts&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>hostnamectl set-hostname &amp;lt;hostname&amp;gt;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>cat &amp;gt;&amp;gt; /etc/hosts &lt;span style="color:#e6db74">&amp;lt;&amp;lt; EOF
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">192.168.69.11 master01.wuvikr.top master01
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">192.168.69.12 master02.wuvikr.top master02
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">192.168.69.13 master03.wuvikr.top master03
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">192.168.69.21 worker01.wuvikr.top worker01
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">192.168.69.22 worker02.wuvikr.top worker02
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">192.168.69.23 worker03.wuvikr.top worker03
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">192.168.69.100 kubeapi.wuvikr.top kubeapi
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">EOF&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># 配置 limit&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>ulimit -SHn &lt;span style="color:#ae81ff">65535&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># 持久化 limit 配置（重新登录后生效）&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>cat &amp;gt;&amp;gt; /etc/security/limits.conf &lt;span style="color:#e6db74">&amp;lt;&amp;lt; EOF
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">* soft nofile 65536
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">* hard nofile 131072
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">* soft nproc 65535
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">* hard nproc 655350
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">* soft memlock unlimited
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">* hard memlock unlimited
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">* soft core unlimited
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">* hard core unlimited
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#e6db74">EOF&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="22-时间同步">2.2 时间同步&lt;/h2>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># 同步硬件时钟到系统时间（虚拟机环境中可选）&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>hwclock -s
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># 设置时区（推荐方式，一步完成）&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>timedatectl set-timezone Asia/Shanghai
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># 确保时间同步服务已启用（Ubuntu 24.04 默认已启用）&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>systemctl enable --now systemd-timesyncd
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e"># 查看时间同步状态&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>timedatectl status
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>
&lt;blockquote>
&lt;p>Ubuntu 24.04 内置的 &lt;code>systemd-timesyncd&lt;/code> 提供轻量级 NTP 客户端功能，支持自动同步、漂移补偿和状态查询。如需更高精度的时间同步（如金融、日志审计场景），建议改用 &lt;code>chrony&lt;/code> 替代 &lt;code>systemd-timesyncd&lt;/code>。&lt;/p></description></item></channel></rss>