Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- arrow_back
- Console and Cloud Shell
- Toggle Lab Panel
- avatar image
- Console and Cloud Shell
- 40 minutes Free
- Rate Lab
- Overview
- In this lab, you become familiar with the Google Cloud web-based interface. There are two integrated environments: a GUI (graphical user interface) environment called the Cloud Console, and a CLI (command-line interface) called Cloud Shell. In this class you use both environments.
- Here are a few things you need to know about the Cloud Console:
- The Cloud Console is under continuous development, so occasionally the graphical layout changes. This is most often to accommodate new Google Cloud features or changes in the technology, resulting in a slightly different workflow.
- You can perform most common Google Cloud actions in the Cloud Console, but not all actions. In particular, very new technologies or sometimes detailed API or command options are not implemented (or not yet implemented) in the Cloud Console. In these cases, the command line or the API is the best alternative.
- The Cloud Console is extremely fast for some activities. The Cloud Console can perform multiple actions on your behalf that might require many CLI commands. It can also perform repetitive actions. In a few clicks you can accomplish activities that would require a great deal of typing and would be prone to typing errors.
- The Cloud Console is able to reduce errors by only offering up through its menus valid options. It is able to leverage access to the platform "behind the scenes" through the SDK to validate configuration before submitting changes. A command line can't do this kind of dynamic validation.
- Objectives
- In this lab, you learn how to perform the following tasks:
- Get access to Google Cloud.
- Create a Cloud Storage bucket using the Cloud Console.
- Create a Cloud Storage bucket using Cloud Shell.
- Become familiar with Cloud Shell features.
- Qwiklabs setup
- For each lab, you get a new GCP project and set of resources for a fixed time at no cost.
- Make sure you signed into Qwiklabs using an incognito window.
- Note the lab's access time (for example, img/time.png and make sure you can finish in that time block.
- There is no pause feature. You can restart if needed, but you have to start at the beginning.
- When ready, click img/start_lab.png.
- Note your lab credentials. You will use them to sign in to Cloud Platform Console. img/open_google_console.png
- 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 get errors or incur charges.
- Accept the terms and skip the recovery resource page.
- Do not click End Lab unless you are finished with the lab or want to restart it. This clears your work and removes the project.
- Task 1: Create a bucket using the Cloud Console
- In this task, you create a bucket. However, the text also helps you become familiar with how actions are presented in the lab instructions in this class and teaches you about the Cloud Console interface.
- Navigate to the Storage service and create the bucket
- In the Cloud Console, on the Navigation menu (9a951fa6d60a98a5.png), click Storage > Browser.
- Click Create bucket.
- For Name, type a globally unique bucket name, and leave all other values as their defaults.
- Click Create.
- Explore features in the Cloud Console
- The Google Cloud menu contains a Notifications (e921662595351d9e.png) icon. Sometimes, feedback from the underlying commands is provided there. If you are not sure what is happening, check Notifications for additional information and history.
- Click Check my progress to verify the objective.
- Create a bucket using the Cloud Console
- Task 2: Access Cloud Shell
- In this section, you explore Cloud Shell and some of its features.
- You can use the Cloud Shell to manage projects and resources via command line, without having to install the Cloud SDK and other tools on your computer.
- Cloud shell provides the following:
- Temporary Compute Engine VM
- Command-line access to the instance via a browser
- 5 GB of persistent disk storage ($HOME dir)
- Pre-installed Cloud SDK and other tools
- gcloud: for working with Google Compute Engine and many Google Cloud services
- gsutil: for working with Cloud Storage
- kubectl: for working with Google Container Engine and Kubernetes
- bq: for working with BigQuery
- Language support for Java, Go, Python, Node.js, PHP, and Ruby
- Web preview functionality
- Built-in authorization for access to resources and instances
- After 1 hour of inactivity, the Cloud Shell instance is recycled. Only the /home directory persists. Any changes made to the system configuration, including environment variables, are lost between sessions.
- Open Cloud Shell and explore features
- In the Google Cloud menu, click Activate Cloud Shell (e92fcd01cbb5e0ff.png). If prompted, click Continue. Cloud Shell opens at the bottom of the Cloud Console window.
- There are three icons to the far right of the Cloud Shell toolbar:
- Hide/Restore: The first one hides and restores the window, giving you full access to the Cloud Console without closing Cloud Shell.
- Open in new window: Having Cloud Shell at the bottom of the Cloud Console is useful when you are issuing individual commands. However, sometimes you will be editing files or want to see the full output of a command. For these uses, this icon pops the Cloud Shell out into a full-sized terminal window.
- Close all tabs: This icon closes Cloud Shell. Every time you close Cloud Shell, the virtual machine is recycled and all machine context is lost.
- Close Cloud Shell now.
- Task 3: Create a bucket using Cloud Shell
- Create a second bucket and verify in the Cloud Console
- Open Cloud Shell again.
- Use the gsutil command to create another bucket. Replace <BUCKET_NAME> with a globally unique name (you can append a 2 to the globally unique bucket name you used previously):
- gsutil mb gs://<BUCKET_NAME>
- In the Cloud Console, on the Navigation menu (9a951fa6d60a98a5.png), click Storage > Browser, or click Refresh if you are already in the Storage Browser. The second bucket should be displayed in the Buckets list.
- You have performed equivalent actions using the Cloud Console and Cloud Shell.
- You created a bucket using the Cloud Console and another bucket using Cloud Shell.
- Click Check my progress to verify the objective.
- Create a bucket using Cloud Shell
- Task 4: Explore more Cloud Shell features
- Upload a file
- Open Cloud Shell.
- Click the three dots (b4af82f98f85f64f.png) icon in the Cloud Shell toolbar to display further options.
- Click Upload file. Upload any file from your local machine to the Cloud Shell VM. This file will be referred to as [MY_FILE].
- In Cloud Shell, type ls to confirm that the file was uploaded.
- Copy the file into one of the buckets you created earlier in the lab. Replace [MY_FILE] with the file you uploaded and [BUCKET_NAME] with one of your bucket names:
- gsutil cp [MY_FILE] gs://[BUCKET_NAME]
- If your filename has whitespaces, ensure to place single quotes around the filename. For example, gsutil cp ‘my file.txt' gs://[BUCKET_NAME]
- You have uploaded a file to the Cloud Shell VM and copied it to a bucket.
- Explore the options available in Cloud Shell by clicking on different icons in the Cloud Shell toolbar.
- Close all the Cloud Shell sessions.
- Click Check my progress to verify the objective.
- Upload a file to Storage bucket
- Task 5: Create a persistent state in Cloud Shell
- In this section you will learn a best practice for using Cloud Shell. The gcloud command often requires specifying values such as a Region or Zone or Project ID. Entering them repeatedly increases the chances of making typing errors. If you use Cloud Shell a lot, you may want to set common values in environment variables and use them instead of typing the actual values.
- Identify available regions
- Open Cloud Shell from the Cloud Console. Note that this allocates a new VM for you.
- To list available regions, execute the following command:
- gcloud compute regions list
- Select a region from the list and note the value in any text editor. This region will now be referred to as [YOUR_REGION] in the remainder of the lab.
- Create and verify an environment variable
- Create an environment variable and replace [YOUR_REGION] with the region you selected in the previous step:
- INFRACLASS_REGION=[YOUR_REGION]
- Verify it with echo:
- echo $INFRACLASS_REGION
- You can use environment variables like this in gcloud commands to reduce the opportunities for typos, and so that you won't have to remember a lot of detailed information.
- Every time you close Cloud Shell and reopen it, a new VM is allocated, and the environment variable you just set disappears. In the next steps, you create a file to set the value so that you won't have to enter the command each time Cloud Shell is cycled.
- Append the environment variable to a file
- Create a subdirectory for materials used in this class:
- mkdir infraclass
- Create a file called config in the infraclass directory:
- touch infraclass/config
- Append the value of your Region environment variable to the config file:
- echo INFRACLASS_REGION=$INFRACLASS_REGION >> ~/infraclass/config
- Create a second environment variable for your Project ID, replacing [YOUR_PROJECT_ID] with your Project ID. You can find the project ID on the Cloud Console Home page.
- INFRACLASS_PROJECT_ID=[YOUR_PROJECT_ID]
- Append the value of your Project ID environment variable to the config file:
- echo INFRACLASS_PROJECT_ID=$INFRACLASS_PROJECT_ID >> ~/infraclass/config
- Use the source command to set the environment variables, and use the echo command to verify that the project variable was set:
- source infraclass/config
- echo $INFRACLASS_PROJECT_ID
- This gives you a method to create environment variables and to easily recreate them if the Cloud Shell is cycled. However, you will still need to remember to issue the source command each time Cloud Shell is opened.
- In the next step you will modify the .profile file so that the source command is issued automatically any time a terminal to Cloud Shell is opened.
- Close and re-open Cloud Shell. Then issue the echo command again:
- echo $INFRACLASS_PROJECT_ID
- There will be no output because the environment variable no longer exists.
- Modify the bash profile and create persistence
- Edit the shell profile with the following command:
- nano .profile
- Add the following line to the end of the file:
- source infraclass/config
- Press Ctrl+O, ENTER to save the file, and then press Ctrl+X to exit nano.
- Close and then re-open Cloud Shell to cycle the VM.
- Use the echo command to verify that the variable is still set:
- echo $INFRACLASS_PROJECT_ID
- You should now see the expected value that you set in the config file.
- If you ever find your Cloud Shell environment corrupted, you can find instructions on resetting it here:
- Resetting Cloud Shell
- This will cause everything in your Cloud Shell environment to be set back to its original default state.
- Task 6: Review the Google Cloud interface
- Cloud Shell is an excellent interactive environment for exploring Google Cloud using Google Cloud SDK commands like gcloud and gsutil.
- You can install the Google Cloud SDK on a computer or on a VM instance in Google Cloud. The gcloud and gsutil commands can be automated using a scripting language like bash (Linux) or Powershell (Windows). You can also explore using the command-line tools in Cloud Shell, and then use the parameters as a guide for re-implementing in the SDK using one of the supported languages.
- The Google Cloud interface consists of two parts: the Cloud Console and Cloud Shell.
- The Console:
- Provides a fast way to get things done
- Presents options to you, instead of requiring you to know them
- Performs behind-the-scenes validation before submitting the commands
- Cloud Shell provides:
- Detailed control
- Complete range of options and features
- A path to automation through scripting
- End your lab
- When you have completed your lab, click End Lab. Qwiklabs 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:
- 1 star = Very dissatisfied
- 2 stars = Dissatisfied
- 3 stars = Neutral
- 4 stars = Satisfied
- 5 stars = Very satisfied
- 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 2019 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.
- Overview
- Objectives
- Task 1: Create a bucket using the Cloud Console
- Task 2: Access Cloud Shell
- Task 3: Create a bucket using Cloud Shell
- Task 4: Explore more Cloud Shell features
- Task 5: Create a persistent state in Cloud Shell
- Task 6: Review the Google Cloud interface
- End your lab
- Score
- 15/15
- Create a bucket using the GCP Console
- Run Step
- 5 / 5
- Create a bucket using Cloud Shell
- Run Step
- 5 / 5
- Upload a file to Storage bucket
- Run Step
- 5 / 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement