The user-notes command in cli-anything-codimd doesn't support PostgreSQL, so the script now queries the database directly via SSH kubectl exec. Also fixes SQL quote handling in db-query command. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
K3s 叢集管理
個人 K3s Kubernetes 叢集的 manifests 與維護腳本
📖 文檔導航
| 文檔 | 用途 |
|---|---|
| SUMMARY.md | 📋 服務總覽、快速參考 |
| QUICKSTART.md | 🚀 快速入門、操作指南 |
🖥️ 連線資訊
ssh ubuntu@192.168.42.120
sudo -i # 切換 root
cd /root/k8s # K3s 工作目錄
- 主機: 192.168.42.120 (vm120 master + vm121/vm122 workers)
- K3s 目錄:
/root/k8s - 舊 manifests:
/root/k8s-manifests(備份保留) - 本地目錄:
/Users/timmy/42_120/k8s - Git Repo: http://192.168.42.124:31337/timmy/k3s.git
🚀 已部署服務
| 服務 | 用途 | 狀態腳本 |
|---|---|---|
| CodiMD | Markdown 協作筆記 | ./apps/codimd/status.sh |
| Opengist | Git Snippets 管理 | ./apps/opengist/status.sh |
| Vaultwarden | 密碼管理器 | ./apps/vaultwarden/status.sh |
| Adminer | 資料庫管理工具 | ./apps/adminer/status.sh |
| PostgreSQL | 通用資料庫 | ./apps/postgres/status.sh |
📂 目錄結構
k8s/
├── apps/
│ ├── adminer/ # 資料庫管理工具
│ ├── codimd/ # 筆記應用
│ ├── opengist/ # Git Snippets
│ ├── postgres/ # 資料庫
│ ├── template/ # 新 App 範本
│ └── vaultwarden/ # 密碼管理器
└── cluster/ # 叢集工具
每個 app 都包含:
manifests/- Kubernetes YAML 檔案backup/- 備份資料deploy.sh- 部署腳本stop.sh- 停止腳本(保留資料)status.sh- 狀態檢查backup.sh- 備份腳本(如有)
⚡ 快速命令
# 部署所有服務
for app in apps/*/; do cd "$app" && ./deploy.sh && cd ../..; done
# 檢查所有服務狀態
for app in apps/*/; do cd "$app" && ./status.sh && cd ../..; done
# 查看 K3s Pods
kubectl get pods -A
# 查看 Ingress
kubectl get ingress -A
🔧 維護工作流程
- 本地修改 → 在此目錄編輯 manifests 或腳本
- Git 提交 →
git add -A && git commit -m "描述" && git push - 遠端更新 →
git -C /root/k8s pull - 套用變更 →
kubectl apply -f manifests/
📚 叢集架構
┌─────────────────────────────────────┐
│ Traefik Ingress │
│ (codimd / opengist / vw / adminer) │
└─────────────────┬───────────────────┘
│
┌─────────────┼─────────────┬─────────┐
│ │ │ │
┌───▼───┐ ┌───▼───┐ ┌───▼───┐ ┌──▼────┐
│CodiMD │ │Opengist│ │Vault │ │Adminer│
│ +PG │ │ │ │warden │ │ │
└───────┘ └────────┘ └───────┘ └───────┘
│ │ │
└───▼─────────────▼─────────────▼───┘
Longhorn Storage
(持久化資料儲存)
🔗 相關連結
⚠️ 注意:維護時請同步本地與遠端,並定期執行備份!
Description
Languages
PLpgSQL
70.2%
Shell
28.5%
Makefile
1.3%