微服務架構郵件系統之 Kubernetes 與 GitOps 維運

Kubernetes and GitOps Operations for Microservice-Based Mail Systems

檔案

日期

2026

類型

語言

中文

摘要

系級郵件服務屬長期運作且高度依賴穩定性的基礎設施,設定錯誤可能造成信件遺
失、拒收或送達率下降。國立陽明交通大學資工系資訊中心的郵件系統由收信、寄信
認證、對外轉送、投遞路由、信箱儲存、垃圾信過濾、負載平衡等16 個功能角色組成,
角色間具嚴格的郵件流程依賴。原以多台VM 與Docker Compose 部署,每次映像更新
或設定變更均需逐機SSH 操作,節點故障缺乏自動復原機制,設定分散於各主機而難
以稽核。
本研究將此系統完整遷移至Kubernetes,並以GitOps 建立可自動化、可追蹤、可回
溯的維運流程。網路層以Calico IPPool 搭配proxy ARP 直接為Pod 指派可路由位址,使
各角色保有與既有MX、SPF、PTR 記錄對齊的穩定對外身份;儲存層以NFS PV 承載
信箱資料,local-path PVC 滿足佇列與資料庫的低延遲需求;投遞路由以啟動閘門等待
成員名錄穩定,解決Dovecot Director 於容器環境下路由環不完整所引發的投遞服務異
常與信箱鎖競爭;GitLab CI 與Flux CD 構成自映像建置至部署的自動化閉環,設定以
Kustomize base/overlay 管理,並由持續協調(reconcile)系統性偵測設定漂移。遷移採
分階段策略,各階段先於測試區驗證功能正確性,再切換生產區。
評估結果顯示:16 個服務角色完整遷移並保留端到端郵件收發路徑;映像更新與設
定變更可全程經 Git 自動完成;分階段策略於正式切換前暴露並修復九項跨元件設定
缺漏。最貼近維運人力的發現為:最耗費人力的兩項操作——服務映像更新與副本擴充
——由舊架構逐機人工的分鐘至十分鐘級,降至自動化流程的秒級,其結構性原因在於
將「隨機台數線性重複」的建置動作收斂為「單次攤提、產物可重複使用」。資源用量
則呈非對稱變化:總 RAM 用量較舊架構下降約 51%,總 CPU 用量反而上升約 4 倍,
惟其中郵件角色本身僅增加約6%,增量幾乎全數來自平台元件,顯示容器化的資源效
益具面向特定性,不可一概而論。本研究並自實作提煉三項可轉移的設計原則:以位
址池為有狀態後端提供穩定對外位址、以分階段整合測試作為切換前系統性暴露缺漏
的策略,以及以GitOps 持續協調作為設定漂移的偵測機制。本研究之評估以功能驗收
i
為主軸,未進行含MTTR 在內的量化效能比較;方法適用於節點與上層路由器具備L2
鄰接性的自建機房環境,完整之限制與適用條件見第四章與第六章。
An institutional mail service is long-running, availability-critical infrastructure where con-
figuration errors can cause message loss, delivery failures, or degraded deliverability. At the
Information Technology Center, Department of Computer Science, National Yang Ming Chiao
Tung University, the mail system comprises 16 specialized roles —inbound MX reception, sub-
mission authentication, outbound relay, delivery routing, mailbox storage, spam and antivirus
filtering, and load balancing —with strict inter-role dependencies spanning the full mail flow.
Historically deployed as Docker Compose stacks on dedicated VMs, every image update or
configuration change required host-by-host SSH intervention, node failures lacked automatic
recovery, and configuration state drifted silently across machines.
This thesis presents a complete migration of the system to Kubernetes, with an operations
model centered on GitOps. At the networking layer, Calico IP pools with proxy ARP assign
routable Pod addresses directly, preserving external identities aligned with existing MX, SPF,
and PTR records. At the storage layer, NFS-backed PersistentVolumes hold mailbox data while
local-path volumes serve latency-sensitive spools and databases. A startup gate that waits for
member-list stabilization resolves the two distinct failures that an incomplete Dovecot Director
ring induces under container scheduling —routing inconsistency that disrupts delivery, and lock
contention from concurrent writes to the same mailbox. GitLab CI and Flux CD form an auto-
mated build-to-deploy loop; configuration is organized as Kustomize base/overlays, with drift
detected systematically through continuous reconciliation. Migration proceeded in stages, with
each stage validated in a test zone before production cutover.
Results confirm that all 16 roles were migrated with the end-to-end inbound and outbound
mail paths preserved, that image and configuration changes flow entirely through Git without
manual intervention, and that the staged rollout exposed and fixed nine cross-component con-
figuration defects before cutover. The most operator-facing outcome is that the two most labor-
iii
intensive tasks —image updates and replica scaling —fall from minutes or tens of minutes of
per-host manual work to seconds of automated flow, an order-of-magnitude difference driven
structurally by collapsing per-machine repetition into a build-once, reuse-many pipeline. The
resource footprint changed asymmetrically: aggregate memory usage fell by roughly half while
aggregate CPU usage rose roughly four-fold, although the mail roles themselves grew by only
about 6% and the increase comes almost entirely from platform components, showing that the
resource case for containerization is dimension-specific rather than uniform. Three transferable
design principles are distilled from the implementation: pool-based IPAM for address-stable
stateful backends, staged integration testing as a systematic pre-cutover defect-exposure strat-
egy, and GitOps continuous reconciliation as a mechanism for configuration-drift detection.
The evaluation focuses on functional and operational verification; quantitative performance
comparison, including MTTR, is left to future work, and the approach targets on-premises en-
vironments with L2 adjacency between nodes and upstream routers (see Chapters 4 and 6 for
full limitations and applicability conditions).
顯示完整詮釋資料 統計資料

引用此條目

呂宗哲 (2026). 微服務架構郵件系統之 Kubernetes 與 GitOps 維運. https://thesis.lib.nycu.edu.tw/handle/20.500.14371/91083

BibTeX RIS

引用文字依 APA 第 7 版格式自動產生,使用前請再核對。

分享

永久網址:https://thesis.lib.nycu.edu.tw/handle/20.500.14371/91083