點解你需要 KSPM?
近年 Kubernetes 安全事故頻發 — 2025 年 Tesla 嘅 Kubernetes cluster 俾人入侵挖礦、2024 年 Sisense 因為 misconfigured RBAC 漏咗幾百 TB 客戶數據。KSPM(Kubernetes Security Posture Management)就係專門解決呢啲問題嘅自動化安全框架。
👉 延伸閱讀:Docker Container 安全加固 8 招實戰教學 — 由入門到進階
簡單講:KSPM 係一套自動掃描、評估、修正 Kubernetes 環境安全設定嘅工具。佢會持續監控你個 cluster 嘅 security posture — 包括 RBAC 權限、network policy、pod security context、secret management — 然後俾你一個分數同具體嘅修復建議。
KSPM vs CSPM 有咩分別?
好多人問 KSPM 同 CSPM(Cloud Security Posture Management)有咩唔同。其實係 focus 嘅層級唔同:
- CSPM 睇雲端 infra 層級 — S3 bucket 係咪 public、Security Group 開咗 0.0.0.0/0、IAM role 權限過大
- KSPM 專注 Kubernetes 內部 — pod 有冇 run as root、RBAC 有冇過度授權、network policy 係咪存在
- CNAPP 就係兩者合體 + workload protection + CI/CD scanning
一般中小型團隊未必需要 full CNAPP,但 KSPM 基本上係 must-have。
三大 KSPM 工具橫評
1. Kubescape(CNCF Sandbox 開源)
最早由 ARMO 開發,而家係 CNCF sandbox project。Kubescape 係第一隻 KSPM 開源工具,對標 NSA-CISA Kubernetes Hardening Guide 同 MITRE ATT&CK framework。
# 安裝 Kubescape
curl -s https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh | /bin/bash
# 掃描成個 cluster
kubescape scan --verbose
# 針對特定 namespace
kubescape scan --include-namespaces production
# 只掃 NSA framework
kubescape scan framework nsa
# 匯出 PDF 報告
kubescape scan --format pdf --output report.pdf
Kubescape 會俾每個 control 一個分數(passed/failed/excluded),最後計返一個整體 risk score。最正係佢內置咗幾百條 rule,由 RBAC、network policy、image scanning、到 secret 管理全部包晒。
適合:想快速入門、有 NSA/MITRE compliance 需求嘅團隊。
2. Trivy + Starboard(Aqua Security 開源)
Trivy 本身就係一個好強嘅 vulnerability scanner,配合 Starboard operator 就變身成 full KSPM 方案。Starboard 會自動喺你個 cluster 入面行 Trivy scan,然後將結果寫成 CRD(Custom Resource Definition)。
# 安裝 Starboard Operator
kubectl apply -f https://raw.githubusercontent.com/aquasecurity/starboard/v0.15.18/deploy/static/starboard.yaml
# Trivy scan + config audit 自動化
kubectl get vulnerabilityreports -A
kubectl get configauditreports -A
# 手動 trigger scan
kubectl label ns production starboard-scan=true
Trivy + Starboard 嘅賣點係 零 effort 持續掃描 — 每次有新 deployment 佢自動行 scan,唔需要靠 CI pipeline trigger。
適合:已經用緊 Trivy、想自動化持續掃描嘅團隊。
3. Cast AI KSPM(SaaS 方案)
Cast AI 本身係做 Kubernetes cost optimization 起家,最近推出 free tier KSPM 方案。賣點係 cloud-native UI、即時 dashboard、同自動修復建議。
適合:唔想自己 manage OSS tool、想要靚 dashboard 嘅團隊。
實戰 Checklist:5 步建立 KSPM
- Day 1:裝 Kubescape,行一次 full scan,睇下 baseline risk score 有幾多
- Day 2:fix critical + high severity findings,特別係 RBAC 過度授權同 privileged pods
- Day 3:deploy Starboard operator,自動化持續掃描
- Day 4:寫 admission controller(用 OPA/Gatekeeper 或 Kyverno)block insecure deployments
- Day 7:將 KSPM scan 結果整合入 Slack/Teams alert
記住:KSPM 係 continuous process,唔係 one-time scan。最理想係 KSPM scan → admission control → alert 三層防線一齊運作。
總結
K8s 安全唔係 option,係 requirement。KSPM 俾你一個起點 — 自動化發現問題 → 量化風險 → 持續修正。無論你用 Kubescape、Trivy+Starboard、定係 Cast AI,最緊要係 今日就開始。多一日 delay,就多一日 exposure。
#IT教學 #自動化 #Kubernetes #Security #安全



