Overview
App Engine allows developers to focus on doing what they do best, writing code. The App Engine standard environment is based on container instances running on Google's infrastructure. Containers are preconfigured with one of several available runtimes, and each runtime also includes libraries that support App Engine Standard APIs. For many applications, the standard environment runtimes and libraries might be all you need.
App Engine offers you a choice between two Go language environments. Both environments have the same code-centric developer workflow, scale quickly and efficiently to handle increasing demand, and enable you to use Google’s proven serving technology to build your web, mobile and IoT applications quickly and with minimal operational overhead. While the two environments have a lot in common, they differ in a few important ways.
The App Engine standard environment makes it easy to build and deploy an application that runs reliably under heavy load and with large amounts of data. Your application runs within its own secure, reliable environment that is independent of the hardware, operating system, or physical location of the server. It supports Go 1.11.
The App Engine flexible environment is based on Compute Engine and automatically scales your app up and down while balancing the load.
- Download an application
- Test the application
- Deploy the application
student_04_e3f1df1e0d22@cloudshell:~ (qwiklabs-gcp-00-3ab6af32c4f1)$ gcloud config set compute/region us-east4
Updated property [compute/region].
Task 2. Download the Hello World app
There is a simple Hello World app for Go that you can use to quickly get a feel for deploying an app to Google Cloud. Follow these steps to download Hello World to your Google Cloud instance.
student_04_e3f1df1e0d22@cloudshell:~ (qwiklabs-gcp-00-3ab6af32c4f1)$ git clone https://github.com/GoogleCloudPlatform/golang-samples.git
Cloning into 'golang-samples'...
remote: Enumerating objects: 27363, done.
remote: Counting objects: 100% (1683/1683), done.
student_04_e3f1df1e0d22@cloudshell:~ (qwiklabs-gcp-00-3ab6af32c4f1)$ cd golang-samples/appengine/go11x/helloworld/
student_04_e3f1df1e0d22@cloudshell:~/golang-samples/appengine/go11x/helloworld (qwiklabs-gcp-00-3ab6af32c4f1)$ ls -l
total 16
-rw-r--r-- 1 student_04_e3f1df1e0d22 student_04_e3f1df1e0d22 591 Aug 5 19:57 app.yaml
-rw-r--r-- 1 student_04_e3f1df1e0d22 student_04_e3f1df1e0d22 27 Aug 5 19:57 go.mod
-rw-r--r-- 1 student_04_e3f1df1e0d22 student_04_e3f1df1e0d22 0 Aug 5 19:57 go.sum
-rw-r--r-- 1 student_04_e3f1df1e0d22 student_04_e3f1df1e0d22 1403 Aug 5 19:57 helloworld.go
-rw-r--r-- 1 student_04_e3f1df1e0d22 student_04_e3f1df1e0d22 1580 Aug 5 19:57 helloworld_test.go
Task 3. Deploy your app
To deploy your app to App Engine, run the following command from within the root directory of your application where the app.yaml file is located:
student_04_e3f1df1e0d22@cloudshell:~/golang-samples/appengine/go11x/helloworld (qwiklabs-gcp-00-3ab6af32c4f1)$ sudo apt-get install google-cloud-sdk-app-engine-go
gcloud app deploy
********************************************************************************
You are running apt-get inside of Cloud Shell. Note that your Cloud Shell
machine is ephemeral and no system-wide change will persist beyond session end.
To suppress this warning, create an empty ~/.cloudshell/no-apt-get-warning file.
The command will automatically proceed in 5 seconds or on any key.
Visit https://cloud.google.com/shell/help for more information.
********************************************************************************
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
google-cloud-sdk-app-engine-go is already the newest version (441.0.0-0).
The following package was automatically installed and is no longer required:
libpcre2-posix2
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.
You are creating an app for project [qwiklabs-gcp-00-3ab6af32c4f1].
WARNING: Creating an App Engine application for a project is irreversible and the region
cannot be changed. More information about regions is at
<https://cloud.google.com/appengine/docs/locations>.
Please choose the region where you want your App Engine application located:
[1] asia-east1 (supports standard and flexible)
[2] asia-northeast1 (supports standard and flexible and search_api)
[3] asia-south1 (supports standard and flexible and search_api)
[4] asia-southeast1 (supports standard and flexible)
[5] australia-southeast1 (supports standard and flexible and search_api)
[6] europe-central2 (supports standard and flexible)
[7] europe-west (supports standard and flexible and search_api)
[8] europe-west2 (supports standard and flexible and search_api)
[9] europe-west3 (supports standard and flexible and search_api)
[10] us-central (supports standard and flexible and search_api)
[11] us-east1 (supports standard and flexible and search_api)
[12] us-east4 (supports standard and flexible and search_api)
[13] us-west1 (supports standard and flexible)
[14] us-west2 (supports standard and flexible and search_api)
[15] us-west3 (supports standard and flexible and search_api)
[16] us-west4 (supports standard and flexible and search_api)
[17] cancel
Please enter your numeric choice: 12
Creating App Engine application in project [qwiklabs-gcp-00-3ab6af32c4f1] and region [us-east4]....done.
Services to deploy:
descriptor: [/home/student_04_e3f1df1e0d22/golang-samples/appengine/go11x/helloworld/app.yaml]
source: [/home/student_04_e3f1df1e0d22/golang-samples/appengine/go11x/helloworld]
target project: [qwiklabs-gcp-00-3ab6af32c4f1]
target service: [default]
target version: [20230805t195851]
target url: [https://qwiklabs-gcp-00-3ab6af32c4f1.uk.r.appspot.com]
target service account: [qwiklabs-gcp-00-3ab6af32c4f1@appspot.gserviceaccount.com]
Do you want to continue (Y/n)? Y
Beginning deployment of service [default]...
Created .gcloudignore file. See `gcloud topic gcloudignore` for details.
Uploading 6 files to Google Cloud Storage
17%
33%
50%
67%
83%
100%
100%
File upload done.
Updating service [default]...done.
Setting traffic split for service [default]...done.
Deployed service [default] to [https://qwiklabs-gcp-00-3ab6af32c4f1.uk.r.appspot.com]
You can stream logs from the command line by running:
$ gcloud app logs tail -s default
To view your application in the web browser run:
$ gcloud app browse
student_04_e3f1df1e0d22@cloudshell:~/golang-samples/appengine/go11x/helloworld (qwiklabs-gcp-00-3ab6af32c4f1)$ gcloud app browse
Did not detect your browser. Go to this link to view your app:
https://qwiklabs-gcp-00-3ab6af32c4f1.uk.r.appspot.com
student_04_e3f1df1e0d22@cloudshell:~/golang-samples/appengine/go11x/helloworld (qwiklabs-gcp-00-3ab6af32c4f1)$
No comments:
Post a Comment