Zero Trust Network là mô hình bảo mật theo nguyên tắc “never trust, always verify” — không service nào được tin tưởng mặc định chỉ vì nó đang chạy trong cùng cluster hay network. Mọi kết nối đều phải được xác thực và ủy quyền, bất kể nguồn gốc.

Trong Kubernetes, zero trust được thực hiện bằng cách kết hợp network policy (layer 3/4) với service mesh mTLS (layer 7), sử dụng workload identity thay vì IP address để xác định nguồn gốc request.

Tại sao cần Zero Trust trong K8s

Default Kubernetes: mọi pod trong cluster có thể giao tiếp với nhau. Nếu một pod bị compromise, attacker có thể lateral move sang toàn bộ cluster. Zero trust giới hạn blast radius — service A chỉ được nói chuyện với service B theo đúng protocol đã định nghĩa.

Hai approach chính

Approach 1: Calico + Istio (sidecar mode)

Calico xử lý network policy (L3/L4), Istio xử lý mTLS và authorization (L7).

  1. Cài Calico + enable Policy Sync API trên Felix
  2. Cài Istio, bật PeerAuthentication ở mode STRICT toàn cluster:
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
  name: default-strict-mode
  namespace: istio-system
spec:
  mtls:
    mode: STRICT
  1. Label namespace để inject Istio sidecar
  2. Thiết lập workload identity qua Kubernetes ServiceAccounts
  3. Viết allow-list policies theo ServiceAccount (deny-all by default, allow theo principle of least privilege):
# Chỉ ServiceAccount 'customer' được vào 'summary'
apiVersion: projectcalico.org/v3
kind: GlobalNetworkPolicy
spec:
  selector: app == 'summary'
  ingress:
    - action: Allow
      source:
        serviceAccounts:
          names: ["customer"]

Approach 2: Istio Ambient Mode

Ambient mode loại bỏ sidecar proxy — thay vào đó dùng ztunnel (node-level) cho mTLS L4, và waypoint proxy (optional) cho L7 policy. Nhẹ hơn về resource overhead so với sidecar.

  1. Cài Calico (CNI) + Istio ambient
  2. Label namespace: istio.io/dataplane-mode=ambient
  3. Define AuthorizationPolicy kiểm soát traffic theo principals (ServiceAccount SPIFFE URI):
apiVersion: security.istio.io/v1
kind: AuthorizationPolicy
spec:
  selector:
    matchLabels:
      app: httpbin
  action: ALLOW
  rules:
    - from:
        - source:
            principals:
              - cluster.local/ns/default/sa/sleep # chỉ sleep ServiceAccount

Thành phần cốt lõi

Thành phầnVai trò
Calico NetworkPolicyL3/L4 ingress/egress control
Istio PeerAuthentication (STRICT mTLS)Encrypt tất cả traffic, xác thực certificate
Istio AuthorizationPolicyL7 allow/deny theo identity, method, path
Kubernetes ServiceAccountWorkload identity — identity nguồn gốc của request
SPIFFE/SPIRECertificate issuance cho workload identity

Nguyên tắc triển khai

  • Deny-all by default — bắt đầu từ zero, explicit allow từng connection
  • Identity-based, not IP-based — IP thay đổi liên tục trong K8s; ServiceAccount là stable identity
  • Least privilege — mỗi service chỉ nhận traffic từ đúng callers cần thiết
  • Encrypt in transit — mTLS STRICT trên tất cả service-to-service communication

Connections

Sources

  • writing/setup_zero_trust_network_with_calico.md
  • writing/setup_zero_trust_network_with_istio_ambient.md