{"id":15451,"date":"2023-08-14T09:05:47","date_gmt":"2023-08-14T02:05:47","guid":{"rendered":"https:\/\/gcloudvn.com\/?p=15451"},"modified":"2024-05-31T14:39:04","modified_gmt":"2024-05-31T07:39:04","slug":"cach-trien-khai-api-service-tren-google-compute-engine","status":"publish","type":"post","link":"https:\/\/gcloudvn.com\/en\/kienthuc\/cach-trien-khai-api-service-tren-google-compute-engine\/","title":{"rendered":"How to implement API service on Google Compute Engine"},"content":{"rendered":"<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">In this article, Gimasys will show you how to <\/span><strong>Deploy API service<\/strong><span style=\"font-weight: 400;\"><strong> basic on Google Cloud via\u00a0 <a href=\"https:\/\/gcloudvn.com\/en\/compute-engine\/\">Compute Engine<\/a><\/strong>. Detail<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Hosting API service running using Docker on Google Cloud server\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Setup domain, SSL for API service<\/span><\/li>\n<\/ul>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/cach-trien-khai-api-service-tren-google-compute-engine\/#Cac_khai_niem_can_nam_ro\" >Concepts that need to be understood<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/cach-trien-khai-api-service-tren-google-compute-engine\/#API_service\" >API services<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/cach-trien-khai-api-service-tren-google-compute-engine\/#Compute_Engine\" >Compute Engine<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/cach-trien-khai-api-service-tren-google-compute-engine\/#Nhung_diem_can_luu_y\" >Points to note<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/cach-trien-khai-api-service-tren-google-compute-engine\/#Huong_dan_chi_tiet_cach_trien_khai_API_service_tren_Google_Compute_Engine\" >Detailed instructions on how to deploy API service on Google Compute Engine<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/cach-trien-khai-api-service-tren-google-compute-engine\/#Buoc_1_Cai_dat_Git\" >Step 1: Install Git<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/cach-trien-khai-api-service-tren-google-compute-engine\/#Buoc_2_Them_SSH_Key_va_Clone_Project\" >Step 2: Add SSH Key and Clone Project<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/cach-trien-khai-api-service-tren-google-compute-engine\/#Buoc_3_Cai_dat_Docker_Compose\" >Step 3: Install Docker Compose<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/cach-trien-khai-api-service-tren-google-compute-engine\/#Buoc_4_Xay_dung_va_chay_Docker_Compose\" >Step 4: Build and Run Docker Compose<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/cach-trien-khai-api-service-tren-google-compute-engine\/#Buoc_5_Mo_port_ung_dung_tren_VMware\" >Step 5: Open the application port on VMware<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/cach-trien-khai-api-service-tren-google-compute-engine\/#Buoc_6_Tao_nhom_instance\" >Step 6: Create an instance pool<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/cach-trien-khai-api-service-tren-google-compute-engine\/#Buoc_7_Tuy_chinh_Load_balancing_cho_vm\" >Step 7: Customize Load balancing for vm<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/cach-trien-khai-api-service-tren-google-compute-engine\/#Buoc_8_Tuy_chinh_domain_va_ssl\" >Step 8: Customize domain and ssl<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/gcloudvn.com\/en\/kienthuc\/cach-trien-khai-api-service-tren-google-compute-engine\/#Tong_ket\" >In conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Cac_khai_niem_can_nam_ro\"><\/span><b>Concepts that need to be understood<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"API_service\"><\/span><b>API services<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">API (Application Programming Interface) services are interfaces that provide a program that describes how to interact with the system to access and\/or change the data in it.<\/span><\/p>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Compute_Engine\"><\/span><b>Compute Engine<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Google Compute Engine is an infrastructure service (IaaS - Infrastructure As A Service) of <a href=\"https:\/\/gcloudvn.com\/en\/google-cloud-platform\/\">GCP<\/a>, which allows you to create flexible and cost-effective virtual machines to run websites, applications, etc. for organizations and businesses.\u00a0<\/span><\/p>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Nhung_diem_can_luu_y\"><\/span><b>Points to note<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">API service is always available on github\/gitlab<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">You need Full permission on GCP to enable necessary services<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Domain, DNS service (Gimasys uses Cloudflare in this case)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Basic knowledge of command line is required<\/span><\/li>\n<\/ul>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Huong_dan_chi_tiet_cach_trien_khai_API_service_tren_Google_Compute_Engine\"><\/span><b>Detailed instructions on how to deploy API service on Google Compute Engine<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Buoc_1_Cai_dat_Git\"><\/span><b>Step 1: Install Git<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul style=\"text-align: justify;\">\n<li><span style=\"font-weight: 400;\">Run command<\/span>\n<ul>\n<li>sudo apt update<\/li>\n<li>sudo apt install git<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li><span style=\"font-weight: 400;\">Check if Git has been successfully installed<\/span>\n<ul>\n<li>git \u2013version<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Buoc_2_Them_SSH_Key_va_Clone_Project\"><\/span><b>Step 2: Add SSH Key and Clone Project<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul style=\"text-align: justify;\">\n<li><span style=\"font-weight: 400;\">Select the folder and start cloning the project from the pre-existing Github\/Gitlab <\/span><\/li>\n<li>Assign read\/write\/execute permission to the directory containing the source code with the command:\n<ul>\n<li>sudo chmod -R 777 .<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Buoc_3_Cai_dat_Docker_Compose\"><\/span><b>Step 3: Install Docker Compose<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">First, we will need to install Docker Compose following these steps:<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Install Docker Compose<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\">sudo curl -L https:\/\/github.com\/docker\/compose\/releases\/download\/v2.5.0\/docker-compose-`uname -s`-`uname -m` -o \/usr\/local\/bin\/docker- compose<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Decentralize Docker Compose<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\">sudo chmod +x \/usr\/local\/bin\/docker-compose<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Check Docker Compose permissions<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\">docker-compose version<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Buoc_4_Xay_dung_va_chay_Docker_Compose\"><\/span><b>Step 4: Build and Run Docker Compose<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Initialization:<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\">docker-compose up \u2013build<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">If there is an error like the code below:<\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15478\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_1.jpg\" alt=\"How to deploy API service on Google Compute Engine 1\" width=\"600\" height=\"84\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_1.jpg 567w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_1-18x3.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/>Please handle by granting read &amp; write permission to user\/non-root-process on docker.sock according to the code:<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\">sudo chmod 666 \/var\/run\/docker.sock<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Buoc_5_Mo_port_ung_dung_tren_VMware\"><\/span><b>Step 5: Open the application port on VMware<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">When creating an instance, users should choose one of the two options below to let HTTP\/HTTPS traffic from outside the internet be accessible through the firewall:<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15477 size-full\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_2.jpg\" alt=\"How to deploy API service on Google Compute Engine 2\" width=\"600\" height=\"165\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_2.jpg 600w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_2-18x5.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/>Since in step 4, we have selected port 9000 for the application port, now we need to add the following steps to open the application port:<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Open VPC Network and select Firewall\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Select CREATE FIREWALL RULE<\/span><span style=\"font-weight: 400;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15476 size-full\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_3.jpg\" alt=\"How to implement API service on Google Compute Engine 3\" width=\"600\" height=\"256\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_3.jpg 600w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_3-18x8.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/span><\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Enter the rule name field, in the target section click All instances in the network\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Source IPv4 input ranges: 0.0.0.0\/0<\/span><span style=\"font-weight: 400;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15475 size-full\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_4.jpg\" alt=\"How to implement API service on Google Compute Engine 4\" width=\"600\" height=\"212\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_4.jpg 600w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_4-18x6.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/span><\/li>\n<li><span style=\"font-weight: 400;\">Select TCP in the Protocols and ports option, then enter the port of the application, here Gimasys enter range 7000-9000<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15474\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_5.jpg\" alt=\"How to deploy API service on Google Compute Engine 5\" width=\"600\" height=\"208\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_5.jpg 599w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_5-18x6.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Click Create\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Go to VMware, open the port corresponding to the External IPs to check<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><b><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15473 size-full\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_6.jpg\" alt=\"How to implement API service on Google Compute Engine 6\" width=\"600\" height=\"171\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_6.jpg 600w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_6-18x5.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/b><\/p>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Buoc_6_Tao_nhom_instance\"><\/span><b>Step 6: Create an instance pool<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">First, we need to create instance group Before customizing load balancing for instance. Select Compute Engine &gt; Instance groups &gt; CREATE INSTANCE GROUP:<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15472 size-full\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_7.jpg\" alt=\"How to implement API service on Google Compute Engine 7\" width=\"600\" height=\"313\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_7.jpg 600w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_7-18x9.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Fill in the necessary information to install the instance group, in the Port mapping section, we need to enter the correct port on which the application is running:<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15471\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_8.jpg\" alt=\"How to deploy API service on Google Compute Engine 8\" width=\"600\" height=\"347\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_8.jpg 601w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_8-18x10.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Click Create<\/span><\/li>\n<\/ul>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Buoc_7_Tuy_chinh_Load_balancing_cho_vm\"><\/span><b>Step 7: Customize Load balancing for vm<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Click Network services &gt; Load balancing\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">In the HTTP(S) Load Balancing section, click Start Configuration\u00a0<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15470 size-full\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_9.jpg\" alt=\"How to deploy API service on Google Compute Engine 9\" width=\"600\" height=\"310\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_9.jpg 600w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_9-18x9.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Select configuration as picture<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15469\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_10.jpg\" alt=\"How to deploy API service on Google Compute Engine 10\" width=\"400\" height=\"367\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_10.jpg 492w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_10-13x12.jpg 13w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Enter information for Load balancer config<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15468\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_11.jpg\" alt=\"How to implement API service on Google Compute Engine 11\" width=\"400\" height=\"449\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_11.jpg 406w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_11-11x12.jpg 11w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Enter information for Backend Configuration<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15467\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_12.jpg\" alt=\"How to implement API service on Google Compute Engine 12\" width=\"600\" height=\"443\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_12.jpg 524w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_12-16x12.jpg 16w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">In the health check menu, select CREATE A HEALTH CHECK, to check if your app is still working:<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15466\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_13.jpg\" alt=\"How to implement API service on Google Compute Engine 13\" width=\"400\" height=\"666\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_13.jpg 409w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_13-7x12.jpg 7w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15465 size-full\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_14.jpg\" alt=\"\" width=\"600\" height=\"203\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_14.jpg 600w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_14-18x6.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Fill in the information about the request path, port (note: port is entered according to the running application). The HTTP response code of this path is 200. Click save to save the configuration<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15464\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_15.jpg\" alt=\"How to implement API service on Google Compute Engine14\" width=\"400\" height=\"573\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_15.jpg 362w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_15-8x12.jpg 8w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Enter a name for Load balancing Config, click create. When finished, in the load balancing config menu screen, a newly initialized instance will appear.<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15463\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_16.jpg\" alt=\"How to deploy API service on Google Compute Engine 15\" width=\"600\" height=\"267\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_16.jpg 601w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_16-18x8.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">See IP load balancing in column IP:Port<\/span><\/li>\n<\/ul>\n<h3 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Buoc_8_Tuy_chinh_domain_va_ssl\"><\/span><b>Step 8: Customize domain and ssl<\/b><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">When you have a domain on Cloudflare and need to assign it to the API service. We need to follow these steps:<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">In the Cloudflare Menu, SSL\/TLS tab, click create Client Certificates &gt; Create Certificate<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15461 size-full\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_17.jpg\" alt=\"C\u00e1ch tri\u1ec3n khai API service tr\u00ean Google Compute Engine 16\" width=\"600\" height=\"315\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_17.jpg 600w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_17-18x9.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Click Create<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15460 size-full\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_18.jpg\" alt=\"How to deploy API service on Google Compute Engine 17\" width=\"600\" height=\"453\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_18.jpg 600w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_18-16x12.jpg 16w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Save 2 codes Certificate and Private Key<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15459\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_19.jpg\" alt=\"How to deploy API service on Google Compute Engine 18\" width=\"600\" height=\"459\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_19.jpg 497w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_19-16x12.jpg 16w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Open overview tab, click Full for SSL\/TLS encryption mode:<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15458\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_20.jpg\" alt=\"How to implement API service on Google Compute Engine 19\" width=\"600\" height=\"236\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_20.jpg 902w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_20-768x302.jpg 768w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_20-18x7.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Return to the load balancing config menu, click edit config, the information will be displayed, click ADD FRONTEND IP AND PORT to add customizations for the https protocol:<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15457\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_21.jpg\" alt=\"How to deploy API service on Google Compute Engine 20\" width=\"600\" height=\"234\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_21.jpg 590w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_21-18x7.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">In the Certificate field, select CREATE A NEW CERTIFICATE, enter the Certificate and Private Key information according to what was generated from Cloudflare\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Click Create\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Click Done &gt; Update to complete customization<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15456\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_22.jpg\" alt=\"How to implement API service on Google Compute Engine 21\" width=\"600\" height=\"246\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_22.jpg 601w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_22-18x7.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Go to the details of the load balancing config, get the IP address of the HTTPS protocol just created, note that only copy the IP<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15455 size-full\" src=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_23.jpg\" alt=\"How to deploy API service on Google Compute Engine 22\" width=\"600\" height=\"191\" srcset=\"https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_23.jpg 600w, https:\/\/gcloudvn.com\/wp-content\/uploads\/2023\/08\/trien_khai_api_23-18x6.jpg 18w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Back to Cloudflare, in the DNS\/records menu, click Add record and add the following steps:\u00a0<\/span>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Type: A\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"2\"><span style=\"font-weight: 400;\">Name: @, www or your subdomain. If your domain is 123.com, you can create a subdomain like abc.123.com\u00a0<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Click Save<\/span><\/li>\n<\/ul>\n<h2 style=\"text-align: justify;\"><span class=\"ez-toc-section\" id=\"Tong_ket\"><\/span><b>In conclusion<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">In this article, Gimasys has shared with you how to <strong>Deploying basic Api service on GCP through Google Compute Engine<\/strong>. We can double check by accessing domain\/sub domain from browser<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Gimasys - Google&#039;s Premier Partner in Vietnam is a provider and consultant on the structure and design of the optimal Cloud solution for you. For technical support, you can contact Gimasys \u2013 Premier Partner of Google in Vietnam at the following information:<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Hotline: <\/b><span style=\"font-weight: 400;\">0974 417 099 (HCM) | 0987 682 505 (HN)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Email: <\/b><span style=\"font-weight: 400;\">gcp@gimasys.com<\/span><\/li>\n<\/ul>\n<p style=\"text-align: right;\"><b>Source: Gimasys<\/b><\/p>","protected":false},"excerpt":{"rendered":"<p>In this article, Gimasys will guide you how to deploy basic Api services on Google Cloud through Compute Engine. Specifically, Hosting API service runs by Docker on Cloud server Google Setup domain,...<\/p>","protected":false},"author":2,"featured_media":15454,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1,135],"tags":[],"class_list":["post-15451","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-kienthuc","category-google-cloud-platform","entry","has-media"],"_links":{"self":[{"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/posts\/15451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/comments?post=15451"}],"version-history":[{"count":0,"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/posts\/15451\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/media\/15454"}],"wp:attachment":[{"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/media?parent=15451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/categories?post=15451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gcloudvn.com\/en\/wp-json\/wp\/v2\/tags?post=15451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}