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

Tìm thấy 358 câu.

Câu 191
You have an application deployed in Google Kubernetes Engine (GKE). You need to update the application to make authorized requests to Google Cloud managed services. You want this to be a one-time setup, and you need to follow security best practices of auto-rotating your security keys and storing them in an encrypted store. You already created a service account with appropriate access to the Google Cloud service. What should you do next?
  1. A Assign the Google Cloud service account to your GKE Pod using Workload Identity.
  2. B Export the Google Cloud service account, and share it with the Pod as a Kubernetes Secret.
  3. C Export the Google Cloud service account, and embed it in the source code of the application.
  4. D Export the Google Cloud service account, and upload it to HashiCorp Vault to generate a dynamic service account for your application.
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 cập nhật ứng dụng chạy trên Google Kubernetes Engine (GKE) để có thể thực hiện các yêu cầu được ủy quyền (authorized requests) đến các dịch vụ được quản lý bởi Google Cloud (như Cloud Storage, BigQuery, v.v.). Yêu cầu chính là:

  • Thiết lập một lần duy nhất (one-time setup).
  • Tuân thủ best practices bảo mật: Tự động xoay vòng khóa bảo mật (auto-rotating security keys) và lưu trữ khóa trong kho mã hóa (encrypted store).
  • Đã có sẵn service account (SA) của Google Cloud với quyền truy cập phù hợp.

Mục tiêu là liên kết SA này với Pod trong GKE một cách an toàn, tránh việc quản lý khóa thủ công, giảm rủi ro lộ khóa, và tận dụng tính năng native của Google Cloud để tự động hóa việc xác thực. Đây là tình huống phổ biến trong môi trường Kubernetes trên GCP, nơi cần tránh các phương pháp lỗi thời như export JSON key file. ✅ Kiến thức dựa trên phiên bản GKE mới nhất (tính đến 2026), với Workload Identity là tiêu chuẩn vàng cho IAM integration.

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

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

Đáp án đúng: Assign the Google Cloud service account to your GKE Pod using Workload Identity.

Lý do 🛠️:

  • Workload Identity là giải pháp native của Google Cloud, cho phép liên kết trực tiếp Google Cloud Service Account (GCP SA) với Kubernetes Service Account (KSA) mà không cần export khóa JSON.
  • One-time setup: Chỉ cần annotate KSA và enable Workload Identity trên cluster (gcloud commands hoặc Terraform), sau đó Pod tự động sử dụng OIDC token để impersonate GCP SA.
  • Bảo mật tốt nhất: Khóa được tự động xoay vòng (auto-rotate) bởi GCP (mỗi ~1 giờ), lưu trữ trong encrypted metadata store của GKE. Không có khóa tĩnh nào tồn tại, giảm bề mặt tấn công.
  • Tuân thủ least privilege và zero-trust model. Đây là khuyến nghị chính thức từ Google từ năm 2020 và vẫn là best practice đến 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 ✅ cho đúng và ❌ cho sai. Tôi giữ nguyên văn bản gốc tiếng Anh của phương án, chỉ phân tích bằng tiếng Việt:

  • ✅ Assign the Google Cloud service account to your GKE Pod using Workload Identity.
    🛠️ Đúng vì: Như đã giải thích ở trên, đây là phương pháp an toàn, tự động hóa cao, không yêu cầu quản lý khóa thủ công, phù hợp hoàn hảo với yêu cầu one-time setup và auto-rotation. Được hỗ trợ đầy đủ trong GKE Standard/ Autopilot clusters.

  • ❌ Export the Google Cloud service account, và share it with the Pod as a Kubernetes Secret.
    🧨 Sai vì: Việc export JSON key và mount dưới dạng Secret tạo ra khóa tĩnh (static keys), dễ bị lộ nếu Secret bị hack (ví dụ: etcd breach). Không auto-rotate, phải thủ công renew, vi phạm best practices. Google khuyến cáo tránh hoàn toàn cách này từ 2019.

  • ❌ Export the Google Cloud service account, và embed it in the source code of the application.
    🚫 Sai nặng vì: Nhúng khóa trực tiếp vào code là anti-pattern bảo mật tồi tệ nhất, khóa sẽ bị lộ trên Git/repo, CI/CD, hoặc image Docker. Không rotate, không encrypted store, dễ bị attacker khai thác. Vi phạm nguyên tắc "secrets không bao giờ vào code".

  • ❌ Export the Google Cloud service account, và upload it to HashiCorp Vault to generate a dynamic service account for your application.
    🔒 Sai vì: Vault hỗ trợ dynamic secrets cho GCP (qua Vault GCP plugin), nhưng vẫn yêu cầu export initial key để auth Vault với GCP – không phải one-time thực sự. Phức tạp hơn Workload Identity native, thêm dependency bên thứ 3 (Vault), và không phải best practice GCP. Google ưu tiên Workload Identity thay vì Vault cho GKE workloads.

Tóm tắt nhanh 📝: Workload Identity là lựa chọn tối ưu, native, và secure nhất cho GKE! Nếu triển khai, dùng lệnh: gcloud container clusters create --workload-pool=PROJECT_ID.svc.id.goog và annotate KSA với iam.gke.io/gcp-service-account. 🚀

Câu 192
You are planning to deploy hundreds of microservices in your Google Kubernetes Engine (GKE) cluster. How should you secure communication between the microservices on GKE using a managed service?
  1. A Use global HTTP(S) Load Balancing with managed SSL certificates to protect your services
  2. B Deploy open source Istio in your GKE cluster, and enable mTLS in your Service Mesh
  3. C Install cert-manager on GKE to automatically renew the SSL certificates.
  4. D Install Anthos Service Mesh, and enable mTLS in your Service Mesh.
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 triển khai và bảo mật giao tiếp giữa hàng trăm microservices trong cụm Google Kubernetes Engine (GKE). Cụ thể, bạn đang lập kế hoạch deploy microservices và cần sử dụng một dịch vụ managed (quản lý bởi Google Cloud) để bảo mật giao tiếp nội bộ giữa các microservices này.

🔑 Yêu cầu chính:

  • Bảo mật giao tiếp giữa các microservices (internal traffic, không phải external).
  • Sử dụng managed service (không phải tự quản lý open source).
  • Công nghệ phù hợp với GKE: Cần hỗ trợ mTLS (mutual TLS) để mã hóa và xác thực lẫn nhau giữa các service, đảm bảo an toàn cho môi trường microservices lớn.

Câu hỏi nhấn mạnh quy mô lớn (hundreds of microservices), nên cần giải pháp service mesh chuyên dụng, dễ scale và managed để giảm gánh nặng vận hành. ✅ Kiến thức cập nhật đến 2026: Anthos Service Mesh (ASM) phiên bản mới nhất (ASM 1.23+ vào 2025-2026) là giải pháp managed chính thức của Google cho GKE, tích hợp Istio với mTLS tự động.

✅ Đáp án đúng

Install Anthos Service Mesh, and enable mTLS in your Service Mesh.

Lý do lựa chọn 🛠️:

  • Anthos Service Mesh là dịch vụ managed hoàn toàn bởi Google Cloud, dựa trên Istio open source nhưng được Google quản lý (installation, upgrade, monitoring tự động qua asmcli hoặc console).
  • Nó hỗ trợ mTLS để bảo mật giao tiếp end-to-end giữa microservices trong GKE, với zero-trust security (xác thực lẫn nhau, mã hóa traffic).
  • Phù hợp quy mô lớn: Traffic management, observability (metrics, logs via Cloud Monitoring/Logging), và integration sâu với GKE Autopilot/Standard.
  • Đáp ứng "managed service" chính xác, không cần tự deploy Istio.

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

❌ 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, giữ nguyên văn bản gốc tiếng Anh:

  • Use global HTTP(S) Load Balancing with managed SSL certificates to protect your services
    ❌ Sai: Global HTTP(S) Load Balancing chỉ bảo vệ external traffic (từ internet vào services), không dành cho giao tiếp nội bộ giữa microservices. Nó dùng SSL cho ingress, không hỗ trợ mTLS end-to-end trong cluster. Không phải managed service cho internal security.

  • Deploy open source Istio in your GKE cluster, and enable mTLS in your Service Mesh
    ❌ Sai: Istio open source yêu cầu tự deploy và quản lý (không phải managed service), tốn công cài đặt, upgrade, và troubleshoot. Google khuyến nghị dùng Anthos Service Mesh thay thế để có managed experience trên GKE.

  • Install cert-manager on GKE to automatically renew the SSL certificates.
    ❌ Sai: cert-manager chỉ quản lý tạo và renew certificates (như Let's Encrypt), không cung cấp service mesh hay mTLS cho giao tiếp microservices. Nó là công cụ bổ trợ, không giải quyết bảo mật traffic nội bộ toàn diện.

🧠 Tóm tắt: Chỉ Anthos Service Mesh đáp ứng đầy đủ managed + mTLS + internal microservices security trên GKE. Các lựa chọn khác hoặc không managed, hoặc không target đúng traffic! 🚀

Câu 193 Chọn nhiều đáp án
You are developing an application that will store and access sensitive unstructured data objects in a Cloud Storage bucket. To comply with regulatory requirements, you need to ensure that all data objects are available for at least 7 years after their initial creation. Objects created more than 3 years ago are accessed very infrequently (less than once a year). You need to configure object storage while ensuring that storage cost is optimized. What should you do? (Choose two.)
  1. A Set a retention policy on the bucket with a period of 7 years.
  2. B Use IAM Conditions to provide access to objects 7 years after the object creation date.
  3. C Enable Object Versioning to prevent objects from being accidentally deleted for 7 years after object creation.
  4. D Create an object lifecycle policy on the bucket that moves objects from Standard Storage to Archive Storage after 3 years.
  5. E Implement a Cloud Function that checks the age of each object in the bucket and moves the objects older than 3 years to a second bucket with the Archive Storage class. Use Cloud Scheduler to trigger the Cloud Function on a daily schedule.
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 chủ đề Google Cloud Storage (GCS), tập trung vào việc quản lý dữ liệu nhạy cảm không cấu trúc (unstructured data objects) trong một bucket. Yêu cầu chính bao gồm:

  • Tuân thủ quy định pháp lý: Tất cả objects phải được lưu trữ ít nhất 7 năm kể từ khi tạo (available for at least 7 years).
  • Tối ưu chi phí lưu trữ: Objects cũ hơn 3 năm chỉ được truy cập rất hiếm (ít hơn 1 lần/năm), nên cần giảm chi phí mà không ảnh hưởng đến tính sẵn sàng.
  • Nhiệm vụ: Cấu hình bucket với hai hành động (Choose two) để đảm bảo retention (giữ dữ liệu) và tối ưu chi phí.

📘 Bối cảnh cập nhật 2026: Theo tài liệu GCP mới nhất (Cloud Storage features đến 2026), GCS hỗ trợ Retention Policy (Bucket Lock), Object Lifecycle Management, các storage class như Standard và Archive (chi phí thấp cho dữ liệu ít truy cập), cùng các công cụ tự động hóa như Cloud Functions và Scheduler. Không liên quan AWS S3 như đề cập nhầm.

✅ Đáp án đúng (Chọn hai)

Hai lựa chọn đúng là:

  1. Set a retention policy on the bucket with a period of 7 years.
    🛡️ Lý do đúng: Retention Policy (hay Bucket Lock) khóa objects không cho xóa hoặc ghi đè trong 7 năm, đảm bảo tuân thủ quy định. Đây là giải pháp chuẩn cho compliance, áp dụng cho toàn bucket hoặc objects.

  2. Create an object lifecycle policy on the bucket that moves objects from Standard Storage to Archive Storage after 3 years.
    💰 Lý do đúng: Object Lifecycle tự động chuyển objects >3 năm từ Standard (chi phí cao, truy cập nhanh) sang Archive (chi phí thấp ~1/10, phù hợp dữ liệu hiếm truy cập). Tối ưu chi phí mà không cần can thiệp thủ công, giữ retention nguyên vẹn.

Kết hợp hai giải pháp này: Giữ dữ liệu 7 năm và giảm chi phí cho dữ liệu cũ.
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 một cách chi tiết:

  • Set a retention policy on the bucket with a period of 7 years.
    ✅ Đúng: Như giải thích trên, đây là cách chính thức để enforce retention 7 năm, ngăn xóa/ghi đè. Hoàn hảo cho dữ liệu nhạy cảm tuân thủ quy định (ví dụ GDPR, HIPAA).

  • Use IAM Conditions to provide access to objects 7 years after the object creation date.
    ❌ Sai: IAM Conditions kiểm soát quyền truy cập dựa trên điều kiện (như tuổi objects), nhưng không enforce retention (giữ dữ liệu 7 năm). Nó chỉ giới hạn ai đọc được sau 7 năm, không ngăn xóa sớm và không tối ưu chi phí.

  • Enable Object Versioning to prevent objects from being accidentally deleted for 7 years after object creation.
    ❌ Sai: Object Versioning giữ các phiên bản cũ khi ghi đè/xóa, nhưng không ngăn xóa vĩnh viễn (có thể purge noncurrent versions). Không có cơ chế tự động 7 năm, và không tối ưu chi phí (vẫn dùng storage class gốc, tốn kém hơn lifecycle).

  • Create an object lifecycle policy on the bucket that moves objects from Standard Storage to Archive Storage after 3 years.
    ✅ Đúng: Lifecycle rule tự động chuyển class storage sau 3 năm, giảm chi phí ~90% cho Archive (retrieval fee cao nhưng phù hợp truy cập <1 lần/năm). Kết hợp retention policy để giữ an toàn.

  • Implement a Cloud Function that checks the age of each object in the bucket and moves the objects older than 3 years to a second bucket with the Archive Storage class. Use Cloud Scheduler to trigger the Cloud Function on a daily schedule.
    ❌ Sai: Giải pháp thủ công này không tối ưu (tốn chi phí Functions + Scheduler, phức tạp quản lý, rủi ro lỗi code). Lifecycle policy làm việc tương tự miễn phí và tự động trong cùng bucket, hiệu quả hơn theo best practices GCP 2026.

🛠️ Khuyến nghị triển khai: Tạo bucket → Enable Retention (compliance mode) → Add Lifecycle rule. Test với gsutil lifecycle set để xác nhận!

Câu 194
You are developing an application using different microservices that must remain internal to the cluster. You want the ability to configure each microservice with a specific number of replicas. You also want the ability to address a specific microservice from any other microservice in a uniform way, regardless of the number of replicas the microservice scales to. You plan to implement this solution on Google Kubernetes Engine. What should you do?
  1. A Deploy each microservice as a Deployment. Expose the Deployment in the cluster using a Service, and use the Service DNS name to address it from other microservices within the cluster.
  2. B Deploy each microservice as a Deployment. Expose the Deployment in the cluster using an Ingress, and use the Ingress IP address to address the Deployment from other microservices within the cluster.
  3. C Deploy each microservice as a Pod. Expose the Pod in the cluster using a Service, and use the Service DNS name to address the microservice from other microservices within the cluster.
  4. D Deploy each microservice as a Pod. Expose the Pod in the cluster using an Ingress, and use the Ingress IP address to address the Pod from other microservices within the cluster.
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 triển khai ứng dụng microservices trên Google Kubernetes Engine (GKE), với các yêu cầu chính sau:

  • Các microservices phải giữ nội bộ (internal) trong cluster, không expose ra ngoài.
  • Cấu hình số lượng replicas cụ thể cho từng microservice (để scale horizontally).
  • Địa chỉ (address) microservice một cách uniform từ bất kỳ microservice nào khác trong cluster, bất kể số replicas thay đổi (cần tên ổn định, không phụ thuộc vào Pod IP động).

🛠️ Giải pháp lý tưởng trên GKE/Kubernetes: Sử dụng Deployment để quản lý replicas (tự động tạo/update Pod), và Service type ClusterIP để expose internal với DNS name ổn định (ví dụ: my-service.namespace.svc.cluster.local). Điều này đảm bảo communication nội bộ mượt mà qua DNS, không cần biết Pod nào đang chạy.

📘 Kiến thức cập nhật (Kubernetes 1.30+ trên GKE 2026): GKE hỗ trợ đầy đủ các resource Kubernetes core, với Service DNS được CoreDNS quản lý ổn định. Không liên quan AWS (có lẽ nhầm lẫn, vì đây là GKE thuần).

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

Đáp án đúng: Deploy each microservice as a Deployment. Expose the Deployment in the cluster using a Service, and use the Service DNS name to address it from other microservices within the cluster.

Lý do:

  • Deployment 🛠️: Quản lý replicas (replicaSet), tự động scale/restart Pod, phù hợp yêu cầu "specific number of replicas". Pod IP động, nhưng Deployment che giấu điều này.
  • Service (ClusterIP mặc định cho internal) ✅: Tạo endpoint ổn định, DNS name uniform (không thay đổi khi scale). Các microservices khác gọi qua DNS này để load balance nội bộ.
  • Hoàn hảo cho internal cluster communication trên GKE.

Nguồn tham khảo:

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

  • ✅ [ĐÚNG] Deploy each microservice as a Deployment. Expose the Deployment in the cluster using a Service, and use the Service DNS name to address it from other microservices within the cluster.
    Như đã giải thích ở trên: Deployment quản lý replicas hoàn hảo, Service cung cấp DNS ổn định cho internal access. Đây là best practice Kubernetes/GKE.

  • ❌ [SAI] Deploy each microservice as a Deployment. Expose the Deployment in the cluster using an Ingress, and use the Ingress IP address to address the Deployment from other microservices within the cluster.
    Lý do sai: Ingress dành cho external HTTP/HTTPS traffic (Layer 7 routing), không phải internal cluster. Ingress IP thường là LoadBalancer public (không internal), và không cung cấp DNS uniform nội bộ. Sử dụng Ingress IP cho internal sẽ kém hiệu quả, expose rủi ro bảo mật, không scale tốt replicas.

  • ❌ [SAI] Deploy each microservice as a Pod. Expose the Pod in the cluster using a Service, and use the Service DNS name to address the microservice from other microservices within the cluster.
    Lý do sai: Pod đơn lẻ không quản lý replicas (Pod ephemeral, chết là mất, không scale). Deployment mới hỗ trợ "specific number of replicas". Service vẫn tốt cho DNS, nhưng thiếu Deployment làm giải pháp không hoàn chỉnh.

  • ❌ [SAI] Deploy each microservice as a Pod. Expose the Pod in the cluster using an Ingress, and use the Ingress IP address to address the Pod from other microservices within the cluster.
    Lý do sai: Kết hợp 2 lỗi lớn - Pod không replicas, Ingress không internal/uniform. Ingress IP public/external, không phù hợp internal cluster, và Pod IP động làm address không ổn định khi scale (dù không scale được).

🧩 Tóm tắt: Best practice GKE là Deployment + Service cho microservices internal. Tránh Pod trực tiếp và Ingress internal!

Câu 195
You are building an application that uses a distributed microservices architecture. You want to measure the performance and system resource utilization in one of the microservices written in Java. What should you do?
  1. A Instrument the service with Cloud Profiler to measure CPU utilization and method-level execution times in the service.
  2. B Instrument the service with Debugger to investigate service errors.
  3. C Instrument the service with Cloud Trace to measure request latency.
  4. D Instrument the service with OpenCensus to measure service latency, and write custom metrics to Cloud Monitoring.
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ả tình huống bạn đang xây dựng một ứng dụng sử dụng kiến trúc microservices phân tán. Bạn muốn đo lường hiệu suất (performance) và sử dụng tài nguyên hệ thống (system resource utilization) trong một microservice được viết bằng ngôn ngữ Java. Nhiệm vụ là chọn công cụ phù hợp nhất để thực hiện việc này.
🛠️ Yêu cầu chính: Tập trung vào việc đo CPU utilization và thời gian thực thi ở mức method-level (thời gian chạy của từng hàm/phương thức), vì đây là các chỉ số cốt lõi của performance và resource utilization trong môi trường Java. Đây là câu hỏi thuộc lĩnh vực observability và profiling trên Google Cloud Platform (GCP), không phải AWS (có thể có nhầm lẫn trong chủ đề, nhưng các công cụ như Cloud Profiler, Cloud Trace đều là của GCP). Kiến thức dựa trên phiên bản mới nhất GCP đến năm 2026, nơi Cloud Profiler hỗ trợ đầy đủ Java với low-overhead sampling profiler.

✅ Đáp án đúng:
Instrument the service with Cloud Profiler to measure CPU utilization and method-level execution times in the service.
Lý do chọn: Cloud Profiler là công cụ chuyên dụng để profiling hiệu suất trên GCP, hỗ trợ Java native agent. Nó thu thập dữ liệu CPU utilization, wall-clock time, và method-level execution times mà không làm gián đoạn ứng dụng (overhead <5%). Hoàn hảo cho microservices để xác định bottlenecks ở mức code chi tiết.
📚 Nguồn: Cloud Profiler Documentation (cập nhật 2025: hỗ trợ Java 21+ và ARM64).

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

  • ✅ [ĐÚNG] Instrument the service with Cloud Profiler to measure CPU utilization and method-level execution times in the service.
    🟢 Đúng vì: Đây là lựa chọn chính xác nhất. Cloud Profiler cung cấp flame graphs trực quan hóa CPU, memory, và thời gian thực thi từng method, lý tưởng cho Java microservices. Nó tự động integrate với Cloud Monitoring và hỗ trợ continuous profiling ở production.

  • ❌ [SAI] Instrument the service with Debugger to investigate service errors.
    🔴 Sai vì: Cloud Debugger (trước đây là Stackdriver Debugger) dùng để debug code bằng snapshot khi lỗi xảy ra (logpoints, breakpoints), không đo performance hay resource utilization. Nó không cung cấp CPU/method-level profiling mà chỉ hỗ trợ troubleshoot errors.

  • ❌ [SAI] Instrument the service with Cloud Trace to measure request latency.
    🔴 Sai vì: Cloud Trace chuyên tracing distributed requests và đo request latency/end-to-end spans, không tập trung vào CPU utilization hay method-level details. Nó tốt cho latency ở mức service, nhưng không profile nội bộ code như Profiler.

  • ❌ [SAI] Instrument the service with OpenCensus to measure service latency, and write custom metrics to Cloud Monitoring.
    🔴 Sai vì: OpenCensus (nay tích hợp vào OpenTelemetry) dùng cho tracing/metrics tùy chỉnh và export sang Cloud Monitoring, chủ yếu đo service-level latency. Không hỗ trợ CPU/method profiling chi tiết; bạn phải tự viết code custom, không hiệu quả bằng Profiler native. (Cập nhật 2025: OpenTelemetry thay thế, nhưng vẫn không thay thế Profiler).

🛠️ Kết luận & Lời khuyên:
Sử dụng Cloud Profiler là best practice cho Java microservices trên GCP. Để triển khai: Thêm agent JAR vào JVM args (-agentpath:/path/to/profiler.so). Theo dõi qua Console hoặc API. Nếu cần full observability stack: Kết hợp Profiler + Trace + Monitoring!
📚 Tài liệu tham khảo thêm:

Câu 196
Your team is responsible for maintaining an application that aggregates news articles from many different sources. Your monitoring dashboard contains publicly accessible real-time reports and runs on a Compute Engine instance as a web application. External stakeholders and analysts need to access these reports via a secure channel without authentication. How should you configure this secure channel?
  1. A Add a public IP address to the instance. Use the service account key of the instance to encrypt the traffic.
  2. B Use Cloud Scheduler to trigger Cloud Build every hour to create an export from the reports. Store the reports in a public Cloud Storage bucket.
  3. C Add an HTTP(S) load balancer in front of the monitoring dashboard. Configure Identity-Aware Proxy to secure the communication channel.
  4. D Add an HTTP(S) load balancer in front of the monitoring dashboard. Set up a Google-managed SSL certificate on the load balancer for traffic encryption.
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 chủ đề bảo mật và truy cập công khai an toàn trên Google Cloud Platform (GCP). Ứng dụng của đội ngũ đang tổng hợp bài báo từ nhiều nguồn, chạy trên Compute Engine instance dưới dạng web app với dashboard giám sát chứa báo cáo thời gian thực (real-time reports) có thể truy cập công khai. Các bên liên quan bên ngoài (external stakeholders và analysts) cần truy cập báo cáo qua kênh an toàn (secure channel) mà không cần xác thực (without authentication).

Yêu cầu chính cần giải quyết:

  • Đảm bảo mã hóa giao thức (encryption) cho traffic để an toàn.
  • Giữ truy cập công khai mà không yêu cầu login/auth.
  • Dashboard chạy trên Compute Engine, cần cấu hình kênh an toàn từ bên ngoài.

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

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

Đáp án đúng: Add an HTTP(S) load balancer in front of the monitoring dashboard. Set up a Google-managed SSL certificate on the load balancer for traffic encryption.

Lý do 🛡️️:

  • HTTP(S) Load Balancer đặt trước Compute Engine instance cho phép truy cập công khai qua domain/IP public mà không cần authentication.
  • Google-managed SSL certificate tự động mã hóa traffic HTTPS (TLS 1.3 trở lên theo chuẩn 2026), đảm bảo kênh an toàn end-to-end từ client đến load balancer.
  • Giải pháp real-time, scalable, và tuân thủ best practices GCP cho public web apps. Không ảnh hưởng đến Compute Engine instance gốc (có thể dùng private IP).

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

  • [SAI] Add a public IP address to the instance. Use the service account key of the instance to encrypt the traffic.
    ❌ Sai vì: Public IP trên Compute Engine không mã hóa traffic (chỉ HTTP/HTTPS cơ bản, dễ bị MITM attack). Service account key dùng cho xác thực API calls, không phải encrypt traffic (không thay thế SSL/TLS). Giải pháp này không an toàn, dễ bị expose và vi phạm nguyên tắc least privilege.

  • [SAI] Use Cloud Scheduler to trigger Cloud Build every hour to create an export from the reports. Store the reports in a public Cloud Storage bucket.
    ❌ Sai vì: Không đáp ứng real-time (chỉ export mỗi giờ qua Cloud Scheduler + Cloud Build). Public Cloud Storage bucket không mã hóa channel (dùng HTTPS nhưng public read dễ bị crawl/abuse). Không phù hợp cho dashboard tương tác, chỉ dùng cho static files.

  • [SAI] Add an HTTP(S) load balancer in front of the monitoring dashboard. Configure Identity-Aware Proxy to secure the communication channel.
    ❌ Sai vì: Identity-Aware Proxy (IAP) bắt buộc authentication (Google accounts hoặc IAM), trái với yêu cầu without authentication. IAP dùng cho protected resources, không dành cho public access. Load balancer + IAP làm phức tạp hóa không cần thiết.

  • [ĐÚNG] Add an HTTP(S) load balancer in front of the monitoring dashboard. Set up a Google-managed SSL certificate on the load balancer for traffic encryption.
    ✅ Đúng vì: Như giải thích ở phần đáp án trên. Đây là best practice GCP cho public HTTPS apps, hỗ trợ global load balancing, auto-scaling, và cert free (Google quản lý provisioning/renewal theo chuẩn 2026 với wildcard/multi-domain support).

🛠️ Lời khuyên triển khai: Sử dụng Global HTTP(S) Load Balancer với backend Compute Engine group, enable HTTPS redirect, và monitor qua Cloud Monitoring. Test với curl -I https://your-domain để xác nhận SSL.

Câu 197
You are planning to add unit tests to your application. You need to be able to assert that published Pub/Sub messages are processed by your subscriber in order. You want the unit tests to be cost-effective and reliable. What should you do?
  1. A Implement a mocking framework.
  2. B Create a topic and subscription for each tester.
  3. C Add a filter by tester to the subscription.
  4. D Use the Pub/Sub emulator.
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 thêm unit tests (kiểm thử đơn vị) cho một ứng dụng sử dụng Google Cloud Pub/Sub. Mục tiêu là kiểm tra (assert) rằng các tin nhắn (messages) được publish đã được xử lý theo thứ tự (in order) bởi subscriber. Yêu cầu các unit tests phải tiết kiệm chi phí (cost-effective) và đáng tin cậy (reliable).

🛠️ Bối cảnh kỹ thuật:

  • Pub/Sub là dịch vụ messaging của Google Cloud, hỗ trợ publish-subscribe model với đảm bảo thứ tự tin nhắn nếu cấu hình ordering key.
  • Unit tests cần chạy local hoặc môi trường kiểm thử mà không phụ thuộc vào tài nguyên cloud thực tế (để tránh chi phí và độ trễ).
  • Thách thức: Đảm bảo thứ tự xử lý tin nhắn trong môi trường test, đồng thời giữ chi phí thấp và độ ổn định cao.

📘 Kiến thức cập nhật (đến 2026): Pub/Sub Emulator (phiên bản mới nhất từ Google Cloud SDK 2024+) hỗ trợ đầy đủ tính năng như ordering, lite topics, và snapshot/restore cho unit tests. Không liên quan AWS (có lẽ nhầm lẫn, vì Pub/Sub là dịch vụ GCP thuần túy).

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

Đáp án đúng: Use the Pub/Sub emulator.

Lý do 🟢:

  • Pub/Sub Emulator chạy local trên máy developer (qua Docker hoặc gcloud emulators), miễn phí hoàn toàn (không tốn quota cloud), và đáng tin cậy cao vì kiểm soát đầy đủ môi trường test.
  • Hỗ trợ xác thực thứ tự tin nhắn (message ordering) giống production, cho phép publish/subscribe real-time trong unit tests.
  • Dễ tích hợp với framework như JUnit, pytest qua client libraries (Python, Java, Go...).
  • Tiết kiệm & reliable: Không tạo tài nguyên thật, tránh race conditions, và restart nhanh chóng.

Nguồn tham khảo:

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

  • ❌ Implement a mocking framework.
    Sai vì: Mocking (như Mockito, unittest.mock) chỉ giả lập interface, không đảm bảo thứ tự xử lý tin nhắn thực tế như Pub/Sub (ordering key, at-least-once delivery). Dễ lỗi logic test, không reliable cho complex scenarios, và tốn công implement custom mocks. Không cost-effective so với emulator sẵn có.

  • ❌ Create a topic and subscription for each tester.
    Sai vì: Tạo topic/subscription thật trên cloud cho mỗi test runner sẽ tốn chi phí cao (quota, billing per operation), không phù hợp unit tests (chạy hàng nghìn lần). Không reliable do latency network, quota limits, và khó cleanup (dùng TearDown). Phù hợp integration tests hơn.

  • ❌ Add a filter by tester to the subscription.
    Sai vì: Push/pull subscription filters chỉ lọc message attributes, không giải quyết thứ tự xử lý (ordering vẫn phụ thuộc global queue). Vẫn dùng tài nguyên cloud → chi phí cao, và không isolated (các tester có thể conflict). Không ideal cho unit tests local.

  • ✅ Use the Pub/Sub emulator.
    Đúng vì: Như đã giải thích ở trên, hoàn hảo cho unit tests: local, free, supports ordering/full Pub/Sub semantics. Chạy lệnh gcloud emulators pubsub start là sẵn sàng!

🧪 Lời khuyên thực hành: Trong code, dùng PUBSUB_EMULATOR_HOST env var để client tự động connect emulator. Test ví dụ: Publish ordered messages → Assert subscriber nhận đúng thứ tự. Siêu hiệu quả! 🚀

Câu 198
You have an application deployed in Google Kubernetes Engine (GKE) that reads and processes Pub/Sub messages. Each Pod handles a fixed number of messages per minute. The rate at which messages are published to the Pub/Sub topic varies considerably throughout the day and week, including occasional large batches of messages published at a single moment.

You want to scale your GKE Deployment to be able to process messages in a timely manner. What GKE feature should you use to automatically adapt your workload?
  1. A Vertical Pod Autoscaler in Auto mode
  2. B Vertical Pod Autoscaler in Recommendation mode
  3. C Horizontal Pod Autoscaler based on an external metric
  4. D Horizontal Pod Autoscaler based on resources utilization
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 ứng dụng được triển khai trên Google Kubernetes Engine (GKE), nơi các Pod đọc và xử lý tin nhắn từ Pub/Sub (dịch vụ message queue của Google Cloud). Mỗi Pod chỉ xử lý một số lượng tin nhắn cố định mỗi phút, nhưng tốc độ publish tin nhắn vào topic biến động mạnh theo ngày/tuần, bao gồm cả các batch lớn đột ngột. Mục tiêu là tự động scale Deployment để xử lý kịp thời, tránh ùn tắc.

🛠️ Vấn đề cốt lõi: Không thể dựa vào tài nguyên nội bộ Pod (như CPU/memory) vì workload phụ thuộc vào tỷ lệ tin nhắn bên ngoài (external metric từ Pub/Sub, ví dụ: số lượng tin nhắn chưa xử lý - backlog, hoặc số pull operations). Cần cơ chế Horizontal Scaling (tăng/giảm số Pod) dựa trên metric bên ngoài để thích ứng nhanh chóng.

📘 Kiến thức cập nhật (đến 2026): Theo tài liệu GKE mới nhất (GKE version 1.29+ và Autoscaler v2), Horizontal Pod Autoscaler (HPA) hỗ trợ external metrics qua Cloud Monitoring, đặc biệt phù hợp cho Pub/Sub với metric như pubsub.googleapis.com/subscription/pull_count hoặc custom metric từ backlog. Vertical Pod Autoscaler (VPA) chỉ điều chỉnh tài nguyên Pod (CPU/RAM), không scale số lượng Pod.

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

Đáp án đúng: Horizontal Pod Autoscaler based on an external metric
🧩 Lý do: HPA với external metric cho phép scale số lượng Pod dựa trên metric bên ngoài Kubernetes, như số lượng tin nhắn Pub/Sub (ví dụ: pubsub.googleapis.com/subscription/num_undelivered_messages hoặc pull request rate). Điều này trực tiếp phản ánh workload biến động (batch lớn), giúp Deployment tự động tăng Pod để xử lý kịp thời. Đây là giải pháp chuẩn cho queue-based workloads trên GKE (xem Tài liệu HPA external metrics).

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

  • Vertical Pod Autoscaler in Auto mode ❌ SAI
    VPA Auto mode tự động điều chỉnh tài nguyên CPU/memory của Pod hiện có dựa trên sử dụng thực tế, không scale số lượng Pod (horizontal). Với workload Pub/Sub biến động theo batch, chỉ tăng tài nguyên Pod không giải quyết ùn tắc tin nhắn, vì mỗi Pod vẫn giới hạn xử lý cố định/phút. Không phù hợp cho scaling kịp thời.

  • Vertical Pod Autoscaler in Recommendation mode ❌ SAI
    VPA Recommendation chỉ gợi ý tài nguyên CPU/memory (không tự động áp dụng), yêu cầu can thiệp thủ công. Tương tự Auto mode, nó tập trung vertical scaling tài nguyên Pod, không xử lý được biến động external metric từ Pub/Sub, dẫn đến chậm trễ với batch lớn.

  • Horizontal Pod Autoscaler based on an external metric ✅ ĐÚNG
    HPA sử dụng external metric từ Cloud Monitoring (như Pub/Sub backlog/pull count) để tăng/giảm số Pod tự động. Hoàn hảo cho trường hợp này, vì trực tiếp scale theo tỷ lệ tin nhắn thực tế, đảm bảo xử lý kịp thời dù publish biến động mạnh. Hỗ trợ đầy đủ trong GKE Enterprise (xem HPA với Pub/Sub).

  • Horizontal Pod Autoscaler based on resources utilization ❌ SAI
    HPA resource chỉ scale dựa trên CPU/memory sử dụng bên trong Pod, không phản ánh tỷ lệ tin nhắn Pub/Sub bên ngoài. Với batch lớn đột ngột, Pod có thể chưa kịp overload CPU/memory trước khi ùn tắc, dẫn đến scale chậm hoặc muộn. Không phù hợp cho external workload biến động.

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

Câu 199
You are using Cloud Run to host a web application. You need to securely obtain the application project ID and region where the application is running and display this information to users. You want to use the most performant approach. What should you do?
  1. A Use HTTP requests to query the available metadata server at the http://metadata.google.internal/ endpoint with the Metadata-Flavor: Google header.
  2. B In the Google Cloud console, navigate to the Project Dashboard and gather configuration details. Navigate to the Cloud Run “Variables & Secrets” tab, and add the desired environment variables in Key:Value format.
  3. C In the Google Cloud console, navigate to the Project Dashboard and gather configuration details. Write the application configuration information to Cloud Run's in-memory container filesystem.
  4. D Make an API call to the Cloud Asset Inventory API from the application and format the request to include instance metadata.
Xem giải thích

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

Câu hỏi yêu cầu tìm cách an toàn và hiệu suất cao nhất để lấy Project ID và region của ứng dụng web đang chạy trên Cloud Run (dịch vụ serverless của Google Cloud), sau đó hiển thị thông tin này cho người dùng.

  • Bối cảnh chính: Cloud Run là nền tảng chạy container serverless, nơi ứng dụng chạy trong môi trường cô lập nhưng có quyền truy cập Metadata Server nội bộ của Google Cloud.
  • Yêu cầu cốt lõi:
    • Bảo mật: Không hardcode hoặc dùng cách thủ công.
    • Hiệu suất: Nhanh nhất, tránh API call nặng hoặc thao tác console.
    • Mục tiêu: Lấy thông tin runtime (project ID như "my-project-123", region như "us-central1") một cách động.
  • Phiên bản cập nhật: Theo tài liệu Google Cloud mới nhất (2024-2026), Metadata Server vẫn là cách chuẩn cho các dịch vụ như Cloud Run, GCE, GKE (xem Cloud Run Metadata và Compute Engine Metadata).

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

✅ Đáp án đúng

Use HTTP requests to query the available metadata server at the http://metadata.google.internal/ endpoint with the Metadata-Flavor: Google header.

Lý do chọn 🛠️:

  • Đây là cách performant nhất (nhanh, lightweight HTTP request nội bộ, latency <1ms) và an toàn vì chỉ accessible từ instance đang chạy (không public).
  • Trên Cloud Run, Metadata Server cung cấp trực tiếp project ID (project/project-id) và region (instance/zone hoặc instance/region).
  • Code ví dụ (Node.js/Python): Gửi GET request đến http://metadata.google.internal/computeMetadata/v1/project/project-id với header Metadata-Flavor: Google.
  • Không cần IAM role phức tạp, tự động available trên Cloud Run (knative-based).

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

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

  • Use HTTP requests to query the available metadata server at the http://metadata.google.internal/ endpoint with the Metadata-Flavor: Google header.
    ✅ Đúng 🏆: Như giải thích trên, đây là phương pháp chuẩn, hiệu suất cao (local network), bảo mật (request chỉ từ container), và dynamic (lấy realtime). Hoàn hảo cho Cloud Run theo best practices 2026.

  • In the Google Cloud console, navigate to the Project Dashboard and gather configuration details. Navigate to the Cloud Run “Variables & Secrets” tab, and add the desired environment variables in Key:Value format.
    ❌ Sai 🔒: Cách này thủ công, không dynamic (env vars fixed lúc deploy, không thay đổi runtime). Không performant vì yêu cầu cập nhật console mỗi lần thay project/region, dễ lỗi human, và không an toàn nếu expose secrets. Cloud Run hỗ trợ env vars nhưng không phải cho metadata runtime.

  • In the Google Cloud console, navigate to the Project Dashboard and gather configuration details. Write the application configuration information to Cloud Run's in-memory container filesystem.
    ❌ Sai 💥: Filesystem của Cloud Run là in-memory/tmpfs (không persistent, mất khi restart/scale). Thủ công qua console, không scalable, và kém bảo mật (dễ leak nếu container compromise). Không phù hợp cho info động như project ID/region.

  • Make an API call to the Cloud Asset Inventory API from the application and format the request to include instance metadata.
    ❌ Sai 🌐: Cloud Asset Inventory API (CAI) dùng để inventory resources toàn project (heavy, rate-limited, cần IAM permissions như cloudasset.assets.searchAllResources), latency cao (100ms+), tốn quota/cost. Không performant so với metadata server local, và overkill cho simple metadata.

Câu 200
You need to deploy resources from your laptop to Google Cloud using Terraform. Resources in your Google Cloud environment must be created using a service account. Your Cloud Identity has the roles/iam.serviceAccountTokenCreator Identity and Access Management (IAM) role and the necessary permissions to deploy the resources using Terraform. You want to set up your development environment to deploy the desired resources following Google-recommended best practices. What should you do?
  1. A 1. Download the service account’s key file in JSON format, and store it locally on your laptop.
    2. Set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of your downloaded key file.
  2. B 1. Run the following command from a command line: gcloud config set auth/impersonate_service_account service-account-name@project.iam.gserviceacccount.com.
    2. Set the GOOGLE_OAUTH_ACCESS_TOKEN environment variable to the value that is returned by the gcloud auth print-access-token command.
  3. C 1. Run the following command from a command line: gcloud auth application-default login.
    2. In the browser window that opens, authenticate using your personal credentials.
  4. D 1. Store the service account's key file in JSON format in Hashicorp Vault.
    2. Integrate Terraform with Vault to retrieve the key file dynamically, and authenticate to Vault using a short-lived access token.
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 lập môi trường phát triển (development environment) trên laptop để deploy tài nguyên lên Google Cloud bằng Terraform, theo best practices được Google khuyến nghị.

  • Yêu cầu chính:

    • Tài nguyên phải được tạo bởi service account (không dùng tài khoản cá nhân).
    • Cloud Identity của bạn có quyền roles/iam.serviceAccountTokenCreator (cho phép impersonate service account để tạo token) và các quyền cần thiết để deploy Terraform.
    • Mục tiêu: Tránh rủi ro bảo mật như lưu trữ key file lâu dài, ưu tiên sử dụng access token ngắn hạn hoặc impersonation để xác thực an toàn.
  • Bối cảnh: Terraform sử dụng Application Default Credentials (ADC) của Google Cloud để xác thực. Best practices GCP (cập nhật đến 2026) nhấn mạnh không tải xuống service account key vì rủi ro lộ key, thay vào đó dùng workload identity federation, impersonation, hoặc OAuth token ngắn hạn 📘.

✅ Đáp án đúng: Lựa chọn thứ 2

1. Run the following command from a command line: gcloud config set auth/impersonate_service_account service-account-name@project.iam.gserviceacccount.com.
2. Set the GOOGLE_OAUTH_ACCESS_TOKEN environment variable to the value that is returned by the gcloud auth print-access-token command.

Lý do lựa chọn (theo best practices GCP mới nhất):

  • Phương án này sử dụng service account impersonation qua gcloud CLI, tận dụng quyền roles/iam.serviceAccountTokenCreator để tạo access token ngắn hạn (thường 1 giờ) mà không cần tải key file 🛡️.
  • gcloud config set auth/impersonate_service_account cấu hình impersonation mặc định.
  • GOOGLE_OAUTH_ACCESS_TOKEN cung cấp token cho ADC của Terraform, đảm bảo deploy bằng service account mà an toàn, dễ quản lý (token tự động refresh nếu cần).
  • Đây là cách Google khuyến nghị cho dev từ local (không dùng key lâu dài), phù hợp Terraform GCP provider v5.x+ (2026) 🚀.

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

  • Phương án 1 (SAI):

    1. Download the service account’s key file in JSON format, and store it locally on your laptop.
    2. Set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the path of your downloaded key file.
    

    ❌ Lý do sai: Vi phạm best practices GCP vì tải và lưu key file cục bộ tạo rủi ro cao (key bị lộ nếu laptop mất, không rotate tự động). GCP khuyến cáo tránh service account keys từ 2021 và nghiêm ngặt hơn ở 2026, ưu tiên impersonation hoặc OIDC 🛑. GOOGLE_APPLICATION_CREDENTIALS chỉ dùng cho key, không an toàn cho dev.

  • Phương án 2 (ĐÚNG): ✅ (Đã giải thích ở trên).

  • Phương án 3 (SAI):

    1. Run the following command from a command line: gcloud auth application-default login.
    2. In the browser window that opens, authenticate using your personal credentials.
    

    ❌ Lý do sai: Sử dụng tài khoản cá nhân (user account) qua ADC login, không phải service account như yêu cầu. Token từ user không đại diện cho service account, vi phạm quy định "resources must be created using a service account" 👤. Phù hợp dev nhanh nhưng không theo yêu cầu.

  • Phương án 4 (SAI):

    1. Store the service account's key file in JSON format in Hashicorp Vault.
    2. Integrate Terraform with Vault to retrieve the key file dynamically, and authenticate to Vault using a short-lived access token.
    

    ❌ Lý do sai: Vẫn tạo và lưu key file (dù trong Vault), chỉ di chuyển rủi ro chứ không loại bỏ (key vẫn tồn tại). GCP best practices 2026 ưu tiên zero-key như impersonation hoặc Workload Identity Federation, không cần Vault cho trường hợp dev local đơn giản 🔒. Phức tạp hóa không cần thiết cho laptop deploy.

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

Phương án đúng giúp môi trường dev an toàn, tuân thủ zero-trust! 🚀