Pipeline CI/CD untuk mengembangkan dan mengirimkan aplikasi dalam container
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Last reviewed 2022-11-18 UTC
Dokumen ini menjelaskan serangkaian alat Google Cloud terintegrasi untuk menyiapkan sistem pengembangan, continuous integration (CI), dan continuous delivery (CD) yang dapat Anda gunakan untuk mengembangkan dan men-deploy aplikasi ke Google Kubernetes Engine (GKE).
Dokumen arsitektur referensi ini ditujukan untuk developer software dan operator. Hal ini mengasumsikan bahwa Anda dapat menjalankan perintah gcloud diGoogle Cloud dan men-deploy container aplikasi ke GKE.
Arsitektur
Diagram berikut menunjukkan referensi yang digunakan dalam arsitektur ini:
Arsitektur ini mencakup komponen berikut:
Cloud Code sebagai ruang kerja pengembangan.
Sebagai bagian dari ruang kerja ini, Anda dapat melihat perubahan dalam cluster
pengembangan, yang berjalan di
minikube.
Anda menjalankan Cloud Code dan cluster minikube di Cloud Shell.
Cloud Shell adalah lingkungan pengembangan online yang dapat diakses dari browser Anda. Platform ini memiliki resource komputasi, memori, lingkungan pengembangan terintegrasi,
(IDE), dan juga memiliki Cloud Code terinstal.
Cloud Build untuk membangun dan menguji aplikasi—bagian "CI" pada pipeline
Bagian pipeline ini mencakup tindakan berikut:
Cloud Build memantau perubahan pada repositori sumber, menggunakan pemicu Cloud Build.
Saat perubahan di-commit ke cabang utama, pemicu Cloud Build akan melakukan hal berikut:
Membangun ulang container aplikasi.
Menempatkan artefak build di bucket Cloud Storage.
Menempatkan container aplikasi di Artifact Registry.
Menjalankan pengujian pada container.
Memanggil Cloud Deploy untuk men-deploy container ke lingkungan staging. Dalam contoh ini, lingkungan staging adalah cluster Google Kubernetes Engine.
Jika build dan pengujian berhasil, Anda dapat menggunakan Cloud Deploy untuk mempromosikan container dari staging ke produksi.
Cloud Deploy untuk mengelola deployment—bagian "CD" dari pipeline. Di bagian pipeline ini, Cloud Deploy melakukan hal-hal berikut:
Membuat bucket Cloud Storage serta menyimpan sumber rendering Skaffold dan manifes yang dirender di bucket tersebut.
Menghasilkan rilis baru
untuk setiap perubahan kode sumber.
Men-deploy aplikasi ke lingkungan produksi. Untuk deployment ke produksi, operator (atau orang lain yang ditunjuk) akan menyetujui deployment secara manual. Dalam arsitektur ini, lingkungan produksi adalah cluster Google Kubernetes Engine.
Dalam arsitektur ini, konfigurasi dibagikan bersama oleh lingkungan pengembangan, staging, dan produksi melalui Skaffold, yakni alat command line yang memfasilitasi pengembangan berkelanjutan untuk Kubernetes- aplikasi native.
Google Cloud menyimpan kode sumber aplikasi di GitHub.
Arsitektur ini menggunakan produk Google Cloud untuk sebagian besar komponen sistem, dengan Skaffold yang mengaktifkan integrasi sistem. Karena Skaffold bersifat open source, Anda dapat menggunakan prinsip-prinsip ini untuk membuat sistem serupa menggunakan kombinasi komponen Google Cloud, internal, dan pihak ketiga.
Modularitas solusi ini berarti bahwa Anda dapat mengadopsinya secara bertahap sebagai bagian dari pipeline pengembangan dan deployment Anda.
Kasus penggunaan
Berikut adalah fitur utama dari sistem terintegrasi ini:
Kembangkan dan deploy lebih cepat.
Loop pengembangan sangat efisien karena Anda dapat memvalidasi perubahan di ruang kerja developer. Deployment berjalan cepat karena sistem CI/CD otomatis dan peningkatan paritas di seluruh lingkungan memungkinkan Anda mendeteksi lebih banyak masalah saat men-deploy perubahan ke produksi.
Manfaat dari peningkatan paritas dalam pengembangan, staging, dan produksi.
Komponen sistem ini menggunakan serangkaian umum alat Google Cloud .
Menggunakan kembali konfigurasi di berbagai lingkungan.yang berbeda.
Penggunaan ulang ini dilakukan dengan Skaffold,
yang memungkinkan format konfigurasi umum untuk lingkungan yang berbeda. Hal ini
juga memungkinkan developer dan operator mengupdate dan menggunakan konfigurasi yang sama.
Terapkan tata kelola di awal alur kerja.
Sistem ini menerapkan pengujian validasi untuk tata kelola pada produksi serta dalam
sistem CI dan lingkungan pengembangan. Menerapkan tata kelola di lingkungan pengembangan memungkinkan masalah ditemukan dan diperbaiki lebih awal.
Izinkan alat yang tidak sesuai mengelola pengiriman software Anda.
Continuous delivery terkelola sepenuhnya, sehingga memisahkan tahapan pipeline
CD dari detail rendering dan deployment.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2022-11-18 UTC."],[[["\u003cp\u003eThis architecture uses Google Cloud tools (Cloud Code, Cloud Build, Cloud Deploy) to set up a continuous integration and continuous delivery (CI/CD) system for developing and deploying applications to Google Kubernetes Engine (GKE).\u003c/p\u003e\n"],["\u003cp\u003eCloud Code serves as the development workspace, running in Cloud Shell, where developers can see changes in the minikube development cluster.\u003c/p\u003e\n"],["\u003cp\u003eCloud Build automates building and testing, using triggers to monitor source code changes, rebuild the application container, and run tests before deploying to the staging environment.\u003c/p\u003e\n"],["\u003cp\u003eCloud Deploy manages the continuous delivery pipeline, registering delivery pipelines and targets, storing Skaffold rendering source and manifests, and deploying the application to production with manual approval.\u003c/p\u003e\n"],["\u003cp\u003eSkaffold facilitates shared configuration across development, staging, and production environments, enabling a common configuration format and allowing for the reuse of configurations.\u003c/p\u003e\n"]]],[],null,["# CI/CD pipeline for developing and delivering containerized apps\n\nThis document describes an integrated set of Google Cloud tools\nto set up a system for development, for continuous integration (CI), and\nfor continuous delivery (CD) that you can use to develop and deploy applications to\n[Google Kubernetes Engine (GKE)](/kubernetes-engine).\nThis reference architecture document is intended for both software developers\nand operators. It assumes that you're familiar with running `gcloud` commands on\nGoogle Cloud and with deploying application containers to\nGKE.\n\nArchitecture\n------------\n\nThe following diagram shows the resources that are used in this architecture:\n\nThis architecture includes the following components:\n\n1. **Cloud Code** as a development workspace. As part of this workspace, you can see changes in the development cluster, which runs on [minikube](https://minikube.sigs.k8s.io/docs/). You run Cloud Code and the minikube cluster in [Cloud Shell](/shell). Cloud Shell is an online development environment accessible from your browser. It has compute resources, memory, an integrated development environment, (IDE), and it also has Cloud Code installed.\n2. **Cloud Build** to build and test the application---the \"CI\"\n part of the pipeline\n\n This part of the pipeline includes the following actions:\n - Cloud Build monitors changes to the source repository, using a Cloud Build trigger.\n - When a change is committed into the main branch, the Cloud Build trigger does the following:\n - Rebuilds the application container.\n - Places build artifacts in a Cloud Storage bucket.\n - Places the application container in Artifact Registry.\n - Runs tests on the container.\n - Calls Cloud Deploy to deploy the container to the staging environment. In this example, the staging environment is a Google Kubernetes Engine cluster.\n - If the build and tests are successful, you can then use Cloud Deploy to promote the container from staging to production.\n3. **Cloud Deploy** to manage the deployment---the \"CD\" part of the\n pipeline. In this part of the pipeline, Cloud Deploy does the\n following:\n\n - Registers a [delivery pipeline](/deploy/docs/terminology#delivery_pipeline) and [targets](/deploy/docs/terminology#target). The targets represent the staging and production clusters.\n - Creates a Cloud Storage bucket and stores the Skaffold rendering source and rendered manifests in that bucket.\n - Generates a new [release](/deploy/docs/terminology#release) for each source code change.\n - Deploys the application to the production environment. For this deployment to production, an operator (or other designated person) manually approves the deployment. In this architecture, the production environment is a Google Kubernetes Engine cluster.\n\nIn this architecture, configuration is shared among the development, staging,\nand production environments through\n[Skaffold](https://skaffold.dev/),\na command-line tool that facilitates continuous development\nfor Kubernetes-native applications.\n\nGoogle Cloud stores the application's source code in GitHub.\n\nThis architecture uses Google Cloud products for most of the components of\nthe system, with Skaffold enabling the integration of the system. Because\nSkaffold is open source, you can use these principles to create a similar system\nusing a combination of Google Cloud, in-house, and third-party components.\nThe modularity of this solution means that you can adopt it incrementally\nas part of your development and deployment pipeline.\n\nUse cases\n---------\n\nThe following are the key features of this integrated system:\n\n- **Develop and deploy faster**.\n\n The development loop is efficient because you can validate\n changes in the developer workspace. Deployment is fast because the\n automated CI/CD system and increased parity across the environments allow you\n to detect more issues when you deploy changes to production.\n- **Benefit from increased parity** across development, staging, and production.\n\n The components of this system use a common set of Google Cloud tools.\n- **Reuse configurations** across the different environments.\n\n This reuse is done with [Skaffold](https://skaffold.dev/),\n which allows a common configuration format for the different environments. It\n also allows developers and operators to update and use the same configuration.\n- **Apply governance** early in the workflow.\n\n This system applies validation tests for governance at production and in the\n CI system and development environment. Applying governance in the development\n environment allows problems to be found and fixed earlier.\n- Let **opinionated tooling** manage your software delivery.\n\n Continuous delivery is fully managed, separating the stages of your CD\n pipeline from the details of rendering and deploying.\n\nDeployment\n----------\n\nTo deploy this architecture, see\n[Develop and deploy containerized apps using a CI/CD pipeline](/architecture/app-development-and-delivery-with-cloud-code-gcb-cd-and-gke/deployment).\n\nWhat's next\n-----------\n\n- To learn how to deploy into a private GKE instance, see [Deploying to a private cluster on a Virtual Private Cloud network](/deploy/docs/execution-environment#deploying_to_a_private_cluster_on_a_network).\n- For information about how to implement, improve, and measure deployment automation, see [Deployment automation](https://dora.dev/devops-capabilities/technical/deployment-automation/)."]]