Ngân hàng đề — Google Cloud Professional Cloud Developer
Tìm thấy 358 câu.
- A Set up a backend with Compute Engine web server instances with a private IP address behind a TCP proxy load balancer.
- B Configure the firewall rules to allow all ingress traffic to connect to the Compute Engine web servers, with each server having a unique external IP address.
- C Configure Cloud Identity-Aware Proxy API for SSH access. Then configure the Compute Engine servers with private IP addresses behind an HTTP(s) load balancer for the application web traffic.
- D Set up a backend with Compute Engine web server instances with a private IP address behind an HTTP(S) load balancer. Set up a bastion host with a public IP address and open firewall ports. Connect to the web instances using the bastion host.
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 cấu hình các instance Compute Engine trong Google Cloud Platform (GCP) để chạy một ứng dụng web có thể truy cập qua HTTP và HTTPS. Ứng dụng này cần được bảo vệ theo best practices khuyến nghị của Google, đồng thời hỗ trợ SSH từ laptop từ xa để thực hiện bảo trì (maintenance) định kỳ.
Các yêu cầu chính:
- Web traffic: Phải an toàn, không expose trực tiếp instances ra internet.
- SSH access: Phải bảo mật cao, tránh mở port SSH public (thường là port 22) để giảm rủi ro tấn công.
- Best practices GCP (cập nhật đến 2026): Sử dụng Identity-Aware Proxy (IAP) cho truy cập SSH an toàn (context-aware access), kết hợp HTTP(S) Load Balancer với instances chỉ có private IP để xử lý traffic web mà không cần public IP trên instances. Điều này tuân thủ nguyên tắc least privilege và zero trust security model của GCP.
📘 Tài liệu tham khảo:
- GCP IAP for TCP forwarding (SSH)
- HTTP(S) Load Balancing best practices
- Compute Engine security best practices
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Configure Cloud Identity-Aware Proxy API for SSH access. Then configure the Compute Engine servers with private IP addresses behind an HTTP(s) load balancer for the application web traffic.
Lý do 🛠️:
- IAP cho SSH: IAP cung cấp truy cập SSH an toàn mà không cần public IP hoặc mở firewall port 22. Bạn chỉ cần enable IAP TCP forwarding và sử dụng
gcloud compute sshvới IAM permissions – hoàn toàn tuân thủ zero-trust, hỗ trợ MFA và audit logs (cập nhật IAP v2 với enhanced security đến 2026). - Private IP + HTTP(S) LB: Web servers chỉ cần private IP, traffic HTTP/HTTPS được route qua Global/Regional HTTP(S) Load Balancer (support SSL termination, autoscaling). Không expose instances trực tiếp, giảm attack surface.
- Đây là best practice chính thức của GCP cho production workloads, tối ưu chi phí và bảo mật.
📋 Giải thích tất cả các phương án (đúng/sai)
-
❌ Phương án SAI: Set up a backend with Compute Engine web server instances with a private IP address behind a TCP proxy load balancer.
Giải thích: TCP Proxy Load Balancer chỉ phù hợp cho non-HTTP traffic (không terminate SSL/HTTPS), không hỗ trợ HTTP/HTTPS features như URL rewriting hay certificate management. GCP khuyến nghị HTTP(S) LB thay thế cho web apps. Sử dụng sai LB type sẽ không handle HTTPS đúng cách. -
❌ Phương án SAI: Configure the firewall rules to allow all ingress traffic to connect to the Compute Engine web servers, with each server having a unique external IP address.
Giải thích: Mở all ingress traffic (0.0.0.0/0) và assign external IP cho mỗi instance là rủi ro bảo mật cao (dễ bị DDoS, brute-force). Vi phạm best practices GCP: Không expose web servers trực tiếp, phải dùng Load Balancer + firewall rules cụ thể (tag-based). -
✅ Phương án ĐÚNG: Configure Cloud Identity-Aware Proxy API for SSH access. Then configure the Compute Engine servers with private IP addresses behind an HTTP(s) load balancer for the application web traffic.
Giải thích: Như đã phân tích ở trên – kết hợp IAP (an toàn cho SSH, không cần bastion/VPN) và HTTP(S) LB + private IP (an toàn cho web traffic). Hoàn hảo theo GCP Well-Architected Framework (Reliability & Security pillars). -
❌ Phương án SAI: Set up a backend with Compute Engine web server instances with a private IP address behind an HTTP(S) load balancer. Set up a bastion host with a public IP address and open firewall ports. Connect to the web instances using the bastion host.
Giải thích: Phần HTTP(S) LB + private IP là tốt, nhưng bastion host (jump server với public IP + mở port SSH) không phải best practice GCP nữa (dù vẫn hỗ trợ). IAP thay thế hoàn hảo, đơn giản hơn, không cần quản lý bastion (vulnerable to attacks), và tích hợp IAM native (deprecated bastion approach từ 2023+).
🧠 Kết luận: Phương án đúng đảm bảo bảo mật cao nhất, dễ scale và quản lý theo tiêu chuẩn GCP 2026! Nếu cần demo code/config, hãy hỏi thêm nhé 🚀.
- A Pipe the content of the files to the Linux Syslog daemon.
- B Install a Google version of fluentd on the Compute Engine instance.
- C Install a Google version of collectd on the Compute Engine instance.
- D Using cron, schedule a job to copy the log files to Cloud Storage once a day.
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 Cloud Logging trên Compute Engine (một dịch vụ máy ảo VM của Google Cloud Platform - GCP). Tình huống: Bạn có các ứng dụng packaged (đóng gói sẵn) và internally developed (phát triển nội bộ) chạy trên Compute Engine instance sử dụng hệ điều hành Linux. Các ứng dụng này ghi log dưới dạng text files cục bộ (local files). Mục tiêu: Gửi logs này đến Cloud Logging (dịch vụ quản lý log tập trung của GCP) một cách hiệu quả, tự động và đáng tin cậy.
✅ Vấn đề cốt lõi: Logs cục bộ không tự động đồng bộ với Cloud Logging; cần một agent hoặc công cụ thu thập log (log collector) để đọc file log, parse và đẩy lên Cloud Logging theo thời gian thực hoặc gần thực tế.
✅ Đáp án đúng và lý do lựa chọn
Install a Google version of fluentd on the Compute Engine instance.
🛠️ Lý do chi tiết:
- Fluentd là công cụ mã nguồn mở mạnh mẽ để thu thập, xử lý và chuyển tiếp logs. GCP cung cấp phiên bản Google-optimized của fluentd (gọi là Cloud Logging agent hoặc trước đây là Stackdriver Logging agent), được thiết kế đặc biệt để:
- Đọc logs từ file local (/var/log, custom paths).
- Parse theo format text, JSON, v.v.
- Gửi trực tiếp đến Cloud Logging với metadata (instance ID, project, labels).
- Đây là giải pháp chuẩn chính thức từ Google, hỗ trợ near-real-time ingestion, buffer để tránh mất log, và tích hợp dễ dàng trên Linux Compute Engine.
- Cập nhật đến 2026: Từ năm 2022, Google khuyến nghị Ops Agent (dựa trên fluentd + Prometheus), nhưng fluentd version vẫn là lựa chọn cốt lõi cho logging thuần túy và được hỗ trợ đầy đủ (không deprecated). Cài đặt đơn giản qua script:
curl -sSO https://dl.google.com/cloudagents/add-logging.sh && sudo bash add-logging.sh.
📘 Nguồn tham khảo: - Cloud Logging agent installation (GCP Docs, cập nhật 2024-2026).
- Ops Agent overview (tích hợp fluentd cho logs).
📋 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 bằng tiếng Anh. Mỗi phương án được đánh giá dựa trên tính hiệu quả, tính chính thức và tích hợp với Cloud Logging:
-
Pipe the content of the files to the Linux Syslog daemon.
❌ Sai vì: Syslog daemon (rsyslog hoặc syslog-ng) chỉ xử lý logs hệ thống chuẩn (facility/priority), không được GCP hỗ trợ trực tiếp để đẩy lên Cloud Logging. Pipe logs thủ công sẽ mất metadata GCP (như resource labels), không có buffer/retry tự động, và không parse custom text files hiệu quả. Giải pháp này không scalable, dễ lỗi và không phải best practice của GCP. -
Install a Google version of fluentd on the Compute Engine instance.
✅ Đúng (như đã giải thích ở trên). Đây là giải pháp tối ưu, chính thức từ Google, hỗ trợ tất cả loại logs text từ apps packaged/internal, với config dễ dàng qua/etc/google-fluentd/google-fluentd.conf. -
Install a Google version of collectd on the Compute Engine instance.
❌ Sai vì: Collectd là agent chuyên thu thập metrics và performance data (CPU, memory, disk), không phải logs. GCP cung cấp Google version of collectd cho Cloud Monitoring (metrics), không hỗ trợ đọc/đẩy text log files đến Cloud Logging. Sử dụng sai công cụ sẽ không giải quyết vấn đề logs. -
Using cron, schedule a job to copy the log files to Cloud Storage once a day.
❌ Sai vì: Cron chỉ copy thủ công hàng ngày sang Cloud Storage (batch processing), dẫn đến:- Logs không real-time (chậm 24h).
- Không parse/extract metadata tự động.
- Cloud Storage chỉ lưu trữ file thô, phải dùng thêm Pub/Sub/Log Router để đẩy sang Cloud Logging (phức tạp, tốn kém). Không có buffer/retry, dễ mất logs nếu cron fail. Đây là workaround kém, không phải giải pháp native của GCP.
🧩 Kết luận: Lựa chọn fluentd đảm bảo tích hợp seamless, zero-downtime và tuân thủ best practices GCP cho production workloads! Nếu cần config chi tiết, tham khảo docs chính thức. 🚀
- A Embed the appropriate database connection string in the image. Create a different image for each environment.
- B When creating the Compute Engine instance, add a tag with the name of the database to be connected. In your application, query the Compute Engine API to pull the tags for the current instance, and use the tag to construct the appropriate database connection string.
- C When creating the Compute Engine instance, create a metadata item with a key of ג€DATABASEג€ and a value for the appropriate database connection string. In your application, read the ג€DATABASEג€ environment variable, and use the value to connect to the appropriate database.
- D When creating the Compute Engine instance, create a metadata item with a key of ג€DATABASEג€ and a value for the appropriate database connection string. In your application, query the metadata server for the ג€DATABASEג€ value, and use the value to connect to the appropriate database.
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 tạo fully baked (hay còn gọi là golden images) cho Google Compute Engine trên Google Cloud Platform (GCP). Đây là các hình ảnh máy ảo (VM images) đã được cấu hình sẵn hoàn chỉnh, chứa ứng dụng của bạn, để triển khai nhanh chóng và nhất quán.
Yêu cầu chính: Ứng dụng cần bootstrap (khởi tạo tự động) để kết nối với cơ sở dữ liệu (DB) phù hợp dựa trên môi trường chạy (test, staging, production). Điều này có nghĩa là image phải linh hoạt, không hardcode thông tin DB cố định, mà vẫn đảm bảo tính bảo mật, dễ quản lý và tuân thủ best practices của GCP.
Bối cảnh kỹ thuật (cập nhật đến 2026): Golden images thường được dùng với managed instance groups hoặc custom images trong Compute Engine. Để xử lý config động theo môi trường, GCP khuyến nghị sử dụng instance metadata qua Metadata Server (http://metadata.google.internal), giúp inject config mà không cần rebuild image. Tránh hardcode để tuân thủ Infrastructure as Code (IaC) và zero-trust security.
📘 Tài liệu tham khảo:
- Compute Engine Metadata Overview (GCP Docs, cập nhật 2025).
- Best Practices for Golden Images.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng:
When creating the Compute Engine instance, create a metadata item with a key of DATABASE and a value for the appropriate database connection string. In your application, query the metadata server for the DATABASE value, and use the value to connect to the appropriate database.
Lý do:
🛠️ Phương án này sử dụng instance metadata server của Compute Engine – một dịch vụ nội bộ (http://169.254.169.254/computeMetadata/v1/ hoặc metadata.google.internal) để lấy giá trị metadata mà không cần credentials, an toàn và hiệu suất cao. Bạn set metadata key-value khi tạo instance (qua gcloud, Console hoặc Terraform), ứng dụng query trực tiếp từ server này để lấy connection string DB phù hợp với env (test/staging/prod). Golden image giữ nguyên, chỉ thay metadata → linh hoạt, immutable infrastructure. Đây là best practice chính thức của GCP cho config động.
❌ Phân tích tất cả các phương án
-
Phương án A (SAI):
Embed the appropriate database connection string in the image. Create a different image for each environment.
Giải thích sai: ❌ Hardcode connection string trực tiếp vào image vi phạm nguyên tắc golden images (immutable và reusable). Phải tạo nhiều image riêng cho mỗi env → tốn kém lưu trữ, khó maintain (update app phải rebuild tất cả), không scale tốt với managed instance groups. Không an toàn vì secrets lộ trong image. -
Phương án B (SAI):
When creating the Compute Engine instance, add a tag with the name of the database to be connected. In your application, query the Compute Engine API to pull the tags for the current instance, and use the tag to construct the appropriate database connection string.
Giải thích sai: ❌ Tags dùng cho firewall rules hoặc resource grouping, không phải config app. App phải query Compute Engine API (cần service account + IAM permissions) → phức tạp, chậm (network call), rủi ro security (expose API keys), và không idempotent. Không phù hợp bootstrap nhanh. -
Phương án C (SAI):
When creating the Compute Engine instance, create a metadata item with a key ofDATABASEand a value for the appropriate database connection string. In your application, read theDATABASEenvironment variable, and use the value to connect to the appropriate database.
Giải thích sai: ❌ Metadata không tự động mount thành environment variable trong Compute Engine (khác với một số cloud khác). App phải query metadata server qua HTTP (với header Metadata-Flavor: Google), không phải đọc env var trực tiếp. Cách này sẽ fail runtime. -
Phương án D (ĐÚNG):
When creating the Compute Engine instance, create a metadata item with a key ofDATABASEand a value for the appropriate database connection string. In your application, query the metadata server for theDATABASEvalue, and use the value to connect to the appropriate database.
Giải thích đúng: ✅ Hoàn hảo! Metadata server cung cấp zero-config access từ bên trong VM. Code ví dụ (Python):import requests response = requests.get('http://metadata.google.internal/computeMetadata/v1/instance/attributes/DATABASE', headers={'Metadata-Flavor': 'Google'}) db_conn = response.textScale tốt với autoscaling groups, secrets có thể dùng Secret Manager inject vào metadata.
🧠 Lời khuyên từ Professional Cloud Developer: Sử dụng Cloud Init hoặc Startup Scripts kết hợp metadata cho bootstrap phức tạp hơn. Test với gcloud compute instances create để verify!
Spanner database. You want to follow security best practices while minimizing code changes. How should you configure your application to retrieve Spanner credentials?
- A Configure the appropriate service accounts, and use Workload Identity to run the pods.
- B Store the application credentials as Kubernetes Secrets, and expose them as environment variables.
- C Configure the appropriate routing rules, and use a VPC-native cluster to directly connect to the database.
- D Store the application credentials using Cloud Key Management Service, and retrieve them whenever a database connection is made.
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 phát triển một ứng dụng microservice chạy trên Google Kubernetes Engine (GKE), cần đọc/ghi dữ liệu vào Cloud Spanner database. Yêu cầu chính là tuân thủ best practices bảo mật (như nguyên tắc least privilege, tránh lưu trữ credentials tĩnh) đồng thời giảm thiểu thay đổi code (không cần hardcode hoặc quản lý key thủ công).
Cụ thể:
- Ứng dụng chạy dưới dạng pods trên GKE cluster.
- Cần retrieve Spanner credentials một cách an toàn để kết nối database.
- Mục tiêu: Sử dụng cơ chế tự động, tích hợp native với GCP IAM, tránh rủi ro lộ thông tin xác thực.
📘 Tài liệu tham khảo:
- Google Cloud Workload Identity (cập nhật 2024-2026: Hỗ trợ đầy đủ cho GKE 1.28+ và Spanner IAM roles như
roles/spanner.databaseUser). - Cloud Spanner Authentication (Best practice: Sử dụng service accounts với Workload Identity).
- GKE Security Best Practices (Khuyến nghị tránh Secrets cho credentials).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Configure the appropriate service accounts, and use Workload Identity to run the pods.
Lý do 🛠️:
- Workload Identity là cơ chế bảo mật tích hợp native giữa GKE và GCP IAM, cho phép pods tự động sử dụng GCP Service Account (SA) mà không cần lưu trữ JSON key files hoặc secrets.
- Quy trình: Tạo GCP SA với quyền Spanner (ví dụ:
roles/spanner.databaseUser), bind với Kubernetes Service Account (KSA) qua annotationiam.gke.io/gcp-service-account. Pods sẽ tự động mount OIDC token để exchange thành access token cho Spanner. - Ưu điểm: Giảm thiểu code changes (chỉ cần dùng default credentials từ metadata server), zero-trust model, tự động rotate credentials, tuân thủ least privilege.
- Đây là best practice chính thức từ Google Cloud đến 2026, thay thế hoàn toàn việc dùng key files.
🔍 Phân tích tất cả các phương án (đúng/sai)
-
[ĐÚNG] Configure the appropriate service accounts, and use Workload Identity to run the pods.
✅ Đúng vì: Như giải thích trên, đây là cách an toàn nhất, tự động hóa credentials qua OIDC federation. Không cần code changes (ứng dụng dùngApplication Default Credentials - ADC). Hỗ trợ đầy đủ trên GKE Standard/Private clusters (phiên bản 1.21+). Giảm rủi ro tấn công supply-chain. -
[SAI] Store the application credentials as Kubernetes Secrets, and expose them as environment variables.
❌ Sai vì: Kubernetes Secrets không mã hóa at-rest mặc định (dễ đọc quakubectlhoặc etcd), dễ bị lộ nếu pod bị compromise. Phải thay đổi code để đọc env vars/key files, vi phạm "minimize code changes". Best practice khuyến nghị tránh hoàn toàn cho GCP services (dùng Workload Identity thay thế). -
[SAI] Configure the appropriate routing rules, and use a VPC-native cluster to directly connect to the database.
❌ Sai vì: Đây chỉ giải quyết networking/layer 3 connectivity (VPC-native GKE dùng alias IP cho intra-cluster traffic, routing rules cho firewall/Private Service Connect). Không liên quan đến credentials (vẫn cần auth để truy cập Spanner). Spanner yêu cầu IAM/SASL auth, không phải chỉ connect trực tiếp. -
[SAI] Store the application credentials using Cloud Key Management Service, and retrieve them whenever a database connection is made.
❌ Sai vì: KMS dùng để encrypt/decrypt data, không phải lưu trữ/retrieve credentials dài hạn (phải dùng IAM thay thế). Yêu cầu thay đổi code lớn để gọi KMS API mỗi connection (unwrap key), tăng latency/complexity. Không an toàn bằng Workload Identity (vẫn cần manage master keys), vi phạm minimize code changes.
🛡️ Kết luận: Workload Identity là lựa chọn tối ưu cho GKE + Spanner, đảm bảo bảo mật zero-credentials và scalability đến 2026!
- A Assign the Project Editor role.
- B Assign the Project Owner role.
- C Assign the Cloud SQL Client role.
- D Assign the Cloud SQL Editor role.
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 trên Compute Engine instance (một máy ảo trong Google Cloud Platform - GCP) và kết nối với Cloud SQL (dịch vụ cơ sở dữ liệu quản lý). Ứng dụng sử dụng Cloud SQL Proxy (công cụ proxy an toàn để kết nối database mà không cần mở cổng firewall) thông qua service account gắn với instance. Mục tiêu là tuân thủ best practice của Google về nguyên tắc least privilege (quyền hạn tối thiểu), nghĩa là chỉ cấp quyền cần thiết nhất cho service account để tránh rủi ro bảo mật.
Cụ thể:
- Cloud SQL Proxy yêu cầu service account có quyền kết nối (connect) đến instance Cloud SQL, nhưng không cần quyền chỉnh sửa dữ liệu trừ khi ứng dụng thực sự cần.
- Theo tài liệu GCP mới nhất (cập nhật đến 2026), role phù hợp nhất là loại client-only để chỉ cho phép kết nối qua proxy.
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Assign the Cloud SQL Client role.
Lý do:
- Role Cloud SQL Client (roles/cloudsql.client) là quyền hạn tối thiểu được Google khuyến nghị cho service account khi sử dụng Cloud SQL Proxy. Nó chỉ cho phép kết nối (connect) đến Cloud SQL instance qua proxy, mà không cấp quyền chỉnh sửa (edit) hoặc quản lý database. Điều này hoàn toàn phù hợp với nguyên tắc least privilege, giảm thiểu rủi ro nếu service account bị xâm phạm.
- Nếu ứng dụng chỉ đọc/ghi dữ liệu qua proxy (không quản lý instance), role này đủ dùng và là best practice chính thức.
🛠️ Giải thích tất cả các phương án (đúng và sai)
-
❌ Assign the Project Editor role.
Sai vì: Role Project Editor (roles/editor) cấp quyền quá rộng trên toàn dự án, bao gồm chỉnh sửa hầu hết tài nguyên (Compute Engine, Cloud SQL, Storage, v.v.). Nó vi phạm nguyên tắc least privilege vì service account chỉ cần quyền connect Cloud SQL, không cần edit toàn bộ dự án. Sử dụng role này tăng rủi ro bảo mật cao. -
❌ Assign the Project Owner role.
Sai vì: Role Project Owner (roles/owner) là quyền cao nhất, cho phép kiểm soát toàn bộ dự án (xóa, chỉnh sửa mọi thứ). Đây là quyền thừa thãi và nguy hiểm nhất, hoàn toàn trái với best practice least privilege. Google khuyên tránh dùng cho service account. -
✅ Assign the Cloud SQL Client role.
Đúng vì: Như đã giải thích ở trên, role này (roles/cloudsql.client) chỉ cấp quyền connect cụ thể cho Cloud SQL qua proxy, là minimum access chính xác theo khuyến nghị Google. Không cấp quyền edit hoặc admin. -
❌ Assign the Cloud SQL Editor role.
Sai vì: Role Cloud SQL Editor (roles/cloudsql.editor) cấp quyền chỉnh sửa (edit) instance Cloud SQL (như thay đổi cấu hình, backup), ngoài quyền connect. Nó vượt quá nhu cầu chỉ kết nối qua proxy, vi phạm least privilege dù vẫn hẹp hơn Project roles.
📘 Tài liệu tham khảo (cập nhật mới nhất GCP đến 2026)
- Cloud SQL Auth Proxy IAM permissions – Hướng dẫn chính thức về service account và role cho proxy.
- Cloud SQL IAM roles – Chi tiết roles/cloudsql.client vs .editor.
- Best practices for Cloud SQL security – Nhấn mạnh least privilege.
- IAM Roles reference: roles/cloudsql.client.
Hy vọng phân tích này giúp bạn ôn thi hiệu quả! 🚀 Nếu cần thêm ví dụ thực hành, hãy hỏi nhé!
- A Use a Vertical Pod Autoscaler to scale the containers, and expose them via a ClusterIP Service.
- B Use a Vertical Pod Autoscaler to scale the containers, and expose them via a NodePort Service.
- C Use a Horizontal Pod Autoscaler to scale the containers, and expose them via a ClusterIP Service.
- D Use a Horizontal Pod Autoscaler to scale the containers, and expose them via a NodePort Service.
Xem giải thích
🧩 Giải thích nội dung câu hỏi
Câu hỏi tập trung vào việc triển khai một dịch vụ stateless (không trạng thái) trên Google Kubernetes Engine (GKE). Dịch vụ này chỉ được truy cập bởi các dịch vụ khác trong cùng cluster GKE, không cần expose ra ngoài. Yêu cầu chính là scale nhanh nhất có thể để đáp ứng tải thay đổi đột ngột.
🛠️ Phân tích yêu cầu chính:
- Stateless services: Phù hợp với autoscaling bằng cách tăng/giảm số lượng pod (horizontal scaling).
- Internal access only: Sử dụng loại Service nội bộ, không expose port ra ngoài cluster.
- Scale nhanh: Ưu tiên cơ chế autoscaling phản ứng nhanh với metrics như CPU/Memory.
- Mục tiêu: Chọn đúng autoscaler và Service type để đảm bảo hiệu suất cao nhất trên GKE (dựa trên Kubernetes phiên bản mới nhất đến 2026, GKE hỗ trợ HPA v2 với custom metrics và VPA v0.11+).
📘 Tài liệu tham khảo:
- Kubernetes HPA Documentation (cập nhật 2024-2026).
- GKE Autoscaling Guide (Google Cloud, hỗ trợ HPA với metrics nhanh).
- Kubernetes Service Types.
✅ Đáp án đúng
Use a Horizontal Pod Autoscaler to scale the containers, and expose them via a ClusterIP Service.
Lý do lựa chọn 🏆:
- Horizontal Pod Autoscaler (HPA) là lựa chọn tối ưu cho scale ngang (tăng/giảm số pod nhanh chóng dựa trên CPU, Memory hoặc custom metrics). Với stateless services, HPA phản ứng trong vài giây đến phút, không cần restart pod, phù hợp scale nhanh nhất trên GKE.
- ClusterIP Service chỉ expose nội bộ cluster, lý tưởng cho internal traffic giữa các services trong GKE, giảm latency và bảo mật (không mở port ra ngoài).
- Kết hợp này đảm bảo scale nhanh, an toàn cho internal-only service.
📋 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, giữ nguyên nội dung gốc bằng tiếng Anh. Mỗi phương án được đánh giá đúng/sai với lý do cụ thể dựa trên best practices GKE/Kubernetes mới nhất:
-
❌ [SAI] Use a Vertical Pod Autoscaler to scale the containers, and expose them via a ClusterIP Service.
Giải thích sai: Vertical Pod Autoscaler (VPA) chỉ scale dọc (tăng/giảm CPU/Memory requests/limits của pod hiện tại), thường yêu cầu restart pod để áp dụng thay đổi, dẫn đến downtime và scale chậm hơn HPA (có thể mất vài phút). Không phù hợp với yêu cầu "scale as quickly as possible" cho stateless services. ClusterIP đúng cho internal, nhưng VPA làm bottleneck. -
❌ [SAI] Use a Vertical Pod Autoscaler to scale the containers, and expose them via a NodePort Service.
Giải thích sai: VPA scale chậm như trên, không lý tưởng cho quick scaling. NodePort Service expose service qua port cố định trên mọi node (30000-32767), cho phép truy cập từ ngoài cluster – vi phạm yêu cầu "only accessed by other services in the GKE cluster". Tăng rủi ro bảo mật và không cần thiết. -
✅ [ĐÚNG] Use a Horizontal Pod Autoscaler to scale the containers, and expose them via a ClusterIP Service.
Giải thích đúng: HPA scale ngang nhanh chóng (thêm/xóa pod dựa trên metrics real-time, hỗ trợ predictive scaling trên GKE 2024+). ClusterIP đảm bảo internal-only access, tối ưu latency nội bộ. Đây là best practice cho internal microservices trên GKE. -
❌ [SAI] Use a Horizontal Pod Autoscaler to scale the containers, and expose them via a NodePort Service.
Giải thích sai: HPA đúng cho quick scaling, nhưng NodePort expose ra ngoài cluster (qua node IP:port), không phù hợp internal-only service. Gây lãng phí resources và rủi ro bảo mật (có thể bị truy cập từ internet nếu không có firewall).
🛡️ Lưu ý thêm: Trên GKE (phiên bản 1.29+ đến 2026), HPA tích hợp tốt với Cluster Autoscaler và Metrics Server cho scale mượt mà. Tránh VPA cho production high-scale vì khuyến cáo "use with caution" (Kubernetes docs). Nếu cần, kết hợp HPA + VPA nhưng ưu tiên HPA cho tốc độ!
Functions. As you modernize the application, you make a change to the API of the service that is backward-incompatible. You need to support both existing callers who use the original API and new callers who use the new API. What should you do?
- A Leave the original Cloud Function as-is and deploy a second Cloud Function with the new API. Use a load balancer to distribute calls between the versions.
- B Leave the original Cloud Function as-is and deploy a second Cloud Function that includes only the changed API. Calls are automatically routed to the correct function.
- C Leave the original Cloud Function as-is and deploy a second Cloud Function with the new API. Use Cloud Endpoints to provide an API gateway that exposes a versioned API.
- D Re-deploy the Cloud Function after making code changes to support the new API. Requests for both versions of the API are fulfilled based on a version identifier included in the call.
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: Bạn đã migrate một ứng dụng monolithic sang Google Cloud, phân tách thành các microservices. Một microservice được deploy trên Cloud Functions. Khi modernize ứng dụng, bạn thực hiện thay đổi API không tương thích ngược (backward-incompatible). Yêu cầu là hỗ trợ cả caller cũ (sử dụng API gốc) và caller mới (sử dụng API mới) mà không làm gián đoạn dịch vụ hiện tại.
📌 Mục tiêu chính: Giữ nguyên Cloud Function cũ, triển khai phiên bản mới, và sử dụng cơ chế routing/versioning phù hợp để xử lý traffic từ hai nhóm caller khác nhau một cách mượt mà. Đây là best practice trong GCP để quản lý API versioning cho serverless functions (cập nhật đến 2026: Cloud Functions Gen 2 hỗ trợ tích hợp tốt hơn với API gateways).
✅ Đáp án đúng
Leave the original Cloud Function as-is and deploy a second Cloud Function with the new API. Use Cloud Endpoints to provide an API gateway that exposes a versioned API.
Lý do lựa chọn:
- Cloud Endpoints là API gateway chính thức của GCP, hỗ trợ versioning API (ví dụ: /v1/ và /v2/) và routing traffic đến các backend khác nhau (như hai Cloud Functions riêng biệt).
- Giữ nguyên function cũ tránh downtime, deploy function mới song song, Endpoints làm proxy thông minh dựa trên path/version trong request.
- Phù hợp với nguyên tắc zero-downtime deployment và API lifecycle management trong GCP (tính năng ổn định từ 2023-2026).
🛠️ Ví dụ: Endpoints config OpenAPI spec với paths versioned, backend mappings riêng cho từng function.
📋 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, giữ nguyên văn bản gốc tiếng Anh. Mỗi phương án được đánh giá đúng/sai dựa trên tài liệu GCP mới nhất (Cloud Functions 2nd Gen, Endpoints v2).
-
[SAI] Leave the original Cloud Function as-is and deploy a second Cloud Function with the new API. Use a load balancer to distribute calls between the versions.
❌ Sai vì: Load Balancer (như HTTP(S) Load Balancer) không hỗ trợ routing dựa trên API version/path tự động cho Cloud Functions. Nó chỉ phân phối traffic round-robin hoặc dựa trên header cơ bản, không phù hợp cho versioning API phức tạp. Sử dụng LB sẽ gây hỗn loạn traffic lẫn lộn giữa old/new callers. (Không phải best practice cho serverless API). -
[SAI] Leave the original Cloud Function as-is and deploy a second Cloud Function that includes only the changed API. Calls are automatically routed to the correct function.
❌ Sai vì: GCP không có cơ chế auto-routing giữa các Cloud Functions riêng biệt dựa trên API changes. Cloud Functions trigger dựa trên event/HTTP URL cố định, không tự detect và route theo nội dung API. Điều này sẽ yêu cầu custom logic, vi phạm yêu cầu "hỗ trợ cả hai callers" mà không cần thay đổi code. -
[ĐÚNG] Leave the original Cloud Function as-is and deploy a second Cloud Function with the new API. Use Cloud Endpoints to provide an API gateway that exposes a versioned API.
✅ Đúng vì: Như giải thích ở trên. Cloud Endpoints hỗ trợ multiple backends (hai functions), versioned endpoints (e.g., /api/v1 -> old func, /api/v2 -> new func), authentication, monitoring. Tích hợp native với Cloud Functions qua Service Config. Hoàn hảo cho microservices migration. -
[SAI] Re-deploy the Cloud Function after making code changes to support the new API. Requests for both versions of the API are fulfilled based on a version identifier included in the call.
❌ Sai vì: Re-deploy sẽ overwrite function cũ, gây downtime cho callers cũ. Cloud Functions không có built-in versioning dựa trên identifier (như query param/version header) mà không cần code changes phức tạp (if-else logic). Điều này vi phạm backward compatibility và không scale tốt cho serverless.
📘 Tài liệu tham khảo (cập nhật 2026)
- Cloud Endpoints docs: cloud.google.com/endpoints/docs – Hướng dẫn versioning và multi-backend.
- Cloud Functions versioning: cloud.google.com/functions/docs/bestpractices#versioning – Khuyến nghị dùng API Gateway.
- GCP Architecture Center: cloud.google.com/architecture/microservices – Best practices cho API migration.
- Release notes 2025-2026: Cloud Endpoints v2.29+ hỗ trợ Gen2 Functions seamless integration.
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/config, hãy hỏi thêm.
- A Store each comment in a subcollection of the article.
- B Add each comment to an array property on the article.
- C Store each comment in a document, and add the comment's key to an array property on the article.
- D Store each comment in a document, and add the comment's key to an array property on the user profile.
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ế schema dữ liệu trong Firestore (một cơ sở dữ liệu NoSQL thuộc Google Cloud Platform/Firebase) cho một ứng dụng cho phép người dùng đọc và đăng bình luận (comments) trên các bài báo (news articles).
🔍 Yêu cầu chính:
- Ứng dụng cần lưu trữ và hiển thị bình luận do người dùng gửi.
- Schema phải hỗ trợ số lượng bài báo và bình luận không xác định (unknown number), nghĩa là phải scale linh hoạt, không bị giới hạn bởi kích thước tài liệu hoặc số lượng dữ liệu lớn.
- Firestore hoạt động dựa trên tài liệu (documents) và tập hợp (collections/subcollections), với các quy tắc thiết kế tốt để tránh vấn đề hiệu suất, chi phí truy vấn và giới hạn kích thước (ví dụ: mỗi document tối đa 1MB).
🛠️ Bối cảnh kỹ thuật: Đây là mô hình one-to-many (một bài báo có nhiều bình luận). Firestore khuyến nghị sử dụng subcollections cho các mối quan hệ lồng nhau để dễ dàng query, scale và quản lý dữ liệu lớn (theo best practices cập nhật đến năm 2026, không có thay đổi lớn về giới hạn này).
📘 Nguồn tham khảo:
- Firestore Best Practices - Collections and Subcollections (Google Firebase Documentation, cập nhật 2025).
- Firestore Data Model (Google Cloud Docs, phiên bản mới nhất 2026).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Store each comment in a subcollection of the article.
Lý do 🏆:
- Phương án này tối ưu nhất cho Firestore vì sử dụng subcollection (tập hợp con) bên trong document bài báo (article document). Mỗi bình luận là một document riêng biệt trong subcollection
commentscủa article đó. - Lợi ích scale: Hỗ trợ số lượng bình luận không giới hạn (không bị ràng buộc bởi kích thước 1MB/document). Dễ dàng query tất cả comments của một bài báo bằng
collectionGrouphoặc trực tiếp từ subcollection. - Hiệu suất cao: Giảm tải truy vấn, hỗ trợ pagination, và tuân thủ mô hình hierarchical data modeling của Firestore (ví dụ:
/articles/{articleId}/comments/{commentId}). - Phù hợp với unknown number vì subcollections có thể chứa hàng triệu documents mà không ảnh hưởng đến document cha.
📋 Giải thích tất cả các phương án (đúng và sai)
-
✅ Store each comment in a subcollection of the article.
Đúng vì: Như đã giải thích ở trên, đây là best practice của Firestore cho one-to-many relationships. Subcollection cho phép scale vô hạn, dễ query (ví dụ:db.collection('articles').doc(articleId).collection('comments')), và tránh vấn đề hotspotting. Không vi phạm giới hạn document size. -
❌ Add each comment to an array property on the article.
Sai vì: Lưu tất cả comments vào một mảng (array) trong document bài báo sẽ vi phạm giới hạn 1MB/document khi số lượng comments tăng (unknown number). Không hỗ trợ query hiệu quả (phải đọc toàn bộ array), khó pagination, và tốn kém chi phí đọc dữ liệu lớn. Firestore không khuyến nghị arrays cho dữ liệu động lớn. -
❌ Store each comment in a document, and add the comment's key to an array property on the article.
Sai vì: Mặc dù lưu comment riêng (tốt), nhưng việc thêm key comment vào array trên document article vẫn gặp vấn đề giới hạn array size (1MB). Khi comments nhiều, array phình to gây lỗi. Query vẫn phức tạp (phải đọc array trước rồi fetch comments), không scale tốt cho unknown number, và tạo redundancy không cần thiết. -
❌ Store each comment in a document, and add the comment's key to an array property on the user profile.
Sai vì: Liên kết comments với user profile thay vì article là không logic cho use case (hiển thị comments theo bài báo, không theo user). Array trên user profile lại gặp giới hạn size, khó query comments của một article cụ thể. Phá vỡ mô hình dữ liệu (comments thuộc về article, không phải user), dẫn đến truy vấn phức tạp và kém hiệu suất.
🧠 Kết luận: Thiết kế subcollection là lựa chọn scale nhất và tuân thủ best practices Firestore 2026, giúp ứng dụng xử lý hàng triệu comments mà không gặp bottleneck! 🚀
Engine instance that doesn't have a public IP address. What should you do?
- A Use Carrier Peering
- B Use VPC Network Peering
- C Use Shared VPC networks
- D Use Private Google Access
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi này thuộc chủ đề Google Cloud Platform (GCP), cụ thể là về Virtual Private Cloud (VPC) và cách truy cập các dịch vụ Google APIs từ Compute Engine instance (máy ảo VM).
Chi tiết câu hỏi:
Bạn đã phát triển một ứng dụng và cần gọi Cloud Storage API (API của dịch vụ lưu trữ đám mây Google Cloud Storage) từ một Compute Engine instance không có địa chỉ IP công khai (public IP address). Vấn đề ở đây là VM nằm trong mạng riêng tư (private network), không thể truy cập internet công khai trực tiếp. Bạn cần tìm cách cho phép VM này gọi API của Google mà không cần public IP, đảm bảo an toàn và tuân thủ nguyên tắc zero-trust networking.
📘 Bối cảnh kiến thức (cập nhật đến 2026): Trong GCP, các dịch vụ như Cloud Storage có private endpoints (ví dụ: storage.googleapis.com với IP private range 199.36.153.4/30). Giải pháp phải sử dụng Private Google Access để route traffic nội bộ qua private IP, tránh public internet. (Nguồn: Cloud VPC Documentation - Private Google Access).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Use Private Google Access
Lý do chi tiết:
🛠️ Private Google Access là tính năng của VPC cho phép các VM không có public IP truy cập các Google APIs và services (như Cloud Storage API) qua private IP addresses (dải 199.36.153.4/30). Khi kích hoạt trên subnet của VM, traffic sẽ được route nội bộ qua Google's private network, không cần NAT gateway hay public IP, đảm bảo bảo mật cao và hiệu suất tốt.
✅ Đây là giải pháp chuẩn và được khuyến nghị trong GCP từ phiên bản VPC mới nhất (2026), tránh rủi ro lộ public IP. Không dùng sẽ khiến VM không gọi được API private endpoints.
📘 Nguồn: Configure Private Google Access.
❌ 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 tính phù hợp với yêu cầu (truy cập Cloud Storage API từ VM private IP).
-
Use Carrier Peering
❌ Sai: Carrier Peering là kết nối vật lý trực tiếp giữa GCP và nhà cung cấp dịch vụ internet (carrier) để trao đổi traffic công khai với chi phí thấp. Nó không liên quan đến việc truy cập Google APIs nội bộ từ VM private, mà chỉ dùng cho traffic outbound/inbound lớn qua public internet. Không giải quyết vấn đề private access. -
Use VPC Network Peering
❌ Sai: VPC Network Peering dùng để kết nối hai VPC (cùng project hoặc khác project/on-prem) qua private IP, chia sẻ subnets/resources. Tuy nhiên, nó không áp dụng cho truy cập Google APIs từ VM, vì Cloud Storage API không phải VPC riêng mà là service managed bởi Google front-end. -
Use Shared VPC networks
❌ Sai: Shared VPC (hay Host Project VPC) cho phép nhiều project chia sẻ một VPC chung để quản lý tài nguyên tập trung. Nó không giải quyết vấn đề truy cập APIs từ VM private IP, mà chỉ là mô hình networking multi-project. VM vẫn cần Private Google Access riêng để gọi Cloud Storage. -
Use Private Google Access
✅ Đúng: Như đã giải thích ở trên, đây là giải pháp chính xác, kích hoạt trên subnet để VM private gọi APIs qua private endpoints. Hoàn hảo cho trường hợp này!
🧩 Tóm tắt nhanh: Câu hỏi kiểm tra kiến thức core về private connectivity trong GCP VPC. Luôn ưu tiên Private Google Access cho Google services từ VM private (cập nhật 2026). Nếu cần thực hành, dùng gcloud CLI: gcloud compute networks subnets update SUBNET --enable-private-ip-google-access.
📘 Tài liệu tham khảo thêm:
CD team. What should you do?
- A Create a new feature branch, and ask the build team to rebuild the image.
- B Shut down the deployed virtual machine, export the disk, and then mount the disk locally to access the boot logs.
- C Install Packer locally, build the Compute Engine image locally, and then run it in your personal Google Cloud project.
- D Check Compute Engine OS logs using the serial port, and check the Cloud Logging logs to confirm access to the serial port.
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 một lập trình viên (developer) đang làm việc với đội CI/CD để khắc phục sự cố (troubleshoot) một tính năng mới. Đội CI/CD đã sử dụng HashiCorp Packer để xây dựng (build) một image mới cho Compute Engine (dịch vụ máy ảo trên Google Cloud) từ nhánh phát triển (development branch). Quá trình build image thành công ✅, nhưng image không khởi động (boot) được khi sử dụng. Nhiệm vụ là điều tra nguyên nhân cùng đội CI/CD một cách hiệu quả nhất.
🛠️ Mục tiêu chính: Tìm cách nhanh chóng truy cập log hệ điều hành (OS logs) để xác định lỗi boot mà không cần rebuild hoặc thay đổi lớn, phù hợp với quy trình troubleshoot trên Google Cloud Compute Engine. Đây là vấn đề phổ biến khi image custom không boot do lỗi kernel, initramfs, hoặc cấu hình sai (theo tài liệu Google Cloud cập nhật đến 2026).
📘 Tài liệu tham khảo:
- Troubleshoot Compute Engine boot issues (Google Cloud Docs, phiên bản mới nhất).
- Serial console for Compute Engine (hỗ trợ log real-time và lịch sử).
- Cloud Logging for Compute Engine (tích hợp serial logs).
✅ Đáp án đúng
Check Compute Engine OS logs using the serial port, and check the Cloud Logging logs to confirm access to the serial port.
Lý do lựa chọn:
- Đây là phương pháp chuẩn và nhanh nhất để troubleshoot boot failure trên Compute Engine 🕒. Serial port (cổng nối tiếp) cung cấp OS logs thời gian thực (real-time console output), bao gồm thông tin chi tiết về quá trình boot (như lỗi kernel panic, filesystem mount fail).
- Nếu serial port được enable (mặc định cho instance mới từ 2023+), logs tự động sync với Cloud Logging, giúp dễ dàng tìm kiếm và chia sẻ với đội CI/CD mà không cần dừng VM hoặc rebuild.
- Phù hợp quy trình best practice của Google Cloud: Không xâm phạm (non-invasive), chi phí thấp, và scale tốt cho môi trường production/dev (cập nhật GCP 2026 hỗ trợ serial port 1-4 với metadata đầy đủ hơn).
📋 Giải thích tất cả các phương án
Dưới đây là phân tích từng lựa chọn một cách chi tiết, với lý do đúng/sai dựa trên best practice Google Cloud:
-
Create a new feature branch, and ask the build team to rebuild the image.
❌ Sai. Phương án này không investigate nguyên nhân gốc rễ mà chỉ "thử lại" mù quáng, có thể mất hàng giờ rebuild Packer và không giải quyết vấn đề (ví dụ: lỗi script provisioner trong Packer). Không hiệu quả cho troubleshoot, vi phạm nguyên tắc "root cause analysis" trong CI/CD. -
Shut down the deployed virtual machine, export the disk, and then mount the disk locally to access the boot logs.
❌ Sai. Việc shutdown VM và export disk (quagcloud compute disks export) rất tốn thời gian (30-60 phút+), phức tạp, và "mount locally" ám chỉ attach vào máy local (không khả thi trực tiếp vì disk GCP là cloud-based). Dễ gây downtime, không an toàn cho môi trường shared, và bỏ qua serial logs đơn giản hơn (serial port không yêu cầu export). -
Install Packer locally, build the Compute Engine image locally, and then run it in your personal Google Cloud project.
❌ Sai. Không reproduce chính xác môi trường CI/CD (local env khác biệt về credentials, network, Packer plugins). Tốn tài nguyên (build image mất 10-30 phút), rủi ro billing cá nhân, và vi phạm nguyên tắc "environment parity". Google khuyến nghị dùng serial logs thay vì local repro. -
Check Compute Engine OS logs using the serial port, and check the Cloud Logging logs to confirm access to the serial port.
✅ Đúng (như đã giải thích ở trên). Phương án tối ưu nhất, enable quagcloud compute instances add-metadatanếu cần, và query logs bằnggcloud logging read. Hoàn hảo cho collaboration với CI/CD team! 🚀