Development

Sealed Secrets & SOPS 2026: Kubernetes Secrets Management แบบ GitOps สำหรับ SME ไทย

เปรียบเทียบ Sealed Secrets และ SOPS สำหรับเข้ารหัส Kubernetes secrets เก็บใน Git อย่างปลอดภัย พร้อมตัวอย่าง ArgoCD GitOps workflow สำหรับ SME ไทย

AF
ADS FIT Team
·8 นาที
Share:
Sealed Secrets & SOPS 2026: Kubernetes Secrets Management แบบ GitOps สำหรับ SME ไทย

# Sealed Secrets & SOPS: คู่มือจัดการ Kubernetes Secrets แบบ GitOps สำหรับ SME ไทย 2026

ทีม DevOps ที่ใช้ Kubernetes มักเจอ dilemma ใหญ่: จะเก็บ secrets (passwords, API keys, certificates) ไว้ที่ไหน? เก็บใน Git ก็เสี่ยง expose, เก็บแยกใน Vault ก็เพิ่มความซับซ้อน, ใช้ kubectl create secret manual ก็ขัดกับหลัก GitOps

Sealed Secrets (Bitnami) และ SOPS (Mozilla) เป็นสองเครื่องมือ open-source ที่แก้ปัญหานี้ได้อย่างสะอาด ทั้งคู่ encrypt secret ก่อน commit เข้า Git ทำให้คุณ store ปลอดภัยใน repository พร้อม version control ครบถ้วน

ในคู่มือนี้คุณจะได้เรียนรู้ความแตกต่างระหว่าง Sealed Secrets กับ SOPS, เปรียบเทียบกับ HashiCorp Vault, ขั้นตอน install บน Kubernetes cluster และ best practices สำหรับ SME ไทยที่กำลังย้ายไปสู่ GitOps workflow

ทำไมต้อง Encrypt Secrets ใน Git?

Kubernetes Secret object มาตรฐานเก็บข้อมูลแบบ base64-encoded เท่านั้น ไม่ใช่ encrypted การ commit ไฟล์ secret.yaml เข้า Git เท่ากับว่าใครเปิด repo ก็อ่าน password ได้

ปัญหาที่ตามมา:

  • Engineer ลาออกแล้ว credentials ยังอยู่ใน Git history
  • Internal repo โดน leak ผ่าน 3rd-party tool integration
  • ไม่ผ่าน compliance audit (SOC 2, ISO 27001, PDPA)
  • Rotate credential ลำบาก เพราะต้อง search-and-replace ใน multiple files
  • ทางแก้คือ encrypt-at-rest ก่อนเข้า Git ซึ่งทั้ง Sealed Secrets และ SOPS ทำให้

    Sealed Secrets vs SOPS vs Vault

    | ปัจจัย | Sealed Secrets | SOPS | HashiCorp Vault |

    |--------|---------------|------|-----------------|

    | Owner | Bitnami (VMware) | Mozilla | HashiCorp |

    | Storage | encrypted YAML ใน Git | encrypted YAML/JSON ใน Git | external server |

    | Key Management | controller key in cluster | KMS / age / PGP | own key engine |

    | Decryption | controller in cluster | client-side (kubectl, ArgoCD) | API call to Vault server |

    | Multi-cluster | one key per cluster | shared key | central server |

    | Dynamic Secrets | No | No | Yes |

    | Audit Logging | basic | external (KMS log) | built-in |

    | Setup Complexity | low | low-medium | high |

    | ค่าใช้จ่าย | Free | Free | Free OSS / Paid Enterprise |

    เลือก Sealed Secrets ถ้า: ใช้ single cluster, ทีมคุ้น kubectl, อยากเริ่มเร็วที่สุด

    เลือก SOPS ถ้า: หลาย cluster แชร์ secret, ใช้ ArgoCD/Flux อยู่แล้ว, ต้องการ KMS integration (AWS KMS, GCP KMS, Azure Key Vault)

    เลือก Vault ถ้า: ต้องการ dynamic secrets (database creds rotate ทุก hour), centralized policy, ทีมขนาดใหญ่

    Sealed Secrets Quick Start

    Step 1: ติดตั้ง Controller บน Cluster

    ```bash

    helm repo add sealed-secrets https://bitnami-labs.github.io/sealed-secrets

    helm install sealed-secrets sealed-secrets/sealed-secrets \

    --namespace kube-system

    ```

    Step 2: ติดตั้ง CLI

    ```bash

    brew install kubeseal

    ```

    Step 3: Encrypt Secret

    ```bash

    # สร้าง regular secret (ห้าม commit)

    kubectl create secret generic db-creds \

    --from-literal=password=SuperSecret123 \

    --dry-run=client -o yaml > secret.yaml

    # encrypt ด้วย kubeseal

    kubeseal --format=yaml < secret.yaml > sealed-secret.yaml

    # ลบ original, commit เฉพาะ sealed

    rm secret.yaml

    git add sealed-secret.yaml && git commit -m "Add db creds"

    ```

    ไฟล์ sealed-secret.yaml จะ encrypted สามารถ commit เข้า public repo ได้โดยปลอดภัย controller ใน cluster เท่านั้นที่ decrypt ได้

    SOPS + age GitOps Workflow

    Step 1: Generate age Keypair

    ```bash

    brew install sops age

    age-keygen -o ~/.config/sops/age/keys.txt

    # Public key: age1abc...xyz

    ```

    Step 2: Configure SOPS

    สร้าง .sops.yaml ที่ root ของ repo:

    ```yaml

    creation_rules:

  • path_regex: 'secrets/.*\.yaml$'
  • age: 'age1abc...xyz'

    ```

    Step 3: Encrypt In-Place

    ```bash

    # encrypt

    sops --encrypt --in-place secrets/db-creds.yaml

    # edit (auto-decrypt + re-encrypt)

    sops secrets/db-creds.yaml

    # decrypt for local use

    sops --decrypt secrets/db-creds.yaml | kubectl apply -f -

    ```

    Step 4: ArgoCD Integration

    ใช้ ksops plugin ให้ ArgoCD decrypt SOPS-encrypted manifests อัตโนมัติเวลา sync — secrets อยู่ใน Git แต่ deployed plain Kubernetes Secret

    Use Case สำหรับ SME ไทย

  • **E-commerce — Multi-environment**: ทีม 5 คนใช้ SOPS + age key เก็บ Stripe API key, MySQL password, JWT secret ของ dev/staging/prod ใน Git repo เดียว แชร์ผ่าน 1Password ตอน onboard developer ใหม่
  • **FinTech — Compliance**: ทีมใช้ SOPS + AWS KMS — KMS log ทุก decrypt event ลง CloudTrail ผ่าน SOC 2 audit ได้ง่าย
  • **Hospital — On-prem K8s**: ใช้ Sealed Secrets เก็บ HL7 integration credentials ใน internal Git, controller-key อยู่บน on-prem cluster, ไม่ต้องเชื่อม cloud KMS
  • Best Practices

  • **Never commit unencrypted secrets** ใช้ pre-commit hook หรือ git-secrets ตรวจจับ
  • **Rotate keys regularly** sealed-secrets controller มี built-in 30-day rotation
  • **Backup keys ออกนอก cluster** ถ้า cluster crash แล้ว key หาย จะ decrypt ไม่ได้
  • **Use namespace scoping** Sealed Secret ผูกกับ namespace, ไม่สามารถย้ายไปใช้ namespace อื่น
  • **Audit decrypt events** เปิด Kubernetes audit log + KMS log
  • **อย่าเก็บ secret ใหญ่** ถ้าเกิน 1 MB ให้ใช้ external secret store แทน
  • สรุป + Call to Action

    Sealed Secrets และ SOPS คือสองเครื่องมือที่ทำให้ GitOps workflow เก็บ secrets ใน Git ได้อย่างปลอดภัย เลือกตาม scale: Sealed Secrets เริ่มเร็วสำหรับ single cluster, SOPS ยืดหยุ่นกว่าสำหรับ multi-cluster + KMS, Vault สำหรับองค์กรใหญ่ที่ต้องการ dynamic secrets

    Key takeaways:

  • Kubernetes Secret = base64 only, NOT encrypted ห้าม commit เข้า Git
  • Sealed Secrets = controller-based, ง่าย, เหมาะ single cluster
  • SOPS + age/KMS = client-side, ยืดหยุ่นกว่า, เหมาะกับ ArgoCD/Flux GitOps
  • Backup key เสมอ key หาย = secrets อ่านไม่ได้
  • ต้องการเริ่ม GitOps + Kubernetes ที่ปลอดภัย? ติดต่อ ADS FIT เพื่อรับคำปรึกษา หรืออ่านบทความเรื่อง [HashiCorp Vault Secrets Management](https://www.adsfit.co.th/blog/hashicorp-vault-secrets-management-guide-sme-thailand-2026) เพื่อเปรียบเทียบทางเลือก enterprise

    Tags

    #Sealed Secrets#SOPS#Kubernetes#GitOps#DevOps#Secrets Management

    สนใจโซลูชันนี้?

    ปรึกษาทีม ADS FIT ฟรี เราพร้อมออกแบบระบบที่ฟิตกับธุรกิจของคุณ

    ติดต่อเรา →

    บทความที่เกี่ยวข้อง