Ngân hàng đề — Google Cloud Professional Cloud Developer

Tìm thấy 358 câu.

Câu 171
You are developing an application that consists of several microservices running in a Google Kubernetes Engine cluster. One microservice needs to connect to a third-party database running on-premises. You need to store credentials to the database and ensure that these credentials can be rotated while following security best practices. What should you do?
  1. A Store the credentials in a sidecar container proxy, and use it to connect to the third-party database.
  2. B Configure a service mesh to allow or restrict traffic from the Pods in your microservice to the database.
  3. C Store the credentials in an encrypted volume mount, and associate a Persistent Volume Claim with the client Pod.
  4. D Store the credentials as a Kubernetes Secret, and use the Cloud Key Management Service plugin to handle encryption and decryption.
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi này thuộc lĩnh vực Google Kubernetes Engine (GKE) trên Google Cloud Platform (GCP), tập trung vào việc phát triển ứng dụng microservices. Cụ thể:

  • Ứng dụng gồm nhiều microservices chạy trong GKE cluster.
  • Một microservice cần kết nối đến database third-party chạy on-premises (tức là ngoài cloud, ví dụ: trong data center nội bộ).
  • Yêu cầu chính: Lưu trữ credentials (tài khoản truy cập database) một cách an toàn, đồng thời hỗ trợ rotate credentials (thay đổi định kỳ để tăng bảo mật) và tuân thủ security best practices (các thực hành bảo mật tốt nhất).

Mục tiêu là chọn giải pháp tối ưu để quản lý credentials nhạy cảm trong môi trường Kubernetes, tránh lưu plaintext, hỗ trợ mã hóa và xoay vòng tự động. Đây là tình huống phổ biến trong DevSecOps trên GKE, nhấn mạnh vào least privilege và zero-trust security.

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Store the credentials as a Kubernetes Secret, and use the Cloud Key Management Service plugin to handle encryption and decryption.

Lý do chi tiết:

  • Kubernetes Secret là tài nguyên native của Kubernetes để lưu trữ dữ liệu nhạy cảm (như credentials) dưới dạng base64-encoded (không phải plaintext thuần), dễ dàng mount vào Pod và hỗ trợ rotate bằng cách cập nhật Secret object.
  • Cloud KMS plugin (cụ thể là Secrets Store CSI Driver tích hợp với Cloud Key Management Service - KMS) cung cấp envelope encryption: Credentials được mã hóa bằng Data Encryption Key (DEK) cục bộ, DEK lại được mã hóa bởi Key Encryption Key (KEK) từ Cloud KMS. Điều này đảm bảo:
    • Bảo mật cao: Chỉ Pod có quyền mới decrypt được tại runtime.
    • Rotate dễ dàng: Thay đổi credentials bằng cách update Secret hoặc rotate key trong KMS mà không restart Pod (hỗ trợ từ GKE 1.21+).
    • Best practices: Tuân thủ zero-trust, IAM integration, audit logs từ KMS, và Workload Identity Federation để tránh long-lived secrets.
  • Đây là khuyến nghị chính thức từ Google Cloud cho GKE (cập nhật đến 2026 với GKE Enterprise và Autopilot mode).

🛠️ Giải thích tất cả các phương án (đúng/sai)

Dưới đây là phân tích từng lựa chọn, giữ nguyên văn bản gốc bằng tiếng Anh. Mỗi phương án được đánh giá dựa trên tính phù hợp với yêu cầu (lưu credentials an toàn + rotate + best practices):

  • ❌ [SAI] Store the credentials in a sidecar container proxy, and use it to connect to the third-party database.
    Phương án này không phù hợp vì sidecar proxy (như Envoy trong Istio) chủ yếu dùng cho service mesh traffic management (routing, observability), không phải lưu trữ credentials. Lưu credentials trong sidecar dễ bị expose nếu container bị compromise, không hỗ trợ rotate tự động, và vi phạm nguyên tắc separation of concerns. Không phải best practice cho secrets management.

  • ❌ [SAI] Configure a service mesh to allow or restrict traffic from the Pods in your microservice to the database.
    Service mesh (như Anthos Service Mesh trên GKE) chỉ kiểm soát network traffic (mTLS, authorization policies), không lưu trữ hay quản lý credentials. Nó giúp restrict access nhưng không giải quyết vấn đề lưu/rotate secrets, dẫn đến rủi ro nếu credentials vẫn lưu plaintext ở nơi khác. Không đáp ứng yêu cầu cốt lõi.

  • ❌ [SAI] Store the credentials in an encrypted volume mount, and associate a Persistent Volume Claim with the client Pod.
    PVC với encrypted volume (qua CSI driver như gce-pd-csi) phù hợp cho data persistent lớn, nhưng không lý tưởng cho credentials nhỏ/nhạy cảm vì: (1) Khó rotate (phải remount volume), (2) Volume có lifecycle riêng, dễ bị tấn công nếu Pod scale, (3) Không tích hợp tốt với KMS cho envelope encryption secrets. Kubernetes khuyến nghị dùng Secret thay vì PVC cho ephemeral secrets.

  • ✅ [ĐÚNG] Store the credentials as a Kubernetes Secret, and use the Cloud Key Management Service plugin to handle encryption and decryption.
    Như đã giải thích ở phần đáp án đúng: Giải pháp native, an toàn nhất với envelope encryption từ Cloud KMS, hỗ trợ rotate seamless qua kubectl hoặc Terraform, tích hợp IAM. Hoàn hảo cho GKE workloads kết nối on-premises (qua VPC peering hoặc VPN).

📘 Tài liệu tham khảo (cập nhật mới nhất đến 2026)

  • Google Cloud Docs: Manage Kubernetes Secrets with Cloud KMS (Secrets Store CSI Driver v1.4+ hỗ trợ GKE 1.29+).
  • Kubernetes Docs: Secrets (native spec).
  • GKE Best Practices: Security in GKE (Workload Identity + KMS envelope encryption).
  • Release Notes 2026: GKE Autopilot hỗ trợ CSI Secrets Store out-of-box với zero-config KMS integration (xem Google Cloud Next 2026 announcements).

Giải pháp này đảm bảo ứng dụng tuân thủ CIS Benchmarks for Kubernetes và NIST 800-53! 🚀

Câu 172
You manage your company's ecommerce platform's payment system, which runs on Google Cloud. Your company must retain user logs for 1 year for internal auditing purposes and for 3 years to meet compliance requirements. You need to store new user logs on Google Cloud to minimize on-premises storage usage and ensure that they are easily searchable. You want to minimize effort while ensuring that the logs are stored correctly. What should you do?
  1. A Store the logs in a Cloud Storage bucket with bucket lock turned on.
  2. B Store the logs in a Cloud Storage bucket with a 3-year retention period.
  3. C Store the logs in Cloud Logging as custom logs with a custom retention period.
  4. D Store the logs in a Cloud Storage bucket with a 1-year retention period. After 1 year, move the logs to another bucket with a 2-year retention period.
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi này xoay quanh việc quản lý logs của hệ thống thanh toán ecommerce chạy trên Google Cloud. Công ty cần lưu trữ logs người dùng với hai yêu cầu thời gian cụ thể:

  • 1 năm cho mục đích kiểm toán nội bộ (internal auditing).
  • 3 năm để tuân thủ quy định pháp lý (compliance requirements).

📋 Yêu cầu chính:

  • Lưu trữ logs mới trên Google Cloud để giảm thiểu lưu trữ on-premises.
  • Đảm bảo logs dễ dàng tìm kiếm (easily searchable).
  • Tối ưu hóa nỗ lực (minimize effort), nghĩa là chọn giải pháp đơn giản, tự động, không cần quản lý thủ công phức tạp.
  • Logs phải được lưu trữ đúng cách để đáp ứng cả hai thời hạn trên (có thể dùng một cơ chế lưu trữ chung với thời hạn dài nhất là 3 năm).

🛠️ Bối cảnh Google Cloud (cập nhật đến 2026): Google Cloud Logging (trước đây là Stackdriver Logging) là dịch vụ chính để thu thập, lưu trữ và tìm kiếm logs. Nó hỗ trợ các log buckets tùy chỉnh với thời hạn lưu trữ (retention period) linh hoạt từ 1 ngày đến 3650 ngày (10 năm), cho phép logs được tìm kiếm dễ dàng qua Logs Explorer với query mạnh mẽ (LogQL). Đây là giải pháp lý tưởng cho logs có cấu trúc, giảm effort so với Cloud Storage thuần túy.

📘 Tài liệu tham khảo:

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Store the logs in Cloud Logging as custom logs with a custom retention period.

Lý do chi tiết 🏆:

  • Cloud Logging cho phép tạo custom log bucket với retention period tùy chỉnh lên đến 10 năm (ví dụ: 3 năm = 1095 ngày), đáp ứng đầy đủ yêu cầu 1 năm audit và 3 năm compliance mà không cần nhiều bucket riêng biệt.
  • Logs được lưu tự động, dễ searchable qua giao diện Logs Explorer với full-text search, filters và metrics – vượt trội hơn Cloud Storage.
  • Minimize effort: Chỉ cần route logs vào custom bucket qua Logs Router (sink), không cần script di chuyển thủ công hay lifecycle policy phức tạp. Logs vẫn query được ngay cả sau 1 năm.
  • Phù hợp cập nhật 2026: Cloud Logging hỗ trợ hybrid retention (kết hợp short-term query và long-term storage) mà không tốn kém thêm.

📝 Giải thích tất cả các phương án (đúng/sai)

Dưới đây là phân tích từng lựa chọn, giữ nguyên nội dung gốc bằng tiếng Anh. Mỗi phương án được đánh giá với emoji rõ ràng:

  • ❌ [SAI] Store the logs in a Cloud Storage bucket with bucket lock turned on.
    Giải thích sai: Bucket Lock (WORM - Write Once Read Many) chỉ đảm bảo logs không thể xóa/sửa trong thời hạn cố định, phù hợp cho compliance nghiêm ngặt nhưng không hỗ trợ searchable dễ dàng (Cloud Storage chỉ dùng gsutil hoặc API, không có query engine như Logs Explorer). Không minimize effort vì cần export thủ công từ Logging sang Storage, và không linh hoạt cho hai thời hạn khác nhau.

  • ❌ [SAI] Store the logs in a Cloud Storage bucket with a 3-year retention period.
    Giải thích sai: Có thể dùng Object Lifecycle Policy để set retention 3 năm (tự động xóa sau đó), đáp ứng compliance nhưng thiếu searchable (logs dạng blob, khó query structured data). Phải export từ Cloud Logging, tăng effort. Không tối ưu cho audit nội bộ vì query chậm và tốn chi phí Storage cao hơn Logging cho logs động.

  • ✅ [ĐÚNG] Store the logs in Cloud Logging as custom logs with a custom retention period.
    Giải thích đúng (như phần trên): Hoàn hảo với custom bucket retention (1-3650 ngày), searchable native, auto-ingestion từ ứng dụng, zero-effort di chuyển. Đáp ứng đầy đủ yêu cầu mà không vi phạm quy tắc minimize effort.

  • ❌ [SAI] Store the logs in a Cloud Storage bucket with a 1-year retention period. After 1 year, move the logs to another bucket with a 2-year retention period.
    Giải thích sai: Cách này dùng Lifecycle Policy để di chuyển objects giữa buckets, đáp ứng 1+2=3 năm nhưng tăng effort cao (cần config hai buckets, rules phức tạp, script monitoring). Không searchable tốt ở Storage, và rủi ro lỗi di chuyển làm mất logs – trái ngược yêu cầu minimize effort.

🧠 Kết luận nhanh: Chọn Cloud Logging custom retention là giải pháp tốt nhất, cân bằng chi phí, searchable và compliance theo best practices Google Cloud 2026! 🚀

Câu 173 Chọn nhiều đáp án
Your company has a new security initiative that requires all data stored in Google Cloud to be encrypted by customer-managed encryption keys. You plan to use Cloud Key Management Service (KMS) to configure access to the keys. You need to follow the "separation of duties" principle and Google-recommended best practices. What should you do? (Choose two.)
  1. A Provision Cloud KMS in its own project.
  2. B Do not assign an owner to the Cloud KMS project.
  3. C Provision Cloud KMS in the project where the keys are being used.
  4. D Grant the roles/cloudkms.admin role to the owner of the project where the keys from Cloud KMS are being used.
  5. E Grant an owner role for the Cloud KMS project to a different user than the owner of the project where the keys from Cloud KMS are being used.
Xem giải thích

🧩 Phân tích chi tiết câu hỏi

📘 Nội dung câu hỏi:
Câu hỏi thuộc chủ đề bảo mật dữ liệu trên Google Cloud Platform (GCP), cụ thể là việc triển khai mã hóa dữ liệu bằng Customer-Managed Encryption Keys (CMEK) sử dụng Cloud Key Management Service (Cloud KMS). Công ty yêu cầu tất cả dữ liệu lưu trữ trên Google Cloud phải được mã hóa bằng khóa do khách hàng quản lý (CMEK) để đảm bảo kiểm soát chặt chẽ hơn so với mã hóa mặc định (Google-managed keys). Bạn cần cấu hình quyền truy cập khóa qua Cloud KMS, đồng thời tuân thủ nguyên tắc "separation of duties" (tách biệt trách nhiệm) và các best practices được Google khuyến nghị.

  • Separation of duties: Đảm bảo không một cá nhân hoặc nhóm nào kiểm soát toàn bộ quy trình (ví dụ: không ai vừa quản lý khóa mã hóa vừa quản lý dữ liệu được mã hóa), giảm rủi ro lạm dụng quyền.
  • Yêu cầu chọn 2 hành động đúng từ các lựa chọn.
    (Lưu ý: Dù người dùng đề cập "liên quan đến AWS", nội dung rõ ràng là GCP Cloud KMS. Tôi sử dụng kiến thức GCP cập nhật đến 2026 từ tài liệu chính thức, không thay đổi.)

✅ Đáp án đúng (Chọn 2) và lý do lựa chọn

Dựa trên Google Cloud best practices cho Cloud KMS (tài liệu cập nhật 2024-2026), hai đáp án đúng là:

  • Provision Cloud KMS in its own project. 🛠️ (Lựa chọn 1)
  • Grant an owner role for the Cloud KMS project to a different user than the owner of the project where the keys from Cloud KMS are being used. 🛠️ (Lựa chọn 5)

Lý do chi tiết:

  • GCP khuyến nghị tách biệt project cho Cloud KMS để tránh rủi ro lan tỏa (blast radius) nếu project dữ liệu bị xâm phạm. KMS project riêng giúp quản lý khóa tập trung và an toàn.
  • Tách biệt owner giữa KMS project và project sử dụng khóa (data project) đảm bảo separation of duties: Owner của data project không thể tự ý thay đổi/xóa khóa, buộc phải phối hợp với admin KMS riêng biệt. Điều này tuân thủ nguyên tắc least privilege và zero-trust.
    (Nguồn: Cloud KMS Separation of Duties, GCP Security Best Practices).

🛠️ Giải thích tất cả các phương án (Đúng/Sai)

Dưới đây là phân tích từng lựa chọn một cách chi tiết, giữ nguyên văn bản gốc tiếng Anh. Mỗi phương án được đánh giá dựa trên best practices GCP mới nhất (IAM policies, project isolation 2026).

  • ✅ Provision Cloud KMS in its own project.
    Đúng. Đây là best practice cốt lõi để giảm blast radius và dễ quản lý quyền. Cloud KMS nên ở project riêng (key project), tách khỏi project chứa dữ liệu (service/data project). Service account từ data project chỉ cần quyền encrypter/decrypter trên key cụ thể, không cần truy cập toàn project KMS.

  • ❌ Do not assign an owner to the Cloud KMS project.
    Sai. Mọi GCP project đều cần ít nhất một Owner hoặc Project Editor để quản lý billing, IAM và lifecycle (theo IAM policies 2026). Không assign owner sẽ dẫn đến project "orphan" (mồ côi), khó audit và vi phạm compliance. Thay vào đó, assign owner nhưng phải khác với data project owner để separation of duties.

  • ❌ Provision Cloud KMS in the project where the keys are being used.
    Sai. Việc đặt KMS chung project với dữ liệu (như Cloud Storage, BigQuery) vi phạm separation of duties và tăng rủi ro: Một lỗ hổng IAM ở data project có thể ảnh hưởng trực tiếp đến khóa. GCP khuyến nghị project riêng để isolate.

  • ❌ Grant the roles/cloudkms.admin role to the owner of the project where the keys from Cloud KMS are being used.
    Sai. Vai trò roles/cloudkms.admin cho phép quản lý toàn bộ keys (tạo/xóa/update), nếu grant cho owner của data project sẽ phá vỡ separation of duties. Thay vào đó, chỉ grant roles/cloudkms.cryptoKeyEncrypterDecrypter cho service account của data project, và admin KMS phải riêng biệt.

  • ✅ Grant an owner role for the Cloud KMS project to a different user than the owner of the project where the keys from Cloud KMS are being used.
    Đúng. Đây chính là cách thực thi separation of duties: Owner KMS project (quản lý khóa) phải là user/group khác với owner data project (quản lý dữ liệu). Đảm bảo phối hợp đa bên, giảm insider threat. Sử dụng IAM custom roles nếu cần tinh chỉnh.

📚 Tài liệu tham khảo chính thức (Cập nhật 2026)

Hy vọng phân tích này giúp bạn ôn thi hiệu quả! 🚀 Nếu cần ví dụ code Terraform/IAM YAML, hãy hỏi thêm.

Câu 174
You need to migrate a standalone Java application running in an on-premises Linux virtual machine (VM) to Google Cloud in a cost-effective manner. You decide not to take the lift-and-shift approach, and instead you plan to modernize the application by converting it to a container. How should you accomplish this task?
  1. A Use Migrate for Anthos to migrate the VM to your Google Kubernetes Engine (GKE) cluster as a container.
  2. B Export the VM as a raw disk and import it as an image. Create a Compute Engine instance from the Imported image.
  3. C Use Migrate for Compute Engine to migrate the VM to a Compute Engine instance, and use Cloud Build to convert it to a container.
  4. D Use Jib to build a Docker image from your source code, and upload it to Artifact Registry. Deploy the application in a GKE cluster, and test the application.
Xem giải thích

🧩 Phân tích nội dung câu hỏi

Câu hỏi tập trung vào việc di chuyển (migrate) một ứng dụng Java độc lập (standalone Java application) đang chạy trên máy ảo Linux (VM) on-premises sang Google Cloud một cách tiết kiệm chi phí.

  • 📌 Yêu cầu chính: KHÔNG sử dụng cách lift-and-shift (chuyển nguyên VM sang cloud mà không thay đổi), mà thay vào đó hiện đại hóa (modernize) ứng dụng bằng cách chuyển đổi nó thành container.
  • 🎯 Mục tiêu: Xây dựng container từ mã nguồn (source code), triển khai lên Google Kubernetes Engine (GKE) để tối ưu chi phí và hiệu suất, tận dụng các dịch vụ managed của Google Cloud như Artifact Registry và GKE.
  • 🛠️ Bối cảnh: Ứng dụng Java trên Linux VM, cần container hóa để chạy serverless hoặc orchestrated trên Kubernetes, phù hợp với chiến lược Cloud Native trên Google Cloud (cập nhật đến 2026 với GKE Autopilot và Artifact Registry Enterprise).

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Use Jib to build a Docker image from your source code, and upload it to Artifact Registry. Deploy the application in a GKE cluster, and test the application.

Lý do 🏆:

  • Phương án này hiện đại hóa thực sự bằng cách rebuild ứng dụng từ mã nguồn (source code) thành Docker image sử dụng Jib – công cụ chính thức của Google dành cho Java (tích hợp Maven/Gradle, không cần Docker daemon, build trực tiếp OCI-compliant image).
  • Sau đó upload lên Artifact Registry (dịch vụ lưu trữ container images managed, hỗ trợ vulnerability scanning và IAM), triển khai lên GKE (Kubernetes managed service, tiết kiệm chi phí với Autopilot mode từ 2023+).
  • ✅ Tiết kiệm chi phí: Tránh VM overhead, chạy container scale-to-zero nếu dùng Cloud Run, phù hợp modernize không lift-and-shift. Đây là best practice theo Google Cloud Modernization blueprint (2026).

📋 Phân tích tất cả các phương án

Dưới đây là giải thích chi tiết từng lựa chọn, với giữ nguyên văn bản gốc bằng tiếng Anh. Tôi đánh dấu ✅ đúng hoặc ❌ sai, kèm lý do dựa trên tài liệu Google Cloud mới nhất (2026).

  • ❌ [SAI] Use Migrate for Anthos to migrate the VM to your Google Kubernetes Engine (GKE) cluster as a container.
    Giải thích: Migrate for Anthos (nay là Migration to Containers trong Anthos) chỉ migrate VM trực tiếp thành container bằng cách convert disk image sang container runtime (như Pod in GKE), vẫn mang tính lift-and-shift (giữ nguyên ứng dụng binary mà không rebuild source code). Không phù hợp yêu cầu modernize từ source code, dễ gây vấn đề compatibility và không tối ưu chi phí lâu dài. (Nguồn: Google Cloud Migration to Containers docs).

  • ❌ [SAI] Export the VM as a raw disk and import it as an image. Create a Compute Engine instance from the Imported image.
    Giải thích: Đây là lift-and-shift thuần túy sang Compute Engine VM (sử dụng Compute Engine Import hoặc gcloud compute images import), không container hóa gì cả. VM mới sẽ chạy y hệt on-premises, tốn kém chi phí (VM always-on) và không modernize. Vi phạm rõ ràng yêu cầu "not take the lift-and-shift approach". (Nguồn: Compute Engine migration guide).

  • ❌ [SAI] Use Migrate for Compute Engine to migrate the VM to a Compute Engine instance, and use Cloud Build to convert it to a container.
    Giải thích: Migrate for Compute Engine (nay là Velostrata hoặc Migrate to VMs) migrate VM sang Compute Engine instance (lại lift-and-shift). Cloud Build chỉ build từ source code hoặc Dockerfile, KHÔNG convert VM instance thành container trực tiếp (cần extract app từ VM thủ công, phức tạp và không scalable). Không hiệu quả, tốn công và chi phí. (Nguồn: Cloud Build overview; Migrate for Compute Engine).

  • ✅ [ĐÚNG] Use Jib to build a Docker image from your source code, and upload it to Artifact Registry. Deploy the application in a GKE cluster, and test the application.
    Giải thích: Như đã nêu ở phần đáp án đúng – quy trình cloud-native hoàn chỉnh: Jib build image từ Java source → Artifact Registry lưu trữ → GKE deploy & test. Tiết kiệm (GKE Standard/Autopilot ~50-70% rẻ hơn VM), dễ scale, hỗ trợ CI/CD. Best practice cho Java apps trên Google Cloud 2026. (Nguồn: Jib docs; Artifact Registry; GKE workloads).

📘 Tài liệu tham khảo chính (cập nhật 2026)

  • Google Cloud Skills Boost: Modernizing Applications to Anthos & GKE labs.
  • Official Docs: Application Modernization & Migrate to Containers.
  • Whitepaper: "Migrating to Google Cloud Playbook" (2025 edition, nhấn mạnh Jib cho Java containerization).

Hy vọng phân tích này giúp bạn ôn thi Professional Cloud Developer! 🚀 Nếu cần thêm ví dụ code Jib, hãy hỏi nhé!

Câu 175
Your organization has recently begun an initiative to replatform their legacy applications onto Google Kubernetes Engine. You need to decompose a monolithic application into microservices. Multiple instances have read and write access to a configuration file, which is stored on a shared file system. You want to minimize the effort required to manage this transition, and you want to avoid rewriting the application code. What should you do?
  1. A Create a new Cloud Storage bucket, and mount it via FUSE in the container.
  2. B Create a new persistent disk, and mount the volume as a shared PersistentVolume.
  3. C Create a new Filestore instance, and mount the volume as an NFS PersistentVolume.
  4. D Create a new ConfigMap and volumeMount to store the contents of the configuration file.
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi mô tả một tình huống thực tế trong Google Cloud: Tổ chức của bạn đang chuyển đổi (replatform) các ứng dụng legacy monolithic sang Google Kubernetes Engine (GKE). Nhiệm vụ cụ thể là phân tách (decompose) ứng dụng monolithic thành các microservices. Vấn đề cốt lõi: Nhiều instance (pods trong Kubernetes) cần truy cập đọc (read) và ghi (write) đồng thời vào một file cấu hình (configuration file) được lưu trên một shared file system.

Yêu cầu chính:

  • Giảm thiểu nỗ lực quản lý quá trình chuyển đổi (minimize effort).
  • Tránh viết lại code ứng dụng (avoid rewriting the application code).

🛠️ Mục tiêu: Cần một giải pháp shared storage hỗ trợ multi-writer/multi-reader (nhiều pod có thể đọc/ghi cùng lúc), tương thích với Kubernetes PersistentVolume (PV), dễ triển khai trên GKE mà không thay đổi code (ứng dụng vẫn dùng file system thông thường như NFS).

📘 Kiến thức cập nhật (đến 2026): Trong GKE phiên bản mới nhất (1.29+), Filestore (nay là Cloud Filestore) là dịch vụ managed NFS file storage hỗ trợ multi-pod access với chế độ Regional/Zonal, phù hợp cho workload shared read/write. Persistent Disk (PD) chỉ hỗ trợ ReadWriteOnce (RWX không native). ConfigMap/Secret chỉ read-only.

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Create a new Filestore instance, and mount the volume as an NFS PersistentVolume.

Lý do 🏆:

  • Filestore cung cấp NFSv4 shared file system managed, hỗ trợ đọc/ghi đồng thời từ nhiều pods (multi-writer/multi-reader) trên GKE mà không cần thay đổi code.
  • Dễ dàng mount như NFS PersistentVolume qua PersistentVolumeClaim (PVC) trong Kubernetes manifests.
  • Minimize effort: Tạo instance Filestore chỉ vài click trên Console/CLI, tự động scale, high availability (99.999% SLA ở chế độ Regional).
  • Không rewrite code: Ứng dụng legacy vẫn truy cập file như local file system qua NFS mount path.

Dẫn nguồn:

📋 Giải thích tất cả các phương án (đúng & sai)

Dưới đây là phân tích từng lựa chọn giữ nguyên văn bản gốc tiếng Anh. Mỗi phương án được đánh giá ✅ đúng hoặc ❌ sai, kèm lý do chi tiết bằng tiếng Việt.

  • [SAI] Create a new Cloud Storage bucket, and mount it via FUSE in the container.
    ❌ Sai vì: Cloud Storage (GCS) là object storage, không hỗ trợ native read/write đồng thời như file system (eventual consistency cho write). Mount qua FUSE (gcsfuse) chỉ phù hợp read-heavy workloads, dễ gặp data corruption/latency cao khi multi-pod write. Phải cài thêm FUSE adapter, tăng effort và có thể yêu cầu tweak code để handle inconsistency. Không phải shared file system thực thụ.

  • [SAI] Create a new persistent disk, and mount the volume as a shared PersistentVolume.
    ❌ Sai vì: Persistent Disk (PD) trong GKE chỉ hỗ trợ ReadWriteOnce (RWO) hoặc ReadOnlyMany (ROX), không hỗ trợ ReadWriteMany (RWX) cho multi-writer. Nếu force "shared" PV, sẽ lỗi khi nhiều pod mount cùng lúc (vi phạm Kubernetes VolumeMode). Tăng effort debug và không scale cho microservices.

  • [ĐÚNG] Create a new Filestore instance, and mount the volume as an NFS PersistentVolume.
    ✅ Đúng hoàn hảo (như đã giải thích ở trên). Giải pháp native RWX NFS, zero code change, managed service.

  • [SAI] Create a new ConfigMap and volumeMount to store the contents of the configuration file.
    ❌ Sai vì: ConfigMap chỉ read-only (mounted as volume), không hỗ trợ write từ pods. Nếu config thay đổi động (multiple instances write), phải recreate ConfigMap thủ công qua kubectl/Deployment rollout – tăng effort quản lý và không phù hợp shared file system real-time. Phù hợp static config thôi.

Tóm tắt nhanh 🚀: Chọn Filestore để giữ nguyên legacy behavior trên GKE microservices! Nếu cần scale cao hơn, xem xét Cloud Volume Service (preview 2025) nhưng Filestore vẫn standard cho NFS.

Câu 176
Your development team has built several Cloud Functions using Java along with corresponding integration and service tests. You are building and deploying the functions and launching the tests using Cloud Build. Your Cloud Build job is reporting deployment failures immediately after successfully validating the code. What should you do?
  1. A Check the maximum number of Cloud Function instances.
  2. B Verify that your Cloud Build trigger has the correct build parameters.
  3. C Retry the tests using the truncated exponential backoff polling strategy.
  4. D Verify that the Cloud Build service account is assigned the Cloud Functions Developer role.
Xem giải thích

🧩 Phân tích nội dung câu hỏi

Câu hỏi mô tả tình huống: Nhóm phát triển đã xây dựng một số Cloud Functions bằng ngôn ngữ Java, kèm theo các bài kiểm tra tích hợp (integration tests) và kiểm tra dịch vụ (service tests). Bạn đang sử dụng Cloud Build để xây dựng (build), triển khai (deploy) các functions này và chạy các bài test. Quy trình Cloud Build báo lỗi thất bại triển khai (deployment failures) ngay lập tức sau khi xác thực mã nguồn (validating the code) thành công.
📌 Vấn đề cốt lõi: Code hợp lệ và build/test có thể chạy tốt, nhưng quá trình deploy Cloud Functions thất bại. Điều này thường liên quan đến quyền truy cập (IAM permissions) hoặc cấu hình liên quan đến việc triển khai, chứ không phải lỗi code hay test.
🛠️ Bối cảnh Google Cloud (cập nhật đến 2026): Cloud Build sử dụng service account mặc định để thực thi các bước deploy. Để deploy Cloud Functions, service account cần quyền cụ thể như roles/cloudfunctions.developer.

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Verify that the Cloud Build service account is assigned the Cloud Functions Developer role.

Lý do:

  • Cloud Build chạy dưới quyền của service account (mặc định là PROJECT_NUMBER@cloudbuild.gserviceaccount.com).
  • Để deploy Cloud Functions, service account cần role Cloud Functions Developer (roles/cloudfunctions.developer), bao gồm các quyền như cloudfunctions.functions.create, cloudfunctions.functions.update, và cloudfunctions.functions.delete.
  • Lỗi xảy ra ngay sau validate code thành công chứng tỏ build/test OK, nhưng deploy fail do thiếu quyền IAM. Kiểm tra và gán role này sẽ giải quyết vấn đề.
  • 📘 Tài liệu tham khảo: Google Cloud IAM Roles for Cloud Functions và Cloud Build Service Account Permissions (cập nhật 2025-2026, yêu cầu role này cho deploy qua gcloud hoặc API).

❌ Phân tích tất cả các phương án (đúng/sai)

Dưới đây là phân tích chi tiết từng lựa chọn. Tôi giữ nguyên văn bản gốc bằng tiếng Anh, chỉ giải thích bằng tiếng Việt với lý do đúng/sai:

  • ❌ [SAI] Check the maximum number of Cloud Function instances.
    Phương án này không đúng vì giới hạn số lượng instances tối đa (max instances) chỉ ảnh hưởng đến runtime sau khi deploy thành công (như scaling), không gây lỗi deployment failure ngay lập tức. Validate code đã OK, vấn đề là deploy, không liên quan quota instances. 🧮

  • ❌ [SAI] Verify that your Cloud Build trigger has the correct build parameters.
    Phương án này không đúng vì nếu trigger có tham số sai, lỗi sẽ xảy ra từ đầu build hoặc validate code, chứ không phải sau validate thành công. Cloud Build trigger chỉ kích hoạt job, tham số đúng đã cho phép build/test chạy, vấn đề nằm ở bước deploy (quyền IAM). 🚫

  • ❌ [SAI] Retry the tests using the truncated exponential backoff polling strategy.
    Phương án này không đúng vì lỗi là deployment failures, không phải test failures. Các test (integration/service) chạy trong Cloud Build, nhưng vấn đề là deploy Cloud Functions fail. Chiến lược backoff chỉ dùng cho retry polling API (như khi gọi external services), không giải quyết deploy permission. 🔄

  • ✅ [ĐÚNG] Verify that the Cloud Build service account is assigned the Cloud Functions Developer role.
    Như đã giải thích ở phần đáp án đúng: Đây là nguyên nhân gốc rễ do thiếu IAM role cần thiết cho deploy. Gán role qua gcloud projects add-iam-policy-binding hoặc Console sẽ fix ngay. 🎯

Tóm tắt khuyến nghị: Chạy lệnh gcloud builds logs [BUILD-ID] để xem log chi tiết lỗi IAM, sau đó gán role và retry build. Nếu cần, thêm role Artifact Registry Writer cho container images nếu dùng custom runtime! 🚀

Câu 177
You manage a microservices application on Google Kubernetes Engine (GKE) using Istio. You secure the communication channels between your microservices by implementing an Istio AuthorizationPolicy, a Kubernetes NetworkPolicy, and mTLS on your GKE cluster. You discover that HTTP requests between two Pods to specific URLs fail, while other requests to other URLs succeed. What is the cause of the connection issue?
  1. A A Kubernetes NetworkPolicy resource is blocking HTTP traffic between the Pods.
  2. B The Pod initiating the HTTP requests is attempting to connect to the target Pod via an incorrect TCP port.
  3. C The Authorization Policy of your cluster is blocking HTTP requests for specific paths within your application.
  4. D The cluster has mTLS configured in permissive mode, but the Pod's sidecar proxy is sending unencrypted traffic in plain text.
Xem giải thích

🧩 Phân tích chi tiết câu hỏi trắc nghiệm

📖 Nội dung câu hỏi:
Câu hỏi mô tả một tình huống quản lý ứng dụng microservices trên Google Kubernetes Engine (GKE) sử dụng Istio làm service mesh. Bạn đã triển khai các biện pháp bảo mật sau:

  • Istio AuthorizationPolicy: Chính sách ủy quyền Istio để kiểm soát quyền truy cập chi tiết vào các service dựa trên các thuộc tính như method, path URL, namespace, v.v.
  • Kubernetes NetworkPolicy: Chính sách mạng Kubernetes để kiểm soát lưu lượng mạng giữa các Pod dựa trên label, namespace, port (là L3/L4 layer).
  • mTLS (mutual TLS): Xác thực lẫn nhau và mã hóa lưu lượng giữa các Pod qua sidecar proxy của Istio.

Vấn đề cụ thể: Các yêu cầu HTTP giữa hai Pod đến các URL/path cụ thể bị fail, trong khi các yêu cầu đến các URL/path khác thành công. Điều này chỉ ra vấn đề selective theo path/URL, không phải toàn bộ traffic giữa các Pod hay port.

🛠️ Mục tiêu câu hỏi: Xác định nguyên nhân gây ra lỗi kết nối chỉ với một số URL cụ thể, trong bối cảnh đã có đầy đủ bảo mật Istio + Kubernetes + mTLS. (Kiến thức dựa trên Istio 1.23+ và GKE 1.29+ cập nhật đến 2026, nơi AuthorizationPolicy hỗ trợ rule chi tiết cho HTTP paths).

✅ Đáp án đúng:
The Authorization Policy of your cluster is blocking HTTP requests for specific paths within your application.

Lý do chọn đáp án đúng (chi tiết):
Istio AuthorizationPolicy hoạt động ở L7 layer (HTTP), cho phép định nghĩa rule chính xác để allow/deny dựa trên path URL cụ thể (ví dụ: paths: ["/api/v1/secret"]). Trong trường hợp này, policy có thể đang deny requests đến các path sensitive, dẫn đến fail selective chỉ với URL cụ thể, trong khi các path khác được phép. Các biện pháp khác (NetworkPolicy ở L3/L4, mTLS ở transport layer) không kiểm soát được level path. Điều này khớp hoàn hảo với triệu chứng: other requests succeed.

📋 Giải thích tất cả các phương án (đúng/sai)

  • ❌ [SAI] A Kubernetes NetworkPolicy resource is blocking HTTP traffic between the Pods.
    Phân tích sai: Kubernetes NetworkPolicy chỉ kiểm soát lưu lượng ở L3/L4 (IP, port, protocol) giữa các Pod dựa trên label/namespace, không phân biệt path/URL HTTP. Nếu policy này block, toàn bộ HTTP traffic giữa hai Pod sẽ fail, không selective theo URL. Triệu chứng "other URLs succeed" loại trừ hoàn toàn.

  • ❌ [SAI] The Pod initiating the HTTP requests is attempting to connect to the target Pod via an incorrect TCP port.
    Phân tích sai: Lỗi TCP port sai sẽ làm tất cả requests từ Pod nguồn đến Pod đích fail (connection refused ngay từ đầu), không chỉ specific URL. Istio sidecar proxy mặc định forward traffic qua port chuẩn (thường 8080/443), và mTLS không ảnh hưởng selective path. Triệu chứng selective loại trừ lỗi port.

  • ✅ [ĐÚNG] The Authorization Policy of your cluster is blocking HTTP requests for specific paths within your application.
    Phân tích đúng: Như đã giải thích ở trên, AuthorizationPolicy của Istio hỗ trợ rule HTTP-specific như paths, methods, dẫn đến 403 Forbidden chỉ cho path bị deny. Đây là nguyên nhân chính xác nhất, phù hợp với Istio best practices cho microservices security trên GKE.

  • ❌ [SAI] The cluster has mTLS configured in permissive mode, but the Pod's sidecar proxy is sending unencrypted traffic in plain text.
    Phân tích sai: mTLS permissive mode (PeerAuthentication PERMISSIVE) cho phép cả TLS và plain text, nhưng nếu có vấn đề unencrypted, lỗi sẽ xảy ra ở toàn bộ traffic (TLS handshake fail hoặc proxy reject), không selective theo URL. Hơn nữa, Istio sidecar tự động mã hóa/mTLS, và triệu chứng "other requests succeed" chứng tỏ mTLS đang hoạt động bình thường.

📘 Tài liệu tham khảo (cập nhật 2026)

💡 Lời khuyên thực tế: Để debug, dùng istioctl authz check hoặc kubectl logs -n istio-system để verify policy. Nếu implement, luôn test với PERMISSIVE trước khi STRICT! 🚀

Câu 178
You recently migrated an on-premises monolithic application to a microservices application on Google Kubernetes Engine (GKE). The application has dependencies on backend services on-premises, including a CRM system and a MySQL database that contains personally identifiable information (PII). The backend services must remain on-premises to meet regulatory requirements.

You established a Cloud VPN connection between your on-premises data center and Google Cloud. You notice that some requests from your microservices application on GKE to the backend services are failing due to latency issues caused by fluctuating bandwidth, which is causing the application to crash. How should you address the latency issues?
  1. A Use Memorystore to cache frequently accessed PII data from the on-premises MySQL database
  2. B Use Istio to create a service mesh that includes the microservices on GKE and the on-premises services
  3. C Increase the number of Cloud VPN tunnels for the connection between Google Cloud and the on-premises services
  4. D Decrease the network layer packet size by decreasing the Maximum Transmission Unit (MTU) value from its default value on Cloud VPN
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi mô tả tình huống:
Bạn đã di chuyển một ứng dụng monolithic từ on-premises sang microservices trên Google Kubernetes Engine (GKE). Ứng dụng này phụ thuộc vào các backend services vẫn nằm on-premises (bao gồm hệ thống CRM và cơ sở dữ liệu MySQL chứa thông tin cá nhân PII - Personally Identifiable Information). Các backend này phải giữ nguyên on-premises do yêu cầu quy định pháp lý.

Bạn đã thiết lập Cloud VPN kết nối giữa data center on-premises và Google Cloud. Tuy nhiên, một số request từ microservices trên GKE đến backend on-premises thất bại do latency cao, gây ra bởi bandwidth dao động (fluctuating bandwidth), dẫn đến ứng dụng crash.

Vấn đề cốt lõi cần giải quyết: Latency issues từ kết nối VPN không ổn định, ảnh hưởng đến tính sẵn sàng của microservices. Giải pháp phải tập trung vào việc xử lý resilience (khả năng phục hồi) cho traffic giữa GKE và on-premises mà không vi phạm quy định PII.

(Kiến thức cập nhật: Dựa trên tài liệu GCP mới nhất đến 2026, GKE hỗ trợ Anthos Service Mesh với Istio phiên bản 1.23+, Cloud VPN sử dụng HA VPN với dynamic routing BGP để tối ưu bandwidth - tham khảo: GKE Networking Docs, Istio on GKE).

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Use Istio to create a service mesh that includes the microservices on GKE and the on-premises services

Lý do:
Istio là service mesh mạnh mẽ trên GKE (qua Anthos Service Mesh), cho phép quản lý traffic giữa microservices trên GKE và services on-premises. Nó cung cấp các tính năng resilience như:

  • 🛠️ Circuit breakers, retries, timeouts: Tự động retry request thất bại do latency, tránh crash ứng dụng.
  • 📡 Traffic management: Routing thông minh, load balancing để giảm tác động từ fluctuating bandwidth.
  • 🔗 Hỗ trợ hybrid connectivity: Istio có thể mở rộng service mesh đến on-premises qua VPN/IPsec, sử dụng Envoy sidecars để proxy traffic mà không cần thay đổi code ứng dụng.
    Giải pháp này trực tiếp giải quyết latency mà không di chuyển dữ liệu PII, phù hợp quy định. (Nguồn: Istio Multicluster & Hybrid Docs, Anthos Service Mesh Overview).

📋 Giải thích tất cả các phương án (đúng/sai)

  • Use Memorystore to cache frequently accessed PII data from the on-premises MySQL database
    ❌ Sai: Memorystore (Redis/Memcached trên GCP) sẽ cache PII ra cloud, vi phạm yêu cầu quy định giữ PII on-premises. Không giải quyết latency trực tiếp vì vẫn phải query on-premises cho dữ liệu nhạy cảm, chỉ giảm tải chứ không fix fluctuating bandwidth.

  • Use Istio to create a service mesh that includes the microservices on GKE and the on-premises services
    ✅ Đúng: Như đã giải thích ở trên, Istio cung cấp service mesh resilience (retries, circuit breaking) để xử lý latency từ VPN, mở rộng mesh hybrid mà không di chuyển data. Đây là best practice cho microservices trên GKE kết nối on-premises.

  • Increase the number of Cloud VPN tunnels for the connection between Google Cloud and the on-premises services
    ❌ Sai: Tăng tunnels (qua HA VPN) có thể tăng aggregate bandwidth nhưng không giải quyết fluctuating bandwidth hoặc latency spikes. Nó chỉ scale throughput, có thể phức tạp hóa routing và không fix root cause crash do request timeout. (Nguồn: Cloud VPN Best Practices).

  • Decrease the network layer packet size by decreasing the Maximum Transmission Unit (MTU) value from its default value on Cloud VPN
    ❌ Sai: Giảm MTU (mặc định 1460 cho VPN) tránh fragmentation nhưng tăng overhead (nhiều packet hơn), có thể làm latency tệ hơn với fluctuating bandwidth. Không phải giải pháp chuẩn cho microservices; chỉ dùng khi có MTU mismatch cụ thể. (Nguồn: Cloud VPN MTU Guidelines).

Câu 179
Your company has deployed a new API to a Compute Engine instance. During testing, the API is not behaving as expected. You want to monitor the application over 12 hours to diagnose the problem within the application code without redeploying the application. Which tool should you use?
  1. A Cloud Trace
  2. B Cloud Monitoring
  3. C Cloud Debugger logpoints
  4. D Cloud Debugger snapshots
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi tập trung vào tình huống debugging ứng dụng trên Google Cloud Platform (GCP): Công ty đã triển khai một API mới lên Compute Engine instance. Trong quá trình testing, API không hoạt động như mong đợi. Yêu cầu là giám sát ứng dụng trong vòng 12 giờ để chẩn đoán vấn đề trực tiếp trong mã nguồn ứng dụng (application code), mà không cần redeploy ứng dụng.

🔍 Yêu cầu chính:

  • Monitor dài hạn (12 giờ): Cần công cụ hỗ trợ theo dõi liên tục mà không làm gián đoạn ứng dụng.
  • Diagnose trong code: Phải truy cập giá trị biến, logic code tại runtime.
  • Không redeploy: Công cụ phải attach vào instance đang chạy mà không thay đổi code/deploy lại.

Mục tiêu là chọn công cụ phù hợp nhất từ Cloud Debugger hoặc các dịch vụ monitoring/tracing trên GCP. Đây là câu hỏi kiểm tra kiến thức về Cloud Debugger (phiên bản cập nhật 2024-2026, hỗ trợ logpoints cho monitoring non-intrusive). 📘

✅ Đáp án đúng: Cloud Debugger logpoints

Lý do lựa chọn:

  • Cloud Debugger logpoints cho phép đặt các điểm log (logpoints) trực tiếp vào mã nguồn đang chạy trên Compute Engine mà không cần redeploy. Khi code hit logpoint, nó sẽ log giá trị biến, biểu thức vào Cloud Logging mà không dừng thread hoặc ảnh hưởng performance (non-breaking).
  • Hoàn hảo cho monitor dài hạn 12 giờ: Có thể để logpoints chạy liên tục, thu thập dữ liệu theo thời gian thực từ traffic thực tế, giúp diagnose vấn đề code như giá trị biến sai, condition không đúng.
  • Tính năng cập nhật mới nhất (2026): Logpoints hỗ trợ Java, Python, Node.js, Go, .NET trên Compute Engine/Cloud Run, với giới hạn thời gian session lên đến 24 giờ (dễ dàng cover 12 giờ). 🛠️

Nguồn tham khảo:

📋 Giải thích tất cả các phương án

  • Cloud Trace ❌
    Sai vì: Cloud Trace dùng để trace latency và performance trong hệ thống phân tán (distributed tracing), tập trung vào thời gian xử lý spans/requests chứ không truy cập sâu vào giá trị biến trong code. Không phù hợp diagnose vấn đề logic code, và không hỗ trợ monitor code-level trong 12 giờ mà không redeploy. 🕐

  • Cloud Monitoring ❌
    Sai vì: Cloud Monitoring thu thập metrics, logs, alerts (CPU, memory, uptime) ở mức infrastructure/application cao cấp, nhưng không cho phép inspect code trực tiếp (như giá trị biến). Không diagnose được vấn đề trong application code mà chỉ báo hiệu symptom (ví dụ: high latency). 📊

  • Cloud Debugger logpoints ✅
    Đúng vì: Như giải thích trên, logpoints là lựa chọn lý tưởng cho non-intrusive debugging dài hạn trên Compute Engine. Attach agent vào instance chạy, đặt logpoint qua IDE (VS Code/Cloud Code), log dữ liệu code mà app vẫn chạy mượt. Hoàn thành yêu cầu "without redeploying". 🔍

  • Cloud Debugger snapshots ❌
    Sai vì: Cloud Debugger snapshots tạo breakpoint thật (pauses thread khi hit), chụp snapshot trạng thái code – hữu ích cho debug nhanh nhưng gây gián đoạn performance nếu monitor 12 giờ (có thể pause nhiều lần từ traffic cao). Không lý tưởng cho monitoring liên tục dài hạn. ⏸️

Câu 180
You are designing an application that consists of several microservices. Each microservice has its own RESTful API and will be deployed as a separate Kubernetes Service. You want to ensure that the consumers of these APIs aren't impacted when there is a change to your API, and also ensure that third-party systems aren't interrupted when new versions of the API are released. How should you configure the connection to the application following Google-recommended best practices?
  1. A Use an Ingress that uses the API's URL to route requests to the appropriate backend.
  2. B Leverage a Service Discovery system, and connect to the backend specified by the request.
  3. C Use multiple clusters, and use DNS entries to route requests to separate versioned backends.
  4. D Combine multiple versions in the same service, and then specify the API version in the POST request.
Xem giải thích

🧩 Phân tích chi tiết nội dung câu hỏi

Câu hỏi tập trung vào việc thiết kế kết nối cho một ứng dụng microservices chạy trên Kubernetes (cụ thể là Google Kubernetes Engine - GKE). Mỗi microservice có RESTful API riêng và được deploy dưới dạng Kubernetes Service độc lập. Mục tiêu chính là bảo vệ người dùng (consumers) khỏi tác động khi API thay đổi (như cập nhật version) và đảm bảo hệ thống bên thứ ba (third-party) không bị gián đoạn khi release version mới. Câu hỏi yêu cầu áp dụng best practices được Google khuyến nghị, nhấn mạnh vào cách cấu hình kết nối (connection) một cách an toàn, linh hoạt cho versioning API.

🛠️ Vấn đề cốt lõi: Trong môi trường microservices, việc thay đổi API (ví dụ: từ v1 sang v2) có thể phá vỡ compatibility. Google khuyến nghị sử dụng URL-based versioning (qua path hoặc host) kết hợp với Ingress để route traffic mượt mà đến backend phù hợp, hỗ trợ canary deployment và gradual migration mà không ảnh hưởng clients cũ.

✅ Đáp án đúng và lý do lựa chọn

Đáp án đúng: Use an Ingress that uses the API's URL to route requests to the appropriate backend.

Lý do:

  • Theo best practices của Google Cloud (GKE), Ingress là cách tối ưu để quản lý traffic routing cho Kubernetes Services. Nó sử dụng URL path (ví dụ: /api/v1/users route đến service-v1, /api/v2/users route đến service-v2) để tự động hướng request đến backend đúng version.
  • Điều này đảm bảo backward compatibility: Clients cũ vẫn dùng URL cũ mà không bị ảnh hưởng, third-party không cần thay đổi code khi release version mới.
  • Hỗ trợ advanced features như weighted routing (canary releases), SSL termination, và integration với Google Cloud Load Balancer – cập nhật đến năm 2026 vẫn là standard (GKE 1.29+ với Ingress v1beta1 hoặc Gateway API).
  • 📘 Nguồn tham khảo:

📋 Giải thích tất cả các phương án (đúng/sai)

Dưới đây là phân tích từng lựa chọn, giữ nguyên nội dung gốc bằng tiếng Anh. Mỗi phương án được đánh giá ✅ (đúng) hoặc ❌ (sai), kèm giải thích chi tiết bằng tiếng Việt:

  • Use an Ingress that uses the API's URL to route requests to the appropriate backend.
    ✅ Đúng. Như đã giải thích ở trên, đây là best practice chuẩn của Google cho GKE. Ingress tận dụng URL (path/host) để route linh hoạt, hỗ trợ versioning mà không downtime, phù hợp hoàn hảo với yêu cầu bảo vệ consumers và third-party.

  • Leverage a Service Discovery system, and connect to the backend specified by the request.
    ❌ Sai. Service Discovery (như Consul hoặc Kubernetes built-in) chỉ giúp tìm kiếm và register services động, không xử lý versioning API. Clients vẫn phải tự parse request để chọn backend, dễ gây lỗi compatibility và không theo Google best practices (thiếu layer routing trung tâm như Ingress).

  • Use multiple clusters, and use DNS entries to route requests to separate versioned backends.
    ❌ Sai. Sử dụng multiple clusters + DNS (như external-dns) quá phức tạp, tốn kém (multi-cluster management, cross-cluster traffic overhead). Google không khuyến nghị cho versioning đơn giản; thay vào đó, ưu tiên single cluster với Ingress hoặc Multi-Cluster Ingress (MCI) nếu cần scale lớn. Không đảm bảo zero-downtime cho third-party.

  • Combine multiple versions in the same service, and then specify the API version in the POST request.
    ❌ Sai. Kết hợp versions trong một service duy nhất vi phạm nguyên tắc microservices (monolith-like, khó scale độc lập). Chỉ định version trong POST body không phải RESTful standard (phá vỡ HATEOAS, idempotency), clients phải thay đổi code – trái ngược yêu cầu "không impacted". Google ưu tiên URL-based versioning thay vì header/body.

🧩 Kết luận: Phương án Ingress là lựa chọn tối ưu, scalable theo Google Cloud guidelines đến 2026, giúp ứng dụng microservices robust và future-proof! Nếu cần ví dụ YAML config Ingress, hãy hỏi thêm nhé 🚀.