<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Frytea's Blog]]></title><description><![CDATA[对月吟诗，煮雪烹茶。]]></description><link>https://blog.frytea.com</link><image><url>https://blog.frytea.com/innei.svg</url><title>Frytea&apos;s Blog</title><link>https://blog.frytea.com</link></image><generator>Shiro (https://github.com/Innei/Shiro)</generator><lastBuildDate>Mon, 09 Mar 2026 03:10:27 GMT</lastBuildDate><atom:link href="https://blog.frytea.com/feed" rel="self" type="application/rss+xml"/><pubDate>Mon, 09 Mar 2026 03:10:27 GMT</pubDate><language><![CDATA[zh-CN]]></language><item><title><![CDATA[过年后的 KDE Plasma 更新]]></title><description><![CDATA[<link rel="preload" as="image" href="https://i-cdn.frytea.com/images/mix/8uubyineezeqpgxn0u.png"/><div><blockquote>该渲染由 Shiro API 生成，可能存在排版问题，最佳体验请前往：<a href="https://blog.frytea.com/notes/3">https://blog.frytea.com/notes/3</a></blockquote><div><p>过年回来，执行 <code>pacman -Syu</code> 看到 KDE 又更新了：
<img src="https://i-cdn.frytea.com/images/mix/8uubyineezeqpgxn0u.png" height="2071" width="3457"/></p><p>每次看到 Plasma 更新，都很开心。</p></div><p style="text-align:right"><a href="https://blog.frytea.com/notes/3#comments">看完了？说点什么呢</a></p></div>]]></description><link>https://blog.frytea.com/notes/3</link><guid isPermaLink="true">https://blog.frytea.com/notes/3</guid><dc:creator><![CDATA[tl.s]]></dc:creator><pubDate>Wed, 25 Feb 2026 06:58:36 GMT</pubDate></item><item><title><![CDATA[终于完成 Typecho 到 Mix-Space 的数据迁移]]></title><description><![CDATA[<link rel="preload" as="image" href="https://i-cdn.frytea.com/images/mix/f6kakha91bzla4cm6o.png"/><div><blockquote>该渲染由 Shiro API 生成，可能存在排版问题，最佳体验请前往：<a href="https://blog.frytea.com/notes/2">https://blog.frytea.com/notes/2</a></blockquote><div><p>终于把 typecho 的所有数据都完整的搬运到 mix-space 中了！！！
<img src="https://i-cdn.frytea.com/images/mix/f6kakha91bzla4cm6o.png" height="1828" width="3106"/></p><p>包括所有博客、页面、评论。</p><p>最近就慢慢看一看数据是否正确，然后再考虑一下如何将 url 重定向。</p><p>只需要用我开源的 export-typecho-to-x 工具，两个命令完成迁移：</p><pre class=""><code class="">npm run dev -- mxspace-api
npm run dev -- mxspace-comments
</code></pre>
<p>太不容易了！！！</p><p>对了，还有友链。慢慢搬吧。</p></div><p style="text-align:right"><a href="https://blog.frytea.com/notes/2#comments">看完了？说点什么呢</a></p></div>]]></description><link>https://blog.frytea.com/notes/2</link><guid isPermaLink="true">https://blog.frytea.com/notes/2</guid><dc:creator><![CDATA[tl.s]]></dc:creator><pubDate>Sun, 22 Feb 2026 19:02:32 GMT</pubDate></item><item><title><![CDATA[赞一下 Innel 佬的 MixSpace]]></title><description><![CDATA[<div><blockquote>该渲染由 Shiro API 生成，可能存在排版问题，最佳体验请前往：<a href="https://blog.frytea.com/notes/1">https://blog.frytea.com/notes/1</a></blockquote><span>赞一下 Innel 佬的 MixSpace ，似乎就是我想要的那种样子</span><p style="text-align:right"><a href="https://blog.frytea.com/notes/1#comments">看完了？说点什么呢</a></p></div>]]></description><link>https://blog.frytea.com/notes/1</link><guid isPermaLink="true">https://blog.frytea.com/notes/1</guid><dc:creator><![CDATA[tl.s]]></dc:creator><pubDate>Mon, 16 Feb 2026 02:40:41 GMT</pubDate></item><item><title><![CDATA[终极指南：在 Linux 裸机服务器上快速部署 Moltbot (原 Clawbot) 并集成飞书]]></title><description><![CDATA[<link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/f488b1f3d943c7babe21254f3c7a54c4.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/52241de099467f7e847ff87b28bf35c9.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/895f4686b7ae7236b27b3d32d5801697.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/3a1b41424787b665bcdb3bbc1fa5fd44.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/33f3080bc554ed14872389433ecf18bf.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/99f7f6a55434f3bf0c7490d049905249.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/a258aa6f09e27c7bd5b6d15002b4ba3b.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/ec6ce4a787b89fd31f77218cd14db1c8.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/f56ca72cfb362bdf3f11c42cbce0ee9e.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/94781257ec10c1275e94c0e4ba4d7964.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/4d7284ec3729fb9b0a24925c3e2cfb20.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/bc8ffa2cf8f65c672d7e9d226da081d3.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/a85365748113bfddc6c564679c0a55a1.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/1cbdf9a5b14056815d3f65361c8b30a9.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/4d23fd3bedf64a03fff4a382647adc4f.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/9a879e159a75751823aadf551433119c.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/4fc7d9b519da4704bdcc1d365a61fd0d.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/4d61d26d14a8b4be49e27637cb538f45.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/dbd3931e740f27cd22b4b96922681ef6.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/045edd82218016ae06b61cde8dddc7cf.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/70263421e06d6479a45743b5ff815c04.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/4c171f081ec920189c1439fb55d2b0e6.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/9c4f90a3fe1e8d1b2502a87d4112b3ed.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/0c807890baa1d0d2d79287b2ebf31628.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/29/1060a0f84529d0f74f785bee088e0929.png"/><div><blockquote>该渲染由 Shiro API 生成，可能存在排版问题，最佳体验请前往：<a href="https://blog.frytea.com/posts/note/1617">https://blog.frytea.com/posts/note/1617</a></blockquote><div><h2 id="">引言</h2><p>2026 年初，一个名为 Moltbot（前身为 Clawbot）的开源 AI 代理（Agent）框架席卷了开发者社区。该框架允许用户将强大的 AI 模型（例如 OpenAI 的 GPT 系列、Anthropic 的 Claude 等）与 WhatsApp、Telegram、Discord 等日常通讯工具集成，从而通过聊天即可操控电脑、执行任务、获取信息。特斯拉前 AI 主管 Andrej Karpathy 的推荐更是使其迅速走红，其 GitHub 项目在短时间内获得了超过 60,000 个星标。</p><p>本指南将提供一份以安全为核心的详尽教程，旨在引导您逐步在 Linux 裸机服务器上安全地完成 Moltbot 的部署。</p><h2 id="">准备工作</h2><p>在开始之前，请确保你已具备以下条件：</p><table><thead><tr><th style="text-align:left"> 项目              </th><th style="text-align:left"> 要求                     </th><th style="text-align:left"> 说明                           </th></tr></thead><tbody><tr><td style="text-align:left"> <strong>Linux 服务器</strong>   </td><td style="text-align:left"> Ubuntu 22.04+ 或其他现代发行版 </td><td style="text-align:left"> 推荐至少 2GB RAM 和 2 核 CPU。      </td></tr><tr><td style="text-align:left"> <strong>基础 Linux 知识</strong> </td><td style="text-align:left"> 熟悉 SSH、命令行操作           </td><td style="text-align:left"> 本教程将提供所有需要的命令。               </td></tr></tbody></table><h2 id="">第一步：准备服务器环境</h2><p>基于安全最佳实践，我们强烈建议不要直接使用 <code>root</code> 用户运行任何应用程序。因此，第一步是创建一个专用的非特权用户，并为其授予 <code>sudo</code> 权限。</p><ol start="1"><li><strong>以 <code>root</code> 用户 SSH 登录你的服务器</strong>：</li></ol><pre class="language-bash lang-bash"><code class="language-bash lang-bash">ssh root@your_server_ip
</code></pre>
<ol start="2"><li><strong>创建一个新用户</strong>（我们称之为 <code>moltbot</code>）：</li></ol><pre class="language-bash lang-bash"><code class="language-bash lang-bash">adduser moltbot
</code></pre>
<p>系统会提示你为新用户设置密码和其他信息。</p><ol start="3"><li><strong>将新用户添加到 <code>sudo</code> 组</strong>，以便执行需要管理员权限的操作：</li></ol><pre class="language-bash lang-bash"><code class="language-bash lang-bash">usermod -aG sudo moltbot
</code></pre>
<ol start="4"><li><strong>切换到新用户</strong>：</li></ol><pre class="language-bash lang-bash"><code class="language-bash lang-bash">su - moltbot
</code></pre>
<ol start="5"><li><strong>更新系统软件包</strong>：</li></ol><pre class="language-bash lang-bash"><code class="language-bash lang-bash">sudo apt update &amp;&amp; sudo apt upgrade -y
</code></pre>
<p>此后，所有操作都应在该 <code>moltbot</code> 用户下进行。</p><h2 id="-moltbot">第二步：安装 Moltbot</h2><p>Moltbot 的核心依赖是 Node.js (版本 ≥ 22)。官方提供了一个便捷的<a href="https://www.molt.bot/">一键安装脚本</a>，可自动处理相关依赖并完成 Moltbot 的安装。</p><ol start="1"><li><strong>执行官方安装脚本</strong>：</li></ol><pre class="language-bash lang-bash"><code class="language-bash lang-bash">curl -fsSL https://molt.bot/install.sh | bash
</code></pre>
<p>该脚本会自动检测您的操作系统，安装适配的 Node.js 版本，并部署 Moltbot 命令行工具（CLI）。</p><p>安装成功后，将自动进入交互式配置流程，如下图所示：</p><p><img src="https://i-cdn.frytea.com/2026/01/29/f488b1f3d943c7babe21254f3c7a54c4.png" alt="图片" height="1272" width="1907"/></p><p>第一个选项是风险提示，输入 <code>yes</code> 确认已知晓。</p><p>第二步在模式选择中，建议选择 <code>QuickStart</code> 以进行快速配置。</p><h2 id="-qwen">第三步：配置使用 Qwen</h2><p>在选择模型服务商时，本教程以阿里云的 <code>Qwen</code>（通义千问）为例，其提供充足的免费额度，非常适合初学者入门。待您熟悉系统后，可根据需求更换为其他模型。</p><p><img src="https://i-cdn.frytea.com/2026/01/29/52241de099467f7e847ff87b28bf35c9.png"/></p><p>选择 Qwen 模型后，终端会提供一个授权链接，请复制并在浏览器中打开。</p><p><img src="https://i-cdn.frytea.com/2026/01/29/895f4686b7ae7236b27b3d32d5801697.png"/></p><p>打开链接后，您会看到授权页面。如果您尚未登录阿里云账户，请根据提示完成登录。</p><p><img src="https://i-cdn.frytea.com/2026/01/29/3a1b41424787b665bcdb3bbc1fa5fd44.png"/></p><p>登录成功后，系统会提示您选择具体的 Qwen 模型版本。</p><p><img src="https://i-cdn.frytea.com/2026/01/29/33f3080bc554ed14872389433ecf18bf.png"/></p><p>此处选择默认模型即可。随后，安装向导会询问是否配置频道（Channel），建议暂时跳过，后续再进行配置。</p><p><img src="https://i-cdn.frytea.com/2026/01/29/99f7f6a55434f3bf0c7490d049905249.png"/></p><p>接着，在技能（Skills）配置步骤中，同样选择 No。</p><p><img src="https://i-cdn.frytea.com/2026/01/29/a258aa6f09e27c7bd5b6d15002b4ba3b.png"/></p><p>等待安装流程结束，在最后的启动方式选择中，选择 <code>TUI</code>（文本用户界面）。</p><p><img src="https://i-cdn.frytea.com/2026/01/29/ec6ce4a787b89fd31f77218cd14db1c8.png"/></p><p>如果成功进入 <code>TUI</code> 聊天界面，说明 Moltbot 已正确安装。您可以输入 <code>Hello</code> 进行初步测试。</p><p><img src="https://i-cdn.frytea.com/2026/01/29/f56ca72cfb362bdf3f11c42cbce0ee9e.png"/></p><p>测试无误后，使用 <code>Ctrl+C</code> 组合键退出 TUI 界面，以便进行后续的后台服务配置。</p><h2 id="-moltbot--gateway">第四步：配置 Moltbot 并启动 Gateway</h2><ol start="1"><li><strong>检查 Gateway 服务状态</strong>：</li></ol><p>安装向导会自动将 Gateway 配置为系统服务并在后台启动。</p><pre class="language-bash lang-bash"><code class="language-bash lang-bash">clawdbot gateway status
</code></pre>
<p>如果服务正常运行，您将看到 <code>active (running)</code> 的状态提示。</p><p><img src="https://i-cdn.frytea.com/2026/01/29/94781257ec10c1275e94c0e4ba4d7964.png" alt="服务状态"/></p><p>如果检查状态时发现服务异常（例如 <code>inactive</code> 或 <code>failed</code>），可以尝试使用内置的诊断工具进行修复：</p><pre class=""><code class="">clawdbot doctor --repair
</code></pre>
<p>修复后，再次检查状态，应可看到服务已恢复正常。</p><p><img src="https://i-cdn.frytea.com/2026/01/29/4d7284ec3729fb9b0a24925c3e2cfb20.png" alt="服务状态"/></p>
<ol start="3"><li><strong>配置选项</strong>：</li></ol><p>您可以根据需要编辑 Moltbot 的主配置文件。</p><p>使用文本编辑器（如 <code>vim</code> 或 <code>nano</code>）打开配置文件：</p><pre class="language-bash lang-bash"><code class="language-bash lang-bash">sudo vim ~/.clawdbot/clawdbot.json
</code></pre>
<ol start="4"><li><strong>重载并重启服务</strong>：</li></ol><p>每次修改配置文件后，需要重载服务以使更改生效。虽然某些版本的 Moltbot 支持自动重载，但手动重启是更可靠的方式。</p><pre class="language-bash lang-bash"><code class="language-bash lang-bash">systemctl --user daemon-reload
clawdbot gateway restart
</code></pre>
<p>至此，Moltbot Gateway 已在后台稳定运行，并监听本地端口，等待连接。</p><h2 id="">第五步：访问后台</h2><p>Moltbot 自带一个 Web UI 用于管理和测试。运行以下命令可获取访问方式：</p><pre class=""><code class="">clawdbot dashboard
</code></pre>
<p>命令会输出一段 SSH 端口转发指令，格式如下：</p><p><img src="https://i-cdn.frytea.com/2026/01/29/bc8ffa2cf8f65c672d7e9d226da081d3.png" alt="后台访问方法"/></p><p>在您的本地电脑（而非服务器）上打开一个终端，并执行上述 SSH 命令。该命令会将服务器的 Web UI 端口 <code>18789</code> 映射到您本地的同名端口。</p><pre class=""><code class="">ssh -N -L 18789:127.0.0.1:18789 xxx@xxx.xxx.xxx.xxx -p xxx
</code></pre>
<p>命令运行后，在本地浏览器访问 <a href="http://127.0.0.1:18789">http://127.0.0.1:18789</a> 即可打开 Web UI 。</p><p>您可以发送一条 <code>Hello</code> 消息进行测试，如果收到回复，则说明一切正常。</p><p><img src="https://i-cdn.frytea.com/2026/01/29/a85365748113bfddc6c564679c0a55a1.png" alt="后台界面"/></p><h2 id="">第六步：接入飞书</h2><p>首先，在服务器上为 Moltbot 安装飞书插件：</p><pre class=""><code class="">clawdbot plugins install @m1heng-clawd/feishu
</code></pre>
<p>接下来，登录<a href="https://open.feishu.cn">飞书开放平台</a>，进入「开发者后台」，点击「创建企业自建应用」。</p><p><img src="https://i-cdn.frytea.com/2026/01/29/1cbdf9a5b14056815d3f65361c8b30a9.png"/></p><p>填写应用名称和描述后，完成创建。</p><p><img src="https://i-cdn.frytea.com/2026/01/29/4d23fd3bedf64a03fff4a382647adc4f.png"/></p><p>创建成功后，进入应用的「凭据与基础信息」页面，复制并妥善保存 App ID 和 App Secret，它们将在后续配置中用到。</p><p><img src="https://i-cdn.frytea.com/2026/01/29/9a879e159a75751823aadf551433119c.png"/></p><p>然后添加机器人，如下操作</p><p><img src="https://i-cdn.frytea.com/2026/01/29/4fc7d9b519da4704bdcc1d365a61fd0d.png"/></p><p>暂时停留在飞书后台，我们先返回服务器终端，完成 Moltbot 的飞书相关配置。</p><p><img src="https://i-cdn.frytea.com/2026/01/29/4d61d26d14a8b4be49e27637cb538f45.png"/></p><p>飞书的其他配置先暂停，回到服务器配置 Clawdbot 的飞书参数</p><h3 id="">添加飞书配置</h3><pre class=""><code class="">clawdbot config set channels.feishu.appId &quot;飞书 app id&quot;

clawdbot config set channels.feishu.appSecret &quot;飞书 app secret&quot;

clawdbot config set channels.feishu.enabled true

# 推荐使用 websocket
clawdbot config set channels.feishu.connectionMode websocket

clawdbot config set channels.feishu.dmPolicy pairing

clawdbot config set channels.feishu.groupPolicy allowlist

clawdbot config set channels.feishu.requireMention true
</code></pre>
<p>配置完成之后，重启</p><pre class=""><code class="">clawdbot gateway restart
</code></pre>
<p>重启完成后回到飞书，找到「事件和回调」，选择长连接模式，如下图</p><p><img src="https://i-cdn.frytea.com/2026/01/29/dbd3931e740f27cd22b4b96922681ef6.png"/></p><p>如果配置成功，说明连接已建立。继续下面的配置，添加事件，选择「接收消息」事件</p><p><img src="https://i-cdn.frytea.com/2026/01/29/045edd82218016ae06b61cde8dddc7cf.png"/></p><p>事件添加完成之后，还需要开通权限，有以下权限全部勾选</p><table><thead><tr><th>权限</th><th>Scope（范围）</th><th>Description（说明）</th></tr></thead><tbody><tr><td>contact:user.base:readonly</td><td>用户信息</td><td>获取基础用户信息</td></tr><tr><td>im:message</td><td>消息 全部勾选</td><td>发送和接收消息</td></tr></tbody></table><p>如下图</p><p><img src="https://i-cdn.frytea.com/2026/01/29/70263421e06d6479a45743b5ff815c04.png"/></p><p><img src="https://i-cdn.frytea.com/2026/01/29/4c171f081ec920189c1439fb55d2b0e6.png"/></p><p>以上步骤全部完成后，即可与机器人对话。但在此之前需要先创建一个版本</p><p><img src="https://i-cdn.frytea.com/2026/01/29/9c4f90a3fe1e8d1b2502a87d4112b3ed.png"/></p><blockquote><p>注意：每次修改配置后都需要重新发布版本，建议全部配置完成后再统一发布。</p></blockquote>
<p>发布完成后，回到飞书客户端，可以看到应用已上线，点击打开应用</p><p><img src="https://i-cdn.frytea.com/2026/01/29/0c807890baa1d0d2d79287b2ebf31628.png"/></p><p>向机器人发送 <code>Hello</code>，即可收到 Moltbot 的回复</p><p><img src="https://i-cdn.frytea.com/2026/01/29/1060a0f84529d0f74f785bee088e0929.png"/></p><p>恭喜您！至此，您已成功在 Linux 服务器上部署了 Moltbot，并将其与飞书集成。现在您可以开始探索其强大的功能，或根据官方文档进行更深度的定制。如果在部署过程中遇到任何问题，欢迎留言交流。</p><h2 id="">常用命令</h2><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 检查常见安全问题
clawdbot security audit

# 自动修复文件权限等问题
clawdbot security audit --fix

# 查看 Moltbot 日志
clawdbot logs --follow
</code></pre>
<h2 id="">参考文献</h2><ul><li><a href="https://www.cnblogs.com/catchadmin/p/19545341">Clawdbot 飞书对接教程 手把手搭建你的专属 AI 助手</a></li><li><a href="https://docs.molt.bot/">https://docs.molt.bot/</a></li><li><a href="https://www.cnblogs.com/sing1ee/p/19541451/2026-moltbot-complete-guide">Moltbot: 2026年终极个人AI助手完整指南 - sing1ee - 博客园</a></li><li><a href="https://www.bleepingcomputer.com/news/security/viral-moltbot-ai-assistant-raises-concerns-over-data-security/">Viral Moltbot AI assistant raises concerns over data security - BleepingComputer</a></li><li><a href="https://www.digitalocean.com/community/tutorials/moltbot-quickstart-guide">Moltbot Quickstart Guide - DigitalOcean</a></li><li><a href="https://docs.molt.bot/gateway/security">Security - Moltbot Documentation</a></li><li><a href="https://caddyserver.com/docs/install">Installing Caddy — Caddy Documentation</a></li></ul></div><p style="text-align:right"><a href="https://blog.frytea.com/posts/note/1617#comments">看完了？说点什么呢</a></p></div>]]></description><link>https://blog.frytea.com/posts/note/1617</link><guid isPermaLink="true">https://blog.frytea.com/posts/note/1617</guid><dc:creator><![CDATA[tl.s]]></dc:creator><pubDate>Thu, 29 Jan 2026 12:00:15 GMT</pubDate></item><item><title><![CDATA[Windows 配置 Claude Code 解决  settings.json 不生效]]></title><description><![CDATA[<div><blockquote>该渲染由 Shiro API 生成，可能存在排版问题，最佳体验请前往：<a href="https://blog.frytea.com/posts/note/1616">https://blog.frytea.com/posts/note/1616</a></blockquote><div><h1 id="tldr">TL;DR</h1><p>默认情况下 Windows 安装的 <code>Claude Code</code> 会从这个位置读取配置：</p><pre class=""><code class="">C:\Users\&lt;YOUR_NAME&gt;\.claude
</code></pre>
<p>其他系统则类似的找到 <code>~/.claude</code> 路径。</p><p>官方流程在安装结束后就完成了，可以直接登录使用。如果需要修改配置将 <code>Claude Code</code> 接入第三方 API，就需要修改这里的 <code>settings.json</code> 配置文件，可以使用 <code>CC-Switch</code> 或是手动编写，但是修改后会发现不生效。</p><p>经过调研，发现是最新版的 <code>Claude Code</code> 修改了一个参数，导致启动时一定要登录，这里可以手动修改一下 <code>C:\Users&lt;YOUR_NAME&gt;.claude.json</code> 中的这个参数，即可正常使用：</p><pre class=""><code class="">hasCompletedOnboarding: true
</code></pre>
<p>将配置中的 <code>false</code> 改为 <code>true</code> ，再重新运行 <code>Claude Code</code> 即可。</p><blockquote><p>这个问题卡了我两天，一度打算放弃回到其他 OS，最后终于在 <a href="https://github.com/farion1231/cc-switch/issues/404#issuecomment-3677768452">这里</a> 找到了答案，因此特别记录一下。</p></blockquote>
<h1 id="refs">Refs</h1><ul><li><a href="https://linux.do/t/topic/803265">《 Claude Code 终极版 FAQ 指南 》</a></li><li><a href="https://linux.do/t/topic/1422264">Windows 用 Claude Code 的最优解是 WSL 吗？</a></li><li><a href="https://linux.do/t/topic/1327596">请问一下claude code windows版本claude.exe是否settings.json不生效？</a></li><li><a href="https://github.com/farion1231/cc-switch/issues/404#issuecomment-3677768452">配置好 setting.json 文件之后，Claude任然要求登录？怎么办？ #404</a></li></ul></div><p style="text-align:right"><a href="https://blog.frytea.com/posts/note/1616#comments">看完了？说点什么呢</a></p></div>]]></description><link>https://blog.frytea.com/posts/note/1616</link><guid isPermaLink="true">https://blog.frytea.com/posts/note/1616</guid><dc:creator><![CDATA[tl.s]]></dc:creator><pubDate>Fri, 09 Jan 2026 08:28:00 GMT</pubDate></item><item><title><![CDATA[Windows 配置 Claude Code 全流程]]></title><description><![CDATA[<link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/09/91c1609863157459c6db4b95273c0760.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/09/46235f95b032b51632eac7927155d25a.png"/><div><blockquote>该渲染由 Shiro API 生成，可能存在排版问题，最佳体验请前往：<a href="https://blog.frytea.com/posts/note/1615">https://blog.frytea.com/posts/note/1615</a></blockquote><div><p>今天终于跑通了 Windows 下运行 Claoude Code 的全流程，不借助 WSL ，原生运行。起因是自己需要一个可以长期运行任务的云桌面，这方面还是 Windows 最好用。不得不说相比于 <code>Linux/macOS</code> ，<code>Windows</code> 下运行 <code>Claude Code</code> 实在太多坑了。</p><p>感谢 LD 巨佬 <a href="https://linux.do/u/haleclipse">哈雷彗星</a> 的 <a href="https://linux.do/t/topic/803265/434">《 Claude Code 终极版 FAQ 指南 》</a> ，在这份指南的指导下,还有开源社区朋友的帮助下，终于跑通了全流程，在这里记录一下，避免更多的朋友踩坑。</p><p><img src="https://i-cdn.frytea.com/2026/01/09/91c1609863157459c6db4b95273c0760.png" alt="ClaudeCode" height="1080" width="1920"/></p><h1 id="">环境说明</h1><p>先说一下我的环境：</p><ul><li>OS: <code>Windows 10 Enterprise LTSC 2021</code></li><li>Shell: <code>PowerShell 5</code> <code>-&gt;</code> <code>PowerShell 7</code></li></ul><p>我是在全新安装的 <code>Windows 10 Enterprise LTSC 2021</code> 系统中进行，使用系统自带的 <code>PowerShell 5</code> 开始 ，流程中会安装最新的 <code>PoserShell 7</code> 并使用 PS7 完成后续。根据论坛大佬的说法，<code>PS7</code> 很好用，自带的 <code>PS5</code> 不好用，因此下面的流程包含了安装 <code>PS7</code> 的流程，大家可以自己体验一下。</p><h1 id="">主要流程</h1><blockquote><p>以下内容主要来自  <a href="https://linux.do/t/topic/803265/434">《 Claude Code 终极版 FAQ 指南 》</a> 和实践补充。</p></blockquote>
<p>打开 <code>PowerShell 5</code> 并安装 <code>WinGet</code>:</p><pre class="language-powershell lang-powershell"><code class="language-powershell lang-powershell">$progressPreference = &#x27;silentlyContinue&#x27;
Install-PackageProvider -Name NuGet -Force | Out-Null
Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery | Out-Null
Write-Host &quot;Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet...&quot;
Repair-WinGetPackageManager -AllUsers
</code></pre>
<p>在 <code>PoserShell 5</code> 中使用 <code>WinGet</code> 安装 <code>PoserShell 7</code></p><pre class="language-powershell lang-powershell"><code class="language-powershell lang-powershell">winget install Microsoft.PowerShell
</code></pre>
<p>打开 <code>PoserShell 7</code> 并使用 <code>winget</code> 安装其他依赖，后续全部在 <code>PS7</code> 中进行：</p><pre class="language-powershell lang-powershell"><code class="language-powershell lang-powershell">
# 必须，安装 fnm 用于管理 node 环境，或使用现有环境
winget install Schniz.fnm
# 可选，安装 Git
winget install --id Git.Git -e --source winget
# 可选，安装 notepad4
winget install zufuliu.notepad4
# 可选，安装 Windows Terminal
winget install -e --id Microsoft.WindowsTerminal
# 可选，安装 Notepad++
winget install -e --id Notepad++.Notepad++
</code></pre>
<p>下面使用 <code>fnm</code> 安装特定版本的 <code>node</code> 运行环境，首先需要对 <code>FNM</code> 给予一个环境启动，否则安装的 <code>node</code> 无法使用，因此首先预配置环境：</p><pre class=""><code class="">New-Item –Path $Profile –Type File –Force
notepad $profile
</code></pre>
<p>之后将以下内容写入该文件并保存：</p><pre class=""><code class="">fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression
</code></pre>
<p>下面开始正式安装 <code>nodejs</code>:</p><pre class="language-powershell lang-powershell"><code class="language-powershell lang-powershell">fnm install lts/krypton
fnm use lts/krypton
</code></pre>
<p>全局安装 <code>Claude Code</code>:</p><pre class="language-powershell lang-powershell"><code class="language-powershell lang-powershell">npm install -g @anthropic-ai/claude-code
</code></pre>
<p>之后就可以愉快的使用 <code>Claude Code</code> 了。</p><p><img src="https://i-cdn.frytea.com/2026/01/09/46235f95b032b51632eac7927155d25a.png" alt="Claude Code  在 Windows PowerShell7 运行"/></p><h1 id="">常见问题</h1><h2 id="-settingsjson-">配置 <code>settings.json</code> 不生效</h2><p>默认情况下这样安装的 <code>Claude Code</code> 会从这个位置读取配置：</p><pre class=""><code class="">C:\Users\&lt;YOUR_NAME&gt;\.claude
</code></pre>
<p>官方流程在安装结束后就完成了，可以直接登录使用。如果你需要修改配置将 <code>Claude Code</code> 接入第三方 API，就需要修改这里的 <code>settings.json</code> 配置文件，可以使用 <code>CC-Switch</code> 或是手动编写，但是修改后会发现不生效。</p><p>经过调研，发现是最新版的 <code>Claude Code</code> 修改了一个参数，导致启动时一定要登录，这里可以手动修改一下 <code>C:\Users&lt;YOUR_NAME&gt;.claude.json</code> 中的这个参数，即可正常使用：</p><pre class=""><code class="">hasCompletedOnboarding: true
</code></pre>
<p>将配置中的 <code>false</code> 改为 <code>true</code> ，再重新运行 <code>Claude Code</code> 即可。</p><blockquote><p>这个问题卡了我两天，一度打算放弃回到其他 OS，最后终于在 <a href="https://github.com/farion1231/cc-switch/issues/404#issuecomment-3677768452">这里</a> 找到了答案，因此特别记录一下。</p></blockquote>
<h1 id="refs">Refs</h1><ul><li><a href="https://linux.do/t/topic/803265">《 Claude Code 终极版 FAQ 指南 》</a></li><li><a href="https://linux.do/t/topic/1422264">Windows 用 Claude Code 的最优解是 WSL 吗？</a></li><li><a href="https://linux.do/t/topic/1327596">请问一下claude code windows版本claude.exe是否settings.json不生效？</a></li><li><a href="https://github.com/farion1231/cc-switch/issues/404#issuecomment-3677768452">配置好 setting.json 文件之后，Claude任然要求登录？怎么办？ #404</a></li></ul></div><p style="text-align:right"><a href="https://blog.frytea.com/posts/note/1615#comments">看完了？说点什么呢</a></p></div>]]></description><link>https://blog.frytea.com/posts/note/1615</link><guid isPermaLink="true">https://blog.frytea.com/posts/note/1615</guid><dc:creator><![CDATA[tl.s]]></dc:creator><pubDate>Fri, 09 Jan 2026 08:22:00 GMT</pubDate></item><item><title><![CDATA[2025-12-31 ｜ 年终总结]]></title><description><![CDATA[<link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/01/720e6785096e33a225ad5b4d6234795c.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/01/98154260829d03f4e00d98043c9d0697.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/01/ea1d621d4d3cab07215eb099b950f955.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/01/7c6b674be3f6c2e21d174cc088bd1d57.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/01/ef9ab8a9b358b71598038d6466ed615c.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/01/5d709498634763fdb1ad58f91b751d04.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/01/7150bf5b58f89bdcc7f609be42a5441e.png"/><link rel="preload" as="image" href="https://i-cdn.frytea.com/2026/01/01/c4c985804c2b71fe1246ca3560b2f807.png"/><div><blockquote>该渲染由 Shiro API 生成，可能存在排版问题，最佳体验请前往：<a href="https://blog.frytea.com/posts/life/1614">https://blog.frytea.com/posts/life/1614</a></blockquote><div><p>2025 年就这样过去了，做了很多事情，发生了很多事情，是转折的一年，是难忘的一年，是值得回味的一年。</p><p>这一年，生活轨迹发生了很堵变化，思想认识也发生了很多转变，突然要写年终总结，真不知道从何说起。就想到哪里说到哪里吧。</p><p>2025 年探索了巨多的事情。这一年是 AI 继续井喷式发展的一年，是各行各业不断变革的一年。年初的时候 AI Agent 成为各家媒体预言本年度的最热词。年底 Manus 被 Meta 收购，或许是 AI Agent 的高光时刻吧。与此同时 AI Agent 似乎正在深刻的改变各行各业。</p><p>就我个人而言，在不断的探索，可或许是眼界和能力还有限，能做出的价值很有限。能做的就是不断的尝试，不断地继续。</p><h1 id="git-">Git 提交</h1><p>今年的 github 提交量挺可观的，因为我不断的在业余时间做各种尝试。</p><p><img src="https://i-cdn.frytea.com/2026/01/01/720e6785096e33a225ad5b4d6234795c.png" alt="git-wrapped-songtianlun" height="1388" width="788"/></p><p>相比于去年，提交量增加了非常非常多。这还只是在 github 的提交，工作时间内网的提交可能是这几倍吧。</p><p>自己的 forgejo 服务器可以看到的提交量也挺多。</p><p><img src="https://i-cdn.frytea.com/2026/01/01/98154260829d03f4e00d98043c9d0697.png" alt="image-20260101010450350"/></p><p>当然跟大佬们相比还是相差甚远，跟我自己去年相比，则是增加了很多了，对此我很满意。</p><h1 id="">价值感悟</h1><p>价值创造。对于价值一词的理解逐渐深刻，特别是今年听到大湾鸡之父刘平云谈到吉祥物如何发挥价值的采访，我对价值这一词突然有一些具象的感觉。</p><p>听Manus联合创始人兼首席科学家季逸超（Peak）的访谈时，谈到他高中时期喜欢倒腾电脑，恰好那段时间乔布斯发布了 App story ，他做的软件在上面稳定的售卖，拿到现金流，足以向家长和老师证明自己做的事情是有价值的，让他可以放手去做。</p><p>我也在想，我如何创造或证明自己更大的价值呢。相比于那些比我更优秀的人，他们更早就想明白了这个问题，相比于那些更优秀的人慢一点，但一定要开始思考。</p><h1 id="">关于学习</h1><p>2025 学了很多东西，像是有学习焦虑一样，学了很多东西，用在各种方面。</p><p>但不知怎么的，总感觉不够深入，创造的价值优先，探索更多的可能性。</p><p><img src="https://i-cdn.frytea.com/2026/01/01/ea1d621d4d3cab07215eb099b950f955.png" alt="截屏 2026-01-01 01.11.51"/></p><p>微信读书阅读的书籍变少了，因为我花费了更多的时间阅读纸质书和输出，还有做很多探索的事情。给自己定的目标是尽量每个月买一本纸质书，读完一本再买下一本。今年陆续买了几本，希望明年阅读更多一些。</p><p>除了阅读，还学习了很多技术和推广等等相关的知识，广泛的涉猎。我不希望自己局限在技术领域，我希望自己能够积极突破，让自己做的东西真正能为更多的人产生价值，为此我需要不断的尝试。除了努力学习，尽量深入的掌握所需领域知识，还需要学习增长、推广、运营等等相关的知识和思维。希望新的一年能够有所突破吧。</p><h1 id="">关于输出</h1><p>最近自己我感觉是输出的低谷了。因为自己陷入了很多纠结和迷茫之中。</p><p>博客不想更新了，因为总感觉浅尝辄止，深入内容又很难把握方向，不知道如何发力。感觉没人会关心，自己在不断的思考。另一方面看着不断有访客进来，努力维持着博客不要倒。</p><p>除了博客，有一段时间尝试过日更公众号，每天想到什么，突然的灵感就用 flomo 记录下来，每天花 5-10 min 批量导出当天的想法，简单排版发公众号，坚持了几周放弃了，因为实在给自己太大压力了，感觉对健康状况有害，就暂时停止了。</p><p>关键问题还是方向和方法，这些问题我还须继续思考和尝试。</p><h1 id="">技术探索</h1><p>今年在技术探索方面同样做了很多努力，从AI到容器化，从算力底座到业务落地，希望利用一切可以看到的东西来尝试。容器方面参与开源社区做了一些贡献，在编码的过程中学到很多，希望新的一年能够继续。AI方面确实不知道如何发力，总感觉有点投机的感觉，想做深入又很难抓住哪一个赚钱的行业。对于我个人状况不敢轻易去下注一个未知的领域，需要稳定上升。</p><p>在 AI 方面研究了不少东西，但效果有限，可能最直接的产出就是一些提示词的整理，还有用法的整理。用 AI 做了不少东西，发现在 AI 助力下自己到达瓶颈的速度变快了，做事情确实能够快速开始，同时也需要快速学习，找到方向和方法，重复直到拿到结果。</p><h1 id="">业余探索</h1><p>在业余探索方面确实做了很多东西，业余时间做了 12+ 的项目，都是在不断尝试，有的技术栈不好，有的效率太低，有的还是自嗨，有的功能不稳定，有的 SEO 不好。总之在做的过程中学到的许多东西才不断深入的理解。有的感觉非常简单的东西和道理，也得自己亲手做一次才能深刻理解，没有实践就下结论很容易只是自己以为自己懂了。</p><h1 id="">个人博客</h1><p>至于个人博客，从百度统计可以看到几年的 PV 不到 10w，UV 6w 左右。</p><p><img src="https://i-cdn.frytea.com/2026/01/01/7c6b674be3f6c2e21d174cc088bd1d57.png" alt="image-20260101012740657"/></p><p>来源方面大部分还是直接访问，来自搜索引擎的只有 15%，说明 SEO 和内容方向还是有不小问题。不过个人博客，无所谓了，还是想些什么就写什么，有什么专题的东西在做专题的网站来整理。</p><p><img src="https://i-cdn.frytea.com/2026/01/01/ef9ab8a9b358b71598038d6466ed615c.png" alt="image-20260101012843988"/></p><p>似乎浏览量的统计还是有点问题，从自己的 Plausible + GA4 看2025年的 UV 81k  PV 108K</p><p><img src="https://i-cdn.frytea.com/2026/01/01/5d709498634763fdb1ad58f91b751d04.png" alt="image-20260101013135126"/></p><p>来源方面有快一半都来自于搜索引擎，难道百度统计不统计来自于其他搜索引擎的流量？</p><p><img src="https://i-cdn.frytea.com/2026/01/01/7150bf5b58f89bdcc7f609be42a5441e.png" alt="image-20260101013224874"/></p><p>主要还是来自国内的访问，使用 Chrome 浏览器最多：</p><p><img src="https://i-cdn.frytea.com/2026/01/01/c4c985804c2b71fe1246ca3560b2f807.png" alt="image-20260101013337511"/></p><h1 id="">关于分享欲</h1><p>思考了超级多的东西，分享东西也总是一阵一阵的，方向举棋不定，投入的精力比较分散。这是我自己存在的问题，未来我想逐渐的改变。去感受身边的美好，尽量聚焦在一些事情上，分享的东西也可以逐渐多一些。自己探索的东西对其他人说不定真是很有价值的。特别的需要挖掘 Reddit 这类论坛，顺便提升英文水平。</p><h1 id="">身体健康</h1><p>这一年去了不少次医院，虽然都是些小毛小病，可也是很难受的，一丁点的难受都可能让自己的精力大大受挫。现在这个年纪很多不舒服，都是在提醒自己该休息了。一些问题，医生听到最后只说，你可能需要放一个长假。</p><p>因此看开一些事情，不要过多较真，不要让自己情绪过多的波动。责任心强，做事情认真。这是我的优势，可如果为了不值得的事情影响了身体健康就太不值得了。应该将有限的注意力放在更有价值的事情上。</p><h1 id="">高光时刻</h1><p>今年的高光时刻大概就是入选中华人民共和国第十五届运动会火炬手了吧。参与了火炬传递，还上了央视，央视主持人读出了我的名字，还有专门的镜头。虽然是团体，可这件事大概也值的自己吹一辈子的牛了。一同入选的大部分都是企业家和各行各业非常有影响力的人。不过还是提醒自己要低调做人，高调做事。该高调高调，该低调低调。希望后面越来越好。希望自己能够做更多有价值的事情。</p>
<h1 id="">关于自信</h1><p>这也许是我这个人最大的缺点了吧。缺乏自信。而一个人的运气人生更好的一个大因素就是要自信，尤其最好是“盲目自信”，没有理由的自信。我已经在各方各面领先了很多人，我需要的是更自信的前进，追求更大的目标，创造更大的价值。因此，希望新的一年，提醒自己越来越自信。</p><h1 id="">写在最后</h1><p>新的一年，继续努力。愿自己健康快乐，爱的人同样健康幸福，希望大家都能够快乐平安，愿新的一年一切都好。</p></div><p style="text-align:right"><a href="https://blog.frytea.com/posts/life/1614#comments">看完了？说点什么呢</a></p></div>]]></description><link>https://blog.frytea.com/posts/life/1614</link><guid isPermaLink="true">https://blog.frytea.com/posts/life/1614</guid><dc:creator><![CDATA[tl.s]]></dc:creator><pubDate>Wed, 31 Dec 2025 17:49:39 GMT</pubDate></item><item><title><![CDATA[AI 生图精品提示词｜第二期：城市星球]]></title><description><![CDATA[<link rel="preload" as="image" href="https://cdn-imagehost.frytea.com/images/2025/12/13/o33ock.webp"/><link rel="preload" as="image" href="https://cdn-imagehost.frytea.com/images/2025/12/13/ntiazl.webp"/><link rel="preload" as="image" href="https://cdn-imagehost.frytea.com/images/2025/12/13/ntowrk.webp"/><link rel="preload" as="image" href="https://cdn-imagehost.frytea.com/images/2025/12/13/nu86cj.webp"/><link rel="preload" as="image" href="https://cdn-imagehost.frytea.com/images/2025/12/13/nv58qh.webp"/><link rel="preload" as="image" href="https://cdn-imagehost.frytea.com/images/2025/12/13/nv9wkq.webp"/><link rel="preload" as="image" href="https://cdn-imagehost.frytea.com/images/2025/12/13/nvfosd.webp"/><div><blockquote>该渲染由 Shiro API 生成，可能存在排版问题，最佳体验请前往：<a href="https://blog.frytea.com/posts/note/1613">https://blog.frytea.com/posts/note/1613</a></blockquote><div><blockquote><p>若没有特别说明，默认使用 <a href="https://ailoft.net/">AiLoft</a> 提供的 <code>Nano Banana Pro</code> 模型生成。</p></blockquote>
<p><img src="https://cdn-imagehost.frytea.com/images/2025/12/13/o33ock.webp" alt="城市星球系列封面图" height="2048" width="2048"/></p><p>本次带来《城市星球》系列，先看效果图：</p><blockquote><p>Refs: <a href="https://x.com/TechieBySA/status/1999577563295826208">https://x.com/TechieBySA/status/1999577563295826208</a></p></blockquote>
<p><img src="https://cdn-imagehost.frytea.com/images/2025/12/13/ntiazl.webp" alt="广州城市星球"/></p><p><img src="https://cdn-imagehost.frytea.com/images/2025/12/13/ntowrk.webp" alt="北京城市星球"/></p><p><img src="https://cdn-imagehost.frytea.com/images/2025/12/13/nu86cj.webp" alt="厦门城市星球"/></p><p><img src="https://cdn-imagehost.frytea.com/images/2025/12/13/nv58qh.webp" alt="香港城市星球"/></p><p><img src="https://cdn-imagehost.frytea.com/images/2025/12/13/nv9wkq.webp" alt="芝加哥城市星球"/></p><p><img src="https://cdn-imagehost.frytea.com/images/2025/12/13/nvfosd.webp" alt="澳门城市星球"/></p><p>提示词如下：</p><pre class=""><code class="">Create a hyperrealistic miniature planet showcasing [GuangZhou] with famous landmarks seamlessly curving around the spherical surface. Position bold 3D white text ”[CITY]” naturally integrated across the lush green central parkland with realistic shadows and dimensional depth. Capture from a top-down orbiting angle that emphasizes the dramatic planet curvature. Use soft golden hour daylight filtering through partly cloudy skies, casting gentle shadows on emerald grass and surrounding trees. The background should blend into a swirling atmospheric sky. Apply vibrant greens, warm earth tones, and soft blues. Render in polished photorealistic style with fine architectural detail.
</code></pre>
<p>可以讲示例中的 <code>GuangZhou</code> 换成其他城市，例如：</p><pre class=""><code class="">[GuangZhou]
[BeiJing]
[XiaMen]
[ZhengZhou]
[HongKong]
[Chicago]
[Macau]
</code></pre>
<p>效果都很不错，快用 <a href="https://ailoft.net/">AiLoft</a> 试试吧。</p></div><p style="text-align:right"><a href="https://blog.frytea.com/posts/note/1613#comments">看完了？说点什么呢</a></p></div>]]></description><link>https://blog.frytea.com/posts/note/1613</link><guid isPermaLink="true">https://blog.frytea.com/posts/note/1613</guid><dc:creator><![CDATA[tl.s]]></dc:creator><pubDate>Sat, 13 Dec 2025 07:04:00 GMT</pubDate></item><item><title><![CDATA[AI 生图精品提示词｜第一期]]></title><description><![CDATA[<link rel="preload" as="image" href="https://cdn-imagehost.frytea.com/images/2025/12/07/10ytg97.webp"/><link rel="preload" as="image" href="https://cdn-imagehost.frytea.com/images/2025/12/07/10y3vde.webp"/><link rel="preload" as="image" href="https://cdn-imagehost.frytea.com/images/2025/12/06/ntjen3.webp"/><link rel="preload" as="image" href="https://cdn-imagehost.frytea.com/images/2025/12/06/nvxopo.webp"/><link rel="preload" as="image" href="https://cdn-imagehost.frytea.com/images/2025/12/06/nwf7ct.webp"/><link rel="preload" as="image" href="https://cdn-imagehost.frytea.com/images/2025/12/07/jyvlhw.webp"/><link rel="preload" as="image" href="https://cdn-imagehost.frytea.com/images/2025/12/07/jzb6gu.webp"/><link rel="preload" as="image" href="https://cdn-imagehost.frytea.com/images/2025/12/07/k198ao.webp"/><link rel="preload" as="image" href="https://cdn-imagehost.frytea.com/images/2025/12/07/k0f9m3.webp"/><link rel="preload" as="image" href="https://cdn-imagehost.frytea.com/images/2025/12/07/jyoc4r.webp"/><div><blockquote>该渲染由 Shiro API 生成，可能存在排版问题，最佳体验请前往：<a href="https://blog.frytea.com/posts/note/1547">https://blog.frytea.com/posts/note/1547</a></blockquote><div><blockquote><p>若没有特别说明，默认使用 <a href="https://ailoft.net/">AiLoft</a> 提供的 <code>Nano Banana Pro</code> 模型生成。</p></blockquote>
<p>本期封面图：</p><p><img src="https://cdn-imagehost.frytea.com/images/2025/12/07/10ytg97.webp" alt="英文封面图" height="768" width="1376"/></p>
<p><img src="https://cdn-imagehost.frytea.com/images/2025/12/07/10y3vde.webp" alt="中文封面图"/></p>
<h1 id="3d-q-">3D Q 版迷你概念商店</h1><blockquote><p>Refs: <a href="https://x.com/dotey/status/1995190286775881780">https://x.com/dotey/status/1995190286775881780</a></p></blockquote>
<p>说明：</p><pre class=""><code class="">🍌 nano banana prompt
3D chibi-style miniature concept store of {Brand Name}
</code></pre>
<p>提示词：</p><pre class=""><code class="">3D chibi-style miniature concept store of {Brand Name}, creatively designed with an exterior inspired by the brand&#x27;s most iconic product or packaging (such as a giant {brand&#x27;s core product, e.g., chicken bucket/hamburger/donut/roast duck}). The store features two floors with large glass windows clearly showcasing the cozy and finely decorated interior: {brand&#x27;s primary color}-themed decor, warm lighting, and busy staff dressed in outfits matching the brand. Adorable tiny figures stroll or sit along the street, surrounded by benches, street lamps, and potted plants, creating a charming urban scene. Rendered in a miniature cityscape style using Cinema 4D, with a blind-box toy aesthetic, rich in details and realism, and bathed in soft lighting that evokes a relaxing afternoon atmosphere. --ar 2:3

Brand name: Starbucks
</code></pre><p>效果图：
Starbucks
<img src="https://cdn-imagehost.frytea.com/images/2025/12/06/ntjen3.webp" alt="3D chibi-style miniature concept store of Starbucks"/></p><p>麦当劳
<img src="https://cdn-imagehost.frytea.com/images/2025/12/06/nvxopo.webp" alt="3D chibi-style miniature concept store of 麦当劳"/></p><p>McDonald
<img src="https://cdn-imagehost.frytea.com/images/2025/12/06/nwf7ct.webp" alt="3D chibi-style miniature concept store of McDonald"/></p>
<h1 id="">和明星自拍</h1><blockquote><p>refs: <a href="https://x.com/canghecode/status/1996593241421181403">https://x.com/canghecode/status/1996593241421181403</a></p></blockquote>
<p>提示词:</p><pre class=""><code class="">“我在[电影名称]的片场和[电影角色]自拍。

保持人物与参考图像完全一致，面部特征、骨骼结构、肤色、表情、姿势和外貌 100%相同。1:1 宽高比，4K 细节。”
</code></pre>
<p>实例:</p><p>参考图片：</p><p><img src="https://cdn-imagehost.frytea.com/images/2025/12/07/jyvlhw.webp" alt="哈利波特"/></p><pre class=""><code class="">我在[疯狂动物城]的片场和[Judy Hopps]、[Nick Wilde]自拍。

保持人物与参考图像完全一致，面部特征、骨骼结构、肤色、表情、姿势和外貌 100%相同。1:1 宽高比，4K 细节。
</code></pre>
<p>效果图：</p><p><img src="https://cdn-imagehost.frytea.com/images/2025/12/07/jzb6gu.webp" alt="哈利波特在疯狂动物城拍摄现场与主演合影"/></p><h1 id="3d-">3D 微缩电影场景</h1><blockquote><p> refs: <a href="https://x.com/tsubame_99/status/1997181713546727621">https://x.com/tsubame_99/status/1997181713546727621</a></p></blockquote>
<pre class=""><code class="">Present an exquisite, miniature 3D cartoon-style scene of the user-specified subject, clearly viewed from a 45° top-down perspective.

Place the subject’s most iconic representation, character, or landmark prominently at the center, complemented by proportionally-sized icons of key elements, symbolic items, charming figures, props, and other details illustrating the subject’s core theme or narrative. The scene should be detailed, finely crafted, and playful.

Rendered with Cinema 4D, the modeling should be refined, smoothly rounded, and rich in texture, accurately capturing realistic PBR materials. Gentle, lifelike lighting and soft shadows should create a warm, comfortable ambiance.

Maintain a clean, minimalist layout and a solid-color background to highlight the primary content.

At the top-center of the scene, prominently display the subject name in a large font size.

All texts should be displayed in the language specified or entered by the user, without any background, and may subtly overlap with the scene elements to enhance overall design integration.

**Parameters:**
Aspect ratio: {User input, default 1:1}
Subject Name / Topic: {User input}
</code></pre><p>实例</p><pre class=""><code class="">Subject Name / Topic: Squid Game
Subject Name / Topic: 名侦探柯南
</code></pre>
<p>效果图：</p><p><img src="https://cdn-imagehost.frytea.com/images/2025/12/07/k198ao.webp" alt="名侦探柯南 3D 微缩电影场景"/></p>
<h1 id="3d-">3D 动态城市天气场景</h1><blockquote><p>refs: <a href="https://x.com/dotey/status/1993729800922341810?s=46">https://x.com/dotey/status/1993729800922341810?s=46</a></p></blockquote>
<p>说明：</p><pre class=""><code class="">🍌 nano banana pro prompt (with gemini)

Dynamically generate a current weather card based on a given city name.
</code></pre><p>提示词：</p><pre class=""><code class="">Present a clear, 45° top-down view of a vertical (9:16) isometric miniature 3D cartoon scene, highlighting iconic landmarks centered in the composition to showcase precise and delicate modeling.

The scene features soft, refined textures with realistic PBR materials and gentle, lifelike lighting and shadow effects. Weather elements are creatively integrated into the urban architecture, establishing a dynamic interaction between the city&#x27;s landscape and atmospheric conditions, creating an immersive weather ambiance.

Use a clean, unified composition with minimalistic aesthetics and a soft, solid-colored background that highlights the main content. The overall visual style is fresh and soothing.

Display a prominent weather icon at the top-center, with the date (x-small text) and temperature range (medium text) beneath it. The city name (large text) is positioned directly above the weather icon. The weather information has no background and can subtly overlap with the buildings.

The text should match the input city&#x27;s native language.
Please retrieve current weather conditions for the specified city before rendering.

City name:【广州】
</code></pre>
<p>效果图</p><p><img src="https://cdn-imagehost.frytea.com/images/2025/12/07/k0f9m3.webp" alt="广州动态城市天气场景"/></p><h1 id="3d-">3D 诗词场景</h1><blockquote><p>Refs: <a href="https://x.com/ykszs017/status/1997268159800434783">https://x.com/ykszs017/status/1997268159800434783</a></p><pre class=""><code class="">A vertical (9:16), intricately detailed 45° top-down isometric miniature 3D cartoon scene. The central composition is a richly composed and densely modeled visualization of an ancient Chinese poem&#x27;s imagery. The scene features soft but highly tactile PBR textures with matte materials (like hand-sculpted clay with visible tool marks, aged wood grain, rough ceramic, and textured fabrics). Layered, lyrical lighting with soft shadows and ambient occlusion emphasizes the depth of every small feature. Key visual elements derived from the verses are creatively integrated into the landscape. The scene must be densely filled with micro-details to create a lived-in, immersive poetic ambiance: add scattered pebbles, moss in cracks, fallen leaves, dew drops on plants, intricate architectural carvings, tiny wildlife (like birds or fish), and environmental clutter relevant to the poem. Use a clean, unified composition that balances richness with aesthetics, set against a soft, solid-colored background that complements the scene&#x27;s color palette. The overall visual style is fresh, soothing, yet elaborate and full of life. Text layout: At the top-center, display the poem title in large, elegant Chinese font. Directly beneath it, display the Dynasty and Author in medium font. The core verses of the poem are arranged below the main scene or subtly floating near relevant objects within the composition, with no background plate. Poem Title: 【天净沙·秋思】 Dynasty/Author: 【元·马致远】 Core Verses Context: 枯藤老树昏鸦，小桥流水人家，古道西风瘦马。夕阳西下，断肠人在天涯 。(Visual Focus: An old tree, tightly entwined with withered vines, has cracked branches, and a few crows are perched or flapping their wings. A small stone bridge spanning a cold and clear stream, with mist and moisture clinging to the water surface; Two or three compact houses by the stream, with very faint smoke from their chimneys, were torn apart by the cold wind. An ancient path, dusty by the autumn wind, extends deeper into the picture. A bony and thin horse, with dull fur, had its mane flapped sideways by the wind. A solitary traveler, wearing an old cloak, with a slender figure, strolled slowly in the wind. The withered and yellow grass lay on the ground, and the cracked dirt road had ruts. The setting sun was close to the horizon, its golden-red rays shattered by the wind, casting long shadows on the travelers, horses and ancient paths. The overall scene presents a desolate, dry and cold, and spacious atmosphere of late autumn.）
</code></pre></blockquote>
<p>效果图：</p><p><img src="https://cdn-imagehost.frytea.com/images/2025/12/07/jyoc4r.webp" alt="天净沙·秋思"/></p></div><p style="text-align:right"><a href="https://blog.frytea.com/posts/note/1547#comments">看完了？说点什么呢</a></p></div>]]></description><link>https://blog.frytea.com/posts/note/1547</link><guid isPermaLink="true">https://blog.frytea.com/posts/note/1547</guid><dc:creator><![CDATA[tl.s]]></dc:creator><pubDate>Sat, 06 Dec 2025 06:47:00 GMT</pubDate></item><item><title><![CDATA[Kubernetes kubectl --raw 使用指南]]></title><description><![CDATA[<div><blockquote>该渲染由 Shiro API 生成，可能存在排版问题，最佳体验请前往：<a href="https://blog.frytea.com/posts/note/1546">https://blog.frytea.com/posts/note/1546</a></blockquote><div><h2 id="-kubectl---raw">什么是 kubectl --raw?</h2><p><code>kubectl --raw</code> 是一个强大的底层工具,允许你直接访问 Kubernetes API Server 的 REST API,绕过 kubectl 的客户端逻辑、准入控制器(Admission Controllers)和 Webhook。</p><h2 id="---raw">为什么需要 --raw?</h2><h3 id="-kubectl-">标准 kubectl 的请求流程</h3><pre class=""><code class="">kubectl 命令
    ↓
客户端验证和处理
    ↓
Admission Controllers
    ↓
Mutating Webhooks (修改请求)
    ↓
Validating Webhooks (验证请求)
    ↓
API Server 存储到 etcd
</code></pre>
<h3 id="kubectl---raw-">kubectl --raw 的请求流程</h3><pre class=""><code class="">kubectl --raw
    ↓
直接 HTTP 请求到 API Server
    ↓
绕过大部分中间件
    ↓
直接操作 etcd
</code></pre>
<h2 id="">适用场景</h2><ol start="1"><li><strong>绕过 Webhook 干扰</strong><ul><li>当 Mutating/Validating Webhook 阻止正常操作时</li></ul></li><li><strong>调试 API Server</strong><ul><li>排查 kubectl 客户端与 API Server 的交互问题</li></ul></li><li><strong>访问特殊端点</strong><ul><li>访问 metrics、healthz 等非资源端点</li></ul></li><li><strong>绕过客户端限制</strong><ul><li>kubectl 版本不支持某些新特性时</li></ul></li><li><strong>性能测试</strong><ul><li>直接测试 API Server 响应时间</li></ul></li><li><strong>修复僵尸资源</strong><ul><li>清理被控制器锁定的资源状态</li></ul></li></ol><h2 id="">基本语法</h2><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 基本格式
kubectl get --raw &lt;API-PATH&gt;

# 或在某些版本中
kubectl --raw &lt;API-PATH&gt;
</code></pre>
<h2 id="">常用操作示例</h2><h3 id="1-get----">1. GET 请求 - 查询资源</h3><h4 id="">查看集群级别资源</h4><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 获取所有节点
kubectl get --raw /api/v1/nodes | jq .

# 获取特定节点
kubectl get --raw /api/v1/nodes/node-name | jq .

# 获取节点状态
kubectl get --raw /api/v1/nodes/node-name/status | jq .

# 获取所有命名空间
kubectl get --raw /api/v1/namespaces | jq .
</code></pre>
<h4 id="">查看命名空间级别资源</h4><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 获取 default 命名空间的所有 Pod
kubectl get --raw /api/v1/namespaces/default/pods | jq .

# 获取特定 Pod
kubectl get --raw /api/v1/namespaces/default/pods/pod-name | jq .

# 获取 Deployment
kubectl get --raw /apis/apps/v1/namespaces/default/deployments/deploy-name | jq .

# 获取 Service
kubectl get --raw /api/v1/namespaces/default/services/svc-name | jq .
</code></pre>
<h4 id="">查看子资源</h4><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># Pod 日志
kubectl get --raw /api/v1/namespaces/default/pods/pod-name/log

# Pod 状态
kubectl get --raw /api/v1/namespaces/default/pods/pod-name/status | jq .

# Service 的 Endpoint
kubectl get --raw /api/v1/namespaces/default/endpoints/service-name | jq .
</code></pre>
<h3 id="2-put----">2. PUT 请求 - 完整更新资源</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 更新节点(先获取,修改,再替换)
kubectl get --raw /api/v1/nodes/node-name &gt; node.json

# 编辑 node.json 文件
vim node.json

# 替换(注意:不同版本语法可能不同)
kubectl replace --raw /api/v1/nodes/node-name -f node.json

# 或使用 kubectl proxy 方式
kubectl proxy --port=8001 &amp;
curl -X PUT \
  -H &quot;Content-Type: application/json&quot; \
  -d @node.json \
  http://localhost:8001/api/v1/nodes/node-name
</code></pre>
<h4 id="">实战案例:清除节点僵尸条件</h4><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 获取节点当前状态
kubectl get --raw /api/v1/nodes/node-name &gt; /tmp/node.json

# 使用 jq 删除特定条件
jq &#x27;del(.status.conditions[] | select(.type == &quot;EtcdIsVoter&quot;))&#x27; \
  /tmp/node.json &gt; /tmp/node-fixed.json

# 更新节点状态
kubectl replace --raw /api/v1/nodes/node-name/status -f /tmp/node-fixed.json
</code></pre>
<h3 id="3-post----">3. POST 请求 - 创建资源</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 创建 Pod
cat &gt; pod.json &lt;&lt;EOF
{
  &quot;apiVersion&quot;: &quot;v1&quot;,
  &quot;kind&quot;: &quot;Pod&quot;,
  &quot;metadata&quot;: {
    &quot;name&quot;: &quot;test-pod&quot;,
    &quot;namespace&quot;: &quot;default&quot;
  },
  &quot;spec&quot;: {
    &quot;containers&quot;: [{
      &quot;name&quot;: &quot;nginx&quot;,
      &quot;image&quot;: &quot;nginx:latest&quot;
    }]
  }
}
EOF

kubectl create --raw /api/v1/namespaces/default/pods -f pod.json
</code></pre>
<h3 id="4-delete----">4. DELETE 请求 - 删除资源</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 删除 Pod
kubectl delete --raw /api/v1/namespaces/default/pods/pod-name

# 使用 kubectl proxy 方式
kubectl proxy --port=8001 &amp;
curl -X DELETE http://localhost:8001/api/v1/namespaces/default/pods/pod-name
</code></pre>
<h3 id="5-patch----">5. PATCH 请求 - 部分更新</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># JSON Patch (精确的操作指令)
kubectl patch --raw /api/v1/nodes/node-name \
  --type=&#x27;json&#x27; \
  -p=&#x27;[
    {&quot;op&quot;: &quot;add&quot;, &quot;path&quot;: &quot;/metadata/labels/new-label&quot;, &quot;value&quot;: &quot;new-value&quot;},
    {&quot;op&quot;: &quot;remove&quot;, &quot;path&quot;: &quot;/status/conditions/0&quot;}
  ]&#x27;

# Strategic Merge Patch (合并式更新)
kubectl patch --raw /api/v1/nodes/node-name \
  --type=&#x27;merge&#x27; \
  -p &#x27;{
    &quot;metadata&quot;: {
      &quot;labels&quot;: {
        &quot;environment&quot;: &quot;production&quot;
      }
    }
  }&#x27;

# Merge Patch (简单合并)
kubectl patch --raw /api/v1/nodes/node-name \
  --type=&#x27;merge&#x27; \
  -p &#x27;{&quot;spec&quot;:{&quot;unschedulable&quot;:true}}&#x27;
</code></pre>
<h2 id="api-">API 路径规则</h2><h3 id="-api--core-api-group">核心 API 组 (Core API Group)</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 格式
/api/v1/&lt;resource-type&gt;                        # 集群级别
/api/v1/namespaces/&lt;namespace&gt;/&lt;resource-type&gt; # 命名空间级别

# 示例
/api/v1/nodes
/api/v1/nodes/node-name
/api/v1/nodes/node-name/status
/api/v1/namespaces/default/pods
/api/v1/namespaces/default/pods/pod-name
/api/v1/namespaces/default/services
</code></pre>
<h3 id="-api--named-api-groups">命名 API 组 (Named API Groups)</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 格式
/apis/&lt;group&gt;/&lt;version&gt;/&lt;resource-type&gt;
/apis/&lt;group&gt;/&lt;version&gt;/namespaces/&lt;ns&gt;/&lt;resource-type&gt;

# 常用 API 组示例
/apis/apps/v1/deployments                           # Deployment
/apis/apps/v1/namespaces/default/deployments
/apis/batch/v1/cronjobs                             # CronJob
/apis/networking.k8s.io/v1/ingresses                # Ingress
/apis/rbac.authorization.k8s.io/v1/clusterroles     # ClusterRole
/apis/storage.k8s.io/v1/storageclasses              # StorageClass
</code></pre>
<h3 id="-subresources">子资源 (Subresources)</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 状态子资源
/api/v1/nodes/&lt;name&gt;/status
/apis/apps/v1/namespaces/&lt;ns&gt;/deployments/&lt;name&gt;/status

# 日志
/api/v1/namespaces/&lt;ns&gt;/pods/&lt;name&gt;/log
/api/v1/namespaces/&lt;ns&gt;/pods/&lt;name&gt;/log?container=container-name

# 执行命令
/api/v1/namespaces/&lt;ns&gt;/pods/&lt;name&gt;/exec

# 端口转发
/api/v1/namespaces/&lt;ns&gt;/pods/&lt;name&gt;/portforward

# 代理
/api/v1/nodes/&lt;name&gt;/proxy
/api/v1/namespaces/&lt;ns&gt;/pods/&lt;name&gt;/proxy
/api/v1/namespaces/&lt;ns&gt;/services/&lt;name&gt;/proxy
</code></pre>
<h2 id="">特殊端点</h2><h3 id="-api-">查看 API 资源</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 列出所有 API 版本
kubectl get --raw /apis | jq &#x27;.groups[].name&#x27;

# 查看特定 API 组
kubectl get --raw /apis/apps/v1 | jq .

# 列出所有可用资源
kubectl get --raw /api/v1 | jq &#x27;.resources[].name&#x27;

# OpenAPI 规范
kubectl get --raw /openapi/v2 | jq . &gt; openapi.json
</code></pre>
<h3 id="">集群信息</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 版本信息
kubectl get --raw /version | jq .

# 健康检查
kubectl get --raw /healthz
kubectl get --raw /livez
kubectl get --raw /readyz

# API Server 标志
kubectl get --raw /debug/flags/v

# Metrics
kubectl get --raw /metrics
</code></pre>
<h3 id="">认证和授权</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 检查当前用户权限
kubectl get --raw /apis/authorization.k8s.io/v1/selfsubjectaccessreviews \
  -X POST \
  -d &#x27;{
    &quot;apiVersion&quot;: &quot;authorization.k8s.io/v1&quot;,
    &quot;kind&quot;: &quot;SelfSubjectAccessReview&quot;,
    &quot;spec&quot;: {
      &quot;resourceAttributes&quot;: {
        &quot;namespace&quot;: &quot;default&quot;,
        &quot;verb&quot;: &quot;get&quot;,
        &quot;resource&quot;: &quot;pods&quot;
      }
    }
  }&#x27;
</code></pre>
<h2 id="-kubectl-proxy-">使用 kubectl proxy 的方式</h2><p>当 <code>kubectl --raw</code> 不可用或语法复杂时,可以使用 proxy 方式:</p><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 启动代理
kubectl proxy --port=8001 &amp;

# 使用 curl 访问
curl http://localhost:8001/api/v1/nodes | jq .

# GET 请求
curl http://localhost:8001/api/v1/namespaces/default/pods

# POST 请求
curl -X POST \
  -H &quot;Content-Type: application/json&quot; \
  -d @pod.json \
  http://localhost:8001/api/v1/namespaces/default/pods

# PUT 请求
curl -X PUT \
  -H &quot;Content-Type: application/json&quot; \
  -d @node.json \
  http://localhost:8001/api/v1/nodes/node-name/status

# DELETE 请求
curl -X DELETE \
  http://localhost:8001/api/v1/namespaces/default/pods/pod-name

# 停止代理
pkill -f &quot;kubectl proxy&quot;
</code></pre>
<h2 id="">实战案例</h2><h3 id="-1--webhook-">案例 1: 绕过 Webhook 修改节点标签</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 问题:Mutating Webhook 拦截标签修改
# 解决:直接通过 API 修改

# 1. 获取节点
kubectl get --raw /api/v1/nodes/node-name &gt; node.json

# 2. 使用 jq 添加标签
jq &#x27;.metadata.labels[&quot;custom-label&quot;] = &quot;custom-value&quot;&#x27; node.json &gt; node-updated.json

# 3. 替换节点
kubectl replace --raw /api/v1/nodes/node-name -f node-updated.json
</code></pre>
<h3 id="-2--finalizer">案例 2: 清理僵尸 Finalizer</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 问题:资源因 finalizer 无法删除
# 解决:直接清空 finalizers

# 1. 获取资源
kubectl get --raw /api/v1/namespaces/stuck-namespace &gt; ns.json

# 2. 清空 finalizers
jq &#x27;.spec.finalizers = []&#x27; ns.json &gt; ns-clean.json

# 3. 更新
kubectl replace --raw /api/v1/namespaces/stuck-namespace/finalize -f ns-clean.json
</code></pre>
<h3 id="-3-">案例 3: 批量查询资源状态</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash">#!/bin/bash
# 批量检查节点状态

for node in $(kubectl get nodes -o name | cut -d/ -f2); do
  echo &quot;=== Node: $node ===&quot;
  kubectl get --raw /api/v1/nodes/$node/status | \
    jq -r &#x27;.status.conditions[] | select(.type==&quot;Ready&quot;) | 
    &quot;Status: \(.status), Reason: \(.reason)&quot;&#x27;
done
</code></pre>
<h3 id="-4-">案例 4: 性能测试</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash">#!/bin/bash
# 测试 API Server 响应时间

echo &quot;Testing API Server performance...&quot;
for i in {1..10}; do
  time kubectl get --raw /api/v1/nodes &gt; /dev/null 2&gt;&amp;1
done
</code></pre>
<h3 id="-5-">案例 5: 导出所有资源</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash">#!/bin/bash
# 导出命名空间的所有资源

NAMESPACE=&quot;default&quot;
OUTPUT_DIR=&quot;./k8s-backup&quot;
mkdir -p $OUTPUT_DIR

# 导出 Pods
kubectl get --raw /api/v1/namespaces/$NAMESPACE/pods | \
  jq . &gt; $OUTPUT_DIR/pods.json

# 导出 Services
kubectl get --raw /api/v1/namespaces/$NAMESPACE/services | \
  jq . &gt; $OUTPUT_DIR/services.json

# 导出 Deployments
kubectl get --raw /apis/apps/v1/namespaces/$NAMESPACE/deployments | \
  jq . &gt; $OUTPUT_DIR/deployments.json

echo &quot;Backup completed in $OUTPUT_DIR&quot;
</code></pre>
<h2 id="">注意事项</h2><h3 id="1-">1. 权限要求</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 需要相应的 RBAC 权限
# 检查权限
kubectl auth can-i get nodes
kubectl auth can-i update nodes
</code></pre>
<h3 id="2-resourceversion-">2. resourceVersion 冲突</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 更新时可能遇到冲突
# Error: the object has been modified; please apply your changes to the latest version

# 解决:重新获取最新版本
kubectl get --raw /api/v1/nodes/node-name &gt; node-latest.json
# 重新修改并更新
</code></pre>
<h3 id="3-">3. 数据格式验证</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 使用 jq 验证 JSON 格式
cat resource.json | jq . &gt; /dev/null

# 如果有错误会提示
</code></pre>
<h3 id="4-">4. 备份重要资源</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 在修改前务必备份
kubectl get --raw /api/v1/nodes/node-name &gt; node-backup-$(date +%Y%m%d).json
</code></pre>
<h3 id="5-">5. 只读操作优先</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 先用 GET 查看,确认无误后再 PUT/PATCH
kubectl get --raw /api/v1/nodes/node-name | jq .
</code></pre>
<h2 id="">版本兼容性</h2><h3 id="kubernetes-118">Kubernetes 1.18+</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash">kubectl get --raw /api/v1/nodes
kubectl create --raw /api/v1/namespaces/default/pods -f pod.json
kubectl replace --raw /api/v1/nodes/node-name -f node.json
kubectl patch --raw /api/v1/nodes/node-name --type=merge -p &#x27;{...}&#x27;
kubectl delete --raw /api/v1/namespaces/default/pods/pod-name
</code></pre>
<h3 id="">早期版本或不支持时</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 使用 kubectl proxy
kubectl proxy --port=8001 &amp;
curl http://localhost:8001/api/v1/nodes
</code></pre>
<h2 id="">调试技巧</h2><h3 id="1-">1. 查看完整请求</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 增加日志级别
kubectl get --raw /api/v1/nodes -v=8
</code></pre>
<h3 id="2--jq-">2. 使用 jq 过滤输出</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 只查看节点名称
kubectl get --raw /api/v1/nodes | jq &#x27;.items[].metadata.name&#x27;

# 查看 Pod 状态
kubectl get --raw /api/v1/namespaces/default/pods | \
  jq &#x27;.items[] | {name: .metadata.name, status: .status.phase}&#x27;
</code></pre>
<h3 id="3-">3. 格式化时间戳</h3><pre class="language-bash lang-bash"><code class="language-bash lang-bash"># 转换时间格式
kubectl get --raw /api/v1/nodes/node-name | \
  jq &#x27;.metadata.creationTimestamp | fromdate | strftime(&quot;%Y-%m-%d %H:%M:%S&quot;)&#x27;
</code></pre>
<h2 id="">总结</h2><p><code>kubectl --raw</code> 是 Kubernetes 的&quot;瑞士军刀&quot;,提供了:</p><p>✅ <strong>直接访问 API</strong> - 绕过客户端限制<br/>✅ <strong>调试工具</strong> - 排查 kubectl 和 API Server 问题<br/>✅ <strong>应急修复</strong> - 处理 Webhook 和控制器导致的问题<br/>✅ <strong>性能测试</strong> - 直接测试 API Server<br/>✅ <strong>学习工具</strong> - 理解 Kubernetes API 结构</p><p>⚠️ <strong>使用场景</strong>: 作为最后的调试和修复手段<br/>⚠️ <strong>不推荐</strong>: 日常操作应使用标准 kubectl 命令<br/>⚠️ <strong>需谨慎</strong>: 直接操作可能破坏资源状态</p><h2 id="">参考资源</h2><ul><li><a href="https://kubernetes.io/docs/reference/kubernetes-api/">Kubernetes API 文档</a></li><li><a href="https://kubernetes.io/docs/reference/kubectl/">kubectl 命令行参考</a></li><li><a href="https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md">Kubernetes API Conventions</a></li></ul></div><p style="text-align:right"><a href="https://blog.frytea.com/posts/note/1546#comments">看完了？说点什么呢</a></p></div>]]></description><link>https://blog.frytea.com/posts/note/1546</link><guid isPermaLink="true">https://blog.frytea.com/posts/note/1546</guid><dc:creator><![CDATA[tl.s]]></dc:creator><pubDate>Mon, 10 Nov 2025 13:08:00 GMT</pubDate></item></channel></rss>