{"id":2606,"date":"2018-09-06T22:44:48","date_gmt":"2018-09-06T22:44:48","guid":{"rendered":"http:\/\/microsoftgeek.com\/?p=2606"},"modified":"2018-09-06T22:44:48","modified_gmt":"2018-09-06T22:44:48","slug":"getting-started-with-cloud-shell-gcloud","status":"publish","type":"post","link":"https:\/\/microsoftgeek.com\/?p=2606","title":{"rendered":"Getting Started with Cloud Shell &#038; Gcloud"},"content":{"rendered":"<h2 id=\"title\" class=\"style-scope google-codelab-step\"><span class=\"style-scope google-codelab-step\">1<\/span>.\u00a0<span class=\"style-scope google-codelab-step\">Overview<\/span><\/h2>\n<p>Google Cloud Shell provides you with command-line access to computing resources hosted on Google Cloud Platform and is available now in the Google Cloud Platform Console. Cloud Shell makes it easy for you to manage your Cloud Platform Console projects and resources without having to install the Google Cloud SDK and other tools on your system. With Cloud Shell, the Cloud SDK\u00a0<code>gcloud<\/code>\u00a0command and other utilities you need are always available when you need them.<\/p>\n<p>In this codelab, you will learn how to connect to computing resources hosted on Google Cloud Platform via the web. You will learn how to use Cloud Shell and the Cloud SDK\u00a0<code>gcloud<\/code>\u00a0command.<\/p>\n<p>This tutorial is adapted from\u00a0<a href=\"https:\/\/cloud.google.com\/cloud-shell\/docs\/quickstart\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/cloud.google.com\/cloud-shell\/docs\/quickstart<\/a>\u00a0and\u00a0<a href=\"https:\/\/cloud.google.com\/sdk\/gcloud\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/cloud.google.com\/sdk\/gcloud\/<\/a><\/p>\n<h3 class=\"checklist\"><strong>What you&#8217;ll learn<\/strong><\/h3>\n<ul class=\"checklist\">\n<li>How to connect to computing resources hosted on Google Cloud Platform.<\/li>\n<li>How to use\u00a0<code>gcloud<\/code>\u00a0commands<\/li>\n<\/ul>\n<h3><strong>What you&#8217;ll need<\/strong><\/h3>\n<ul>\n<li>Familiarity with standard Linux text editors such as Vim, EMACs or Nano<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2 id=\"title\" class=\"style-scope google-codelab-step\"><span class=\"style-scope google-codelab-step\">2<\/span>.\u00a0<span class=\"style-scope google-codelab-step\">Setup and Requirements<\/span><\/h2>\n<h2><strong>Self-paced environment setup<\/strong><\/h2>\n<p>If you don&#8217;t already have a Google Account (Gmail or Google Apps), you must\u00a0<a href=\"https:\/\/accounts.google.com\/SignUp\" target=\"_blank\" rel=\"noopener noreferrer\">create one<\/a>. Sign-in to Google Cloud Platform console (<a href=\"http:\/\/console.cloud.google.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">console.cloud.google.com<\/a>) and create a new project:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/iHhcE5E3Q9EgC0Co0aG_zRe4EDbsNp7NjBbihV02Hx74kNFxmchTs3SVt8HpTImo0QdYw1llpgC2YLilbHr1Iohyy3xcG3ySL5L9n6Sjfy7iHwtEppHPdu2S7AfiL0faNlOB_Gzl\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/KZMNwfTrZ--a7tcACdNX09saQgstDqv3jw5b2xb2PrM4iadXNE8jg-QQQTFnAwAponbE-p_NTuWbe94vPsYFW72GbVnwRopWPVR8qDZfYjSrlI9q7ekDkQoCTg58dh4zmqU9padK\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/GrNDJHeGF0ivcFxXHU3B8ZBZJwQ77_pLcv9Icbti71Rf7sfR-Thoi55uk64qYHZqCezTHonHPE_yiIxT1xLjQRFLUyHi3Q5mST4Zfd8BINp0DjlJBpac9gp63umB1U_SpBgds7um\" \/><\/p>\n<p>Remember the project ID, a unique name across all Google Cloud projects (the name above has already been taken and will not work for you, sorry!). It will be referred to later in this codelab as\u00a0<code>PROJECT_ID<\/code>.<\/p>\n<p>Next, you&#8217;ll need to\u00a0<a href=\"https:\/\/console.cloud.google.com\/billing\" target=\"_blank\" rel=\"noopener noreferrer\">enable billing<\/a>\u00a0in the Cloud Console in order to use Google Cloud resources.<\/p>\n<p>Running through this codelab shouldn&#8217;t cost you more than a few dollars, but it could be more if you decide to use more resources or if you leave them running (see &#8220;cleanup&#8221; section at the end of this document).<\/p>\n<p>&nbsp;<\/p>\n<h2><strong>Launch Cloud Shell<\/strong><\/h2>\n<h3>Activate Google Cloud Shell<\/h3>\n<p>From the GCP Console click the Cloud Shell icon on the top right toolbar:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/7EBr6OLFS04RwQtl_O1zZ5_RuJb880FSbaEx-YKRj8WqNCpzVDoC1xuQZCxdMLyaJGlufCDDu0_5-Nrwo4C7b8B8pcEQYyirBtzMSbHsoLTPRw9M2aiT8JFxuZl97Ekj_thd5pfb\" \/><\/p>\n<p>Then click &#8220;Start Cloud Shell&#8221;:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/KvLqPq-kXV2a12bLtR6QPpUgwNOsb8uTariZXL4Gub_rIoO-M6etpuU27Z0oCO37OWV4rxODSeforx4rHsbhmqgnoVc8U34OT5okYMJXEhagidwMxiBZo2pSmqQjdl4oxPkw4BWg\" \/><\/p>\n<p>It should only take a few moments to provision and connect to the environment:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/o4xbMf1aTN5Yy-lrvmMhiMsaS76DmngbCC6IDr-4B2EBlDOL3wHl5_lrj6zz6ngFJMcXaLBjhjNVBpF_BAullBz-aMLpjMCg3Cqnl2S99JkOZu4o1uLwk9iM1qkXDU-MlEOKgksc\" \/><\/p>\n<p>This virtual machine is loaded with all the development tools you&#8217;ll need. It offers a persistent 5GB home directory, and runs on the Google Cloud, greatly enhancing network performance and authentication. Much, if not all, of your work in this lab can be done with simply a browser or your Google Chromebook.<\/p>\n<p>Once connected to the cloud shell, you should see that you are already authenticated and that the project is already set to your\u00a0<em>PROJECT_ID<\/em>.<\/p>\n<p>Run the following command in the cloud shell to confirm that you are authenticated:<\/p>\n<pre><code><span class=\"pln\">gcloud auth list<\/span><\/code><\/pre>\n<p><strong>Command output<\/strong><\/p>\n<pre>Credentialed accounts:\r\n - &lt;myaccount&gt;@&lt;mydomain&gt;.com (active)<\/pre>\n<aside class=\"special\"><strong>Note:\u00a0<\/strong><code>gcloud<\/code>\u00a0is the powerful and unified command-line tool for Google Cloud Platform. Full documentation is available from\u00a0<a href=\"https:\/\/cloud.google.com\/sdk\/gcloud\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/cloud.google.com\/sdk\/gcloud<\/a>. It comes pre-installed on Cloud Shell. You will notice its support for tab-completion.<\/p>\n<\/aside>\n<pre><code><span class=\"pln\">gcloud config list project<\/span><\/code><\/pre>\n<p><strong>Command output<\/strong><\/p>\n<pre>[core]\r\nproject = &lt;PROJECT_ID&gt;<\/pre>\n<p>If it is not, you can set it with this command:<\/p>\n<pre><code><span class=\"pln\">gcloud config <\/span><span class=\"kwd\">set<\/span><span class=\"pln\"> project <\/span><span class=\"pun\">&lt;<\/span><span class=\"pln\">PROJECT_ID<\/span><span class=\"pun\">&gt;<\/span><\/code><\/pre>\n<p><strong>Command output<\/strong><\/p>\n<pre>Updated property [core\/project].\r\n\r\n\r\n<\/pre>\n<h2 id=\"title\" class=\"style-scope google-codelab-step\"><span class=\"style-scope google-codelab-step\">3<\/span>.\u00a0<span class=\"style-scope google-codelab-step\">Use the command line<\/span><\/h2>\n<p>After Cloud Shell launches, you can use the command line to invoke the Cloud SDK\u00a0<code>gcloud<\/code>\u00a0command or other tools available on the virtual machine instance. You can also use your\u00a0<code>$HOME<\/code>\u00a0directory in persistent disk storage to store files across projects and between Cloud Shell sessions. Your\u00a0<code>$HOME<\/code>\u00a0directory is private to you and cannot be accessed by other users.<\/p>\n<p>Let&#8217;s get started by taking a look at the commands available to you. Try this:<\/p>\n<pre><code><span class=\"pln\">gcloud <\/span><span class=\"pun\">-<\/span><span class=\"pln\">h<\/span><\/code><\/pre>\n<p>Simple usage guidelines are available by adding\u00a0<code>-h<\/code>\u00a0onto the end of any\u00a0<code>gcloud<\/code>\u00a0invocation. More verbose help can be obtained by appending the\u00a0<code>--help<\/code>\u00a0flag, or executing\u00a0<code>gcloud<\/code>\u00a0<code>help COMMAND<\/code>.<\/p>\n<p>Give it a try:<\/p>\n<pre><code><span class=\"pln\">gcloud config <\/span><span class=\"pun\">--<\/span><span class=\"pln\">help<\/span><\/code><\/pre>\n<p>Now try<\/p>\n<pre><code><span class=\"pln\">gcloud help config<\/span><\/code><\/pre>\n<p>You will notice that\u00a0<code>gcloud config --help<\/code>\u00a0and\u00a0<code>gcloud help config<\/code>\u00a0commands are equivalent\u2014both give long, detailed help.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2 id=\"title\" class=\"style-scope google-codelab-step\"><span class=\"style-scope google-codelab-step\">4<\/span>.\u00a0<span class=\"style-scope google-codelab-step\">Using gcloud commands<\/span><\/h2>\n<p>Let&#8217;s try to view the list of configurations in our environment. From reading the long, detailed help in our previous step, we know we can use the command\u00a0<code>gcloud list<\/code>.<\/p>\n<pre><code><span class=\"pln\">gcloud config list<\/span><\/code><\/pre>\n<p>You may wonder whether there are other properties that were not set. You can see all properties by calling:<\/p>\n<pre><code><span class=\"pln\">gcloud config list <\/span><span class=\"pun\">--<\/span><span class=\"pln\">all<\/span><\/code><\/pre>\n<h2><strong>Summary<\/strong><\/h2>\n<p>In this step, you launched Cloud Shell and called some simple\u00a0<code>gcloud<\/code>\u00a0commands.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u00a0Overview Google Cloud Shell provides you with command-line access to computing resources hosted on Google Cloud Platform and is available now in the Google Cloud Platform Console. Cloud Shell makes it easy for you to manage your Cloud Platform Console projects and resources without having to install the Google Cloud SDK and other tools on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70],"tags":[],"class_list":["post-2606","post","type-post","status-publish","format-standard","hentry","category-gcp"],"_links":{"self":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/2606","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2606"}],"version-history":[{"count":1,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/2606\/revisions"}],"predecessor-version":[{"id":2607,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/2606\/revisions\/2607"}],"wp:attachment":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2606"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2606"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2606"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}