Quay lại bộ đề
Question #226 Topic 1
You are creating the CI/CD cycle for the code of the directed acyclic graphs (DAGs) running in Cloud Composer. Your team has two Cloud Composer instances: one instance for development and another instance for production. Your team is using a Git repository to maintain and develop the code of the DAGs. You want to deploy the DAGs automatically to Cloud Composer when a certain tag is pushed to the Git repository. What should you do?
Bạn đang tạo quy trình CI/CD cho mã nguồn của các đồ thị có hướng không chu trình (DAG) chạy trong Cloud Composer. Nhóm của bạn có hai thực thể (instance) Cloud Composer: một thực thể cho môi trường phát triển (development) và một thực thể cho môi trường sản xuất (production). Nhóm của bạn đang sử dụng kho lưu trữ Git để duy trì và phát triển mã nguồn của các DAG. Bạn muốn tự động triển khai các DAG lên Cloud Composer khi một thẻ (tag) nhất định được đẩy (push) lên kho lưu trữ Git. Bạn nên làm gì?
A
1. Use Cloud Build to copy the code of the DAG to the Cloud Storage bucket of the development instance for DAG testing.2. If the tests pass, use Cloud Build to copy the code to the bucket of the production instance.
1. Sử dụng Cloud Build để sao chép mã nguồn của DAG vào bucket Cloud Storage của thực thể phát triển để chạy thử nghiệm DAG.
2. Nếu các bài kiểm thử vượt qua, sử dụng Cloud Build để sao chép mã nguồn vào bucket của thực thể sản xuất.
B
1. Use Cloud Build to build a container with the code of the DAG and the KubernetesPodOperator to deploy the code to the Google Kubernetes Engine (GKE) cluster of the development instance for testing.2. If the tests pass, use the KubernetesPodOperator to deploy the container to the GKE cluster of the production instance.
1. Sử dụng Cloud Build để xây dựng một container chứa mã nguồn của DAG và sử dụng KubernetesPodOperator để triển khai mã nguồn đó lên cụm Google Kubernetes Engine (GKE) của thực thể phát triển để thử nghiệm.
2. Nếu các bài kiểm thử vượt qua, sử dụng KubernetesPodOperator để triển khai container lên cụm GKE của thực thể sản xuất.
C
1. Use Cloud Build to build a container and the KubernetesPodOperator to deploy the code of the DAG to the Google Kubernetes Engine (GKE) cluster of the development instance for testing.2. If the tests pass, copy the code to the Cloud Storage bucket of the production instance.
1. Sử dụng Cloud Build để xây dựng một container và sử dụng KubernetesPodOperator để triển khai mã nguồn của DAG lên cụm Google Kubernetes Engine (GKE) của thực thể phát triển để thử nghiệm.
2. Nếu các bài kiểm thử vượt qua, sao chép mã nguồn vào bucket Cloud Storage của thực thể sản xuất.
D
1. Use Cloud Build to copy the code of the DAG to the Cloud Storage bucket of the development instance for DAG testing.2. If the tests pass, use Cloud Build to build a container with the code of the DAG and the KubernetesPodOperator to deploy the container to the Google Kubernetes Engine (GKE) cluster of the production instance.
1. Sử dụng Cloud Build để sao chép mã nguồn của DAG vào bucket Cloud Storage của thực thể phát triển để chạy thử nghiệm DAG.
2. Nếu các bài kiểm thử vượt qua, sử dụng Cloud Build để xây dựng một container chứa mã nguồn của DAG và sử dụng KubernetesPodOperator để triển khai container đó lên cụm Google Kubernetes Engine (GKE) của thực thể sản xuất.
Giải thích & Tài liệu tham khảo
Cloud Composer lưu trữ mã nguồn của các DAG bên trong thư mục dags/ của một bucket Cloud Storage (GCS bucket) liên kết với môi trường đó. Do đó, việc triển khai DAG chỉ đơn giản là sao chép các tệp tin Python vào thư mục này.
- Quy trình CI/CD chuẩn và đơn giản nhất (Lựa chọn A) là: Sử dụng Cloud Build để tự động hóa việc sao chép các tệp DAG vào GCS bucket của môi trường phát triển (development instance) để chạy kiểm thử tự động. Nếu quá trình kiểm thử thành công, Cloud Build sẽ tiếp tục sao chép các tệp mã nguồn đó sang GCS bucket của môi trường sản xuất (production instance).
Các lựa chọn khác không chính xác:
- B, C, D lạm dụng
KubernetesPodOperatorđể đóng gói DAG vào một container Docker. Việc này làm tăng độ phức tạp của hệ thống một cách không cần thiết, vì Composer đã tự động đồng bộ các tệp tin trong GCS bucket vào các worker của Airflow mà không cần đóng gói lại mã nguồn DAG.
(Đáp án được gợi ý bởi AI)