
시작하기 전에
- 실습에서는 정해진 기간 동안 Google Cloud 프로젝트와 리소스를 만듭니다.
- 실습에는 시간 제한이 있으며 일시중지 기능이 없습니다. 실습을 종료하면 처음부터 다시 시작해야 합니다.
- 화면 왼쪽 상단에서 실습 시작을 클릭하여 시작합니다.
Create a basic Node.js application from the Google Cloud Console
/ 25
Configure your CI/CD pipeline with Cloud Build and Google Cloud Deploy
/ 25
Automate continuous integration using a Cloud Build trigger
/ 25
Promote and approve releases
/ 25
In this exercise, you create a modern serverless continuous integration/continuous delivery (CI/CD) pipeline to automate application delivery to GKE and Anthos clusters.
The pipeline starts with a "hello world" Node.js code stored in Cloud Source Repositories in a private Git repository. Commits that are made to the master branch trigger a Cloud Build workflow, which builds a new container image, pushes it to Artifact Registry, and triggers Google Cloud Deploy as the CD part.
Google Cloud Deploy delivers the application to the dev cluster, which, after testing, allows you to promote it to a staging and production cluster. Additionally, you learn to implement approvals to ensure that code only reaches production when the right stakeholders approve the release.
In this lab, you learn how to:
In this task, you use Qwiklabs and perform initialization steps for your lab.
For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.
Sign in to Qwiklabs using an incognito window.
Note the lab's access time (for example, 1:15:00
), and make sure you can finish within that time.
There is no pause feature. You can restart if needed, but you have to start at the beginning.
When ready, click Start lab.
Note your lab credentials (Username and Password). You will use them to sign in to the Google Cloud Console.
Click Open Google Console.
Click Use another account and copy/paste credentials for this lab into the prompts.
If you use other credentials, you'll receive errors or incur charges.
Accept the terms and skip the recovery resource page.
After you complete the initial sign-in steps, the project dashboard appears.
Google Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud.
Google Cloud Shell provides command-line access to your Google Cloud resources.
In Cloud console, on the top right toolbar, click the Open Cloud Shell button.
Click Continue.
It takes a few moments to provision and connect to the environment. When you are connected, you are already authenticated, and the project is set to your PROJECT_ID. For example:
gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Example output:
Output:
Example output:
Enable the required Google Cloud APIs:
Export the current Qwiklabs project ID into a PROJECT_ID environmental variable:
Set the Zone environment variable:
Authenticate to the Artifact Registry:
Clone a copy of a hello world example into Cloud Shell, and change into the HelloWorldNodeJs folder that the clone operation creates:
You can explore the code in the Cloud Shell Editor.
Use the Docker CLI to build the code into a container and push it to Artifact Registry:
The docker build command looks in the specified path (.) for a Dockerfile. If
it finds one, it follows the instructions to build a Docker image (in this case
adding the specified tag -t
). docker push then uploads a copy of the image to
Artifact Registry.
In the Google Cloud Console, navigate to Artifact Registry and confirm that the image was created and uploaded as expected.
Click Check my progress to verify the objective.
In the previous task, you took code from a Git repository, used Docker to build an image, and pushed it to Artifact Registry. Cloud Build allows you to create workflows of build steps similar to the kind you executed manually. Google and the Cloud Build community have created several builders, each usable by name.
In this task, you create a cloudbuild.yaml
file to define the build workflow: build the image, push it to Artifact Registry, and finally push it to Google Cloud Deploy. From there, Google Cloud Deploy manages continuous delivery. You then test for correctness.
Create a cloudbuild.yaml
file, which executes the same steps you just performed
manually:
The file name cloudbuild.yaml
is the expected default, but you can give it a
custom name. At its most basic, the cloudbuild.yaml
file lays out the
steps the Cloud Build worker should complete. The file can then be manually
passed to Cloud Build or automated as part of a trigger.
Create a clouddeploy.yaml
file to specify the delivery pipeline containing
the target platforms where the helloworld
file should be delivered; in this
case, the three existing GKE clusters: dev-cluster, staging-cluster, and
prod-cluster:
Create the skaffold.yaml
file to specify the Kubernetes YAML files to be
deployed by Google Cloud Deploy:
Create the Kubernetes files to be deployed to the clusters:
Deploy the clouddeploy.yaml
file to Google Cloud Deploy to configure the release
pipeline:
In the Google Cloud Console, navigate to Cloud Deploy and confirm that the pipeline was created.
Click on helloworld-pipeline to open it and view the pipeline.
Use Cloud Build to execute the workflow:
In the Google Cloud Console, navigate to Cloud Deploy, open the pipeline you created earlier, and wait for the release to be deployed to dev-cluster.
In the Google Cloud Console, navigate to
Kubernetes Engine > Gateways, Services & Ingress, click on Services tab and locate the hello-world-demo
service, and click on the link with the public IP address to see the deployed application running
on dev-cluster.
Click Check my progress to verify the objective.
For this task, you use a very simplified development process. You commit changes to the Git repository local to Cloud Shell and push the changes to the remote repository. When changes are pushed to Cloud Source Repositories master branch, a Cloud Build trigger based on the cloudbuild.yaml file created earlier is executed, which builds the image, pushes it to Artifact Registry, and schedules a Google Cloud Deploy release.
In Cloud Shell, initialize and configure Git for use:
Stage the code for commit in the local Cloud Shell Git repository, and make the initial commit:
Create a new helloworld Git repository in your Cloud repository:
Git allows for the creation of remote team repositories for sharing code between developers.
In Cloud Shell, create a remote link to the Git
repository created in the previous step, and name it to-google
:
Push the code from your local Cloud Shell repository to the Google repository helloworld master branch:
In the Google Cloud Console, navigate to Source Repositories and investigate your new repo.
The code is written locally and stored in a central repository, the build steps
are defined in a cloudbuild.yaml
file, and the deployment steps are specified
in the clouddeploy.yaml
file. The last step is to create a trigger to put it
all together.
In the Google Cloud Console, navigate to Cloud Build > Triggers.
Click on the CREATE TRIGGER button.
Enter the name HelloWorldJS
.
Under Source, enter select the repository to be
helloworld (Cloud Source Repositories)
and the branch to match ^master$
.
Under Configuration, select Cloud Build configuration file
, and
enter /cloudbuild.yaml
as the Cloud Build configuration file location.
Under Service Account, select XXXXXXXXX-compute@developer.gserviceaccount.com
. Please note the warning, in a production setting, declare a dedicated service account with limited IAM Permissions.
Click on CREATE to create the trigger.
When the trigger is ready, to test the trigger's logic, click RUN. If a
window pops up to select a branch, enter master
and press RUN TRIGGER.
Navigate to Cloud Build > History and wait for the build workflow to complete.
Navigate to Cloud Deploy and confirm that the new pipeline has been triggered.
Return to Cloud Shell and edit the services code:
Make a change to the services returned message; for example, change World
to World 2
.
Stage and commit the change to your local developers Git repository, and then push the change to the repository:
Return to the Google Cloud Console and navigate to Cloud Build > History.
When the trigger is finished executing, go to Cloud Deploy and wait for the deployment to occur.
Re-load the application and confirm that the new message is displayed.
Click Check my progress to verify the objective.
You have been working out of dev-cluster, which is great for developing and testing new features of your application. However, after those features have been developed, you might want to expose them to an internal audience in a staging environment for further testing and eventually deploy them to a production environment.
In this task, you learn how to promote your application to other environments and use approvals for stakeholders to approve a release.
In the Google Cloud Console, navigate to Cloud Deploy and open your pipeline.
In the pipeline visualization area, click on the 3-dot menu in the dev target box. Notice the following actions:
To deploy your application to staging, click Promote release. Investigate the options in the pop-up window, and check the Manifest Diff tab to check the differences with the previous version.
Click Promote.
After the application is deployed, to see the deployed application running on staging-cluster, navigate to Kubernetes Engine > Gateways, Services & Ingress, click on Services tab.
Locate the hello-world-demo
service
and click on the link with the public IP address.
To promote the release from staging to production, return to
Cloud Deploy, open your pipeline, click Promote in the staging box, and
then in the dialog, click Promote again. Notice that this time the
promotion has been blocked by a review action that you specified earlier in the
clouddeploy.yaml
.
In the visualization area between staging and production, click Review.
After reviewing the changes, click Approve. Usually, approvals would be done by a different person or team.
Return to your Cloud Deploy pipeline visualization, and click on the release that is deployed to prod-cluster.
Click again on the rollout to open a details window and open the Render logs and Deployment logs. Here you can debug if there are any issues in the deployment. Notice that the actual deployment also runs on a Cloud Build runner.
After the rollout has finished, to see the deployed application running
on prod-cluster, navigate to Kubernetes Engine > Gateways, Services & Ingress, click on Services tab, locate to the hello-world-demo
service, and click on the link with the public IP address.
Click Check my progress to verify the objective.
You have used Cloud Source Repositories, Cloud Build, and Google Cloud Deploy to automate the application delivery to GKE and Anthos clusters. You also learned how to promote and approve releases to staging and production clusters.
When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
현재 이 콘텐츠를 이용할 수 없습니다
이용할 수 있게 되면 이메일로 알려드리겠습니다.
감사합니다
이용할 수 있게 되면 이메일로 알려드리겠습니다.
한 번에 실습 1개만 가능
모든 기존 실습을 종료하고 이 실습을 시작할지 확인하세요.