GCP100

This class should teach you how to interact with Google Cloud Platform (GCP) at a very simple level.

GCP is extremely feature rich which means it might confuse you with its complexity.

This class should show you some basics which you can use right away.

To get started in my GCP kitchen, I located two important ingredients:

I logged into gmail.

Next, I visited the URL listed below:

https://cloud.google.com/

Then this:

https://cloud.google.com/docs/

Then this:

https://cloud.google.com/free/docs/frequently-asked-questions

I registered; I gave GCP my Credit Card info; GCP gave me a $300 credit.

Be aware, not everyone gets a $300 credit; I'm not sure why.

Next, I visited the URL listed below:

https://cloud.google.com/compute/docs/quickstart-linux

I followed the instructions in that page.

While following the instructions, I noticed that the "VM Instances" page needed a long time to load.

So, be ready for that poor behavior.

One deviation I made from the instructions was from the "Create an instance" page.

Near the bottom of that page I clicked the link to copy my public SSH key from my laptop.

My intent was to ease my ability to ssh into the GCP-Instance from a shell in my laptop.

The text I mouse-copied into the GCP SSH-key-form came from this file:

~/.ssh/id_rsa.pub

It looks like this:

ssh-rsa
AAAAB3NzaC1yc2EAAAADAQABAAABAQC8cbLxnaqPPznHz9DgMq
xg38LPxRTRT1qjyQH0cGEHHtHVYHgPdCNvW++0ArCuJVxiQ7fx
XvK2cYThurYozSkI6uwxVSPBoJgsLmLPvhc+JshDHi7SgtWl4b
8JZlnL5dMPQNo61p/qGmqZpKxXYJanY0zN4WnB17vlnVFhXL2j
3U3YKvifIC8a6gRKitG+XFGmj5sZKbJuqbnfhD93ytcRGV+rEM
VipYAl2XBs27K0VGwK+u3NOOerWXjRrgqIo9Frk7C4rps/dMYd
56QKxnVumr24TUJ0TlymsCYkhD9qDHyJHxGTyN5BAzUpryphd7
QDLZn+Rdrm4Ssu8/jclLPH
dan@ubu42

GCP quickly launched an instance: 35.226.218.244

I connected to it using an ssh shell command from my laptop:


dan@h80:~ $ ssh dan@35.226.218.244
Warning: Permanently added '35.226.218.244' (ECDSA) to the list of known hosts.
Linux instance-1 4.9.0-5-amd64 #1 SMP Debian 4.9.65-3+deb9u2 (2018-01-04) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
dan@instance-1:~$ 
dan@instance-1:~$ 
dan@instance-1:~$

One puzzling bit of behavior is: "How did GCP know that I wanted a Linux account named dan?"

My guess is that it pulled "dan" from the gmail account I was logged in with.

Next I ran some shell commands in my GCP account to verify that it behaved well:


dan@h80:~ $ 
dan@h80:~ $ ssh dan@35.226.218.244
Warning: Permanently added '35.226.218.244' (ECDSA) to the list of known hosts.
Linux instance-1 4.9.0-5-amd64 #1 SMP Debian 4.9.65-3+deb9u2 (2018-01-04) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
dan@instance-1:~$ 
dan@instance-1:~$ 
dan@instance-1:~$ 



dan@instance-1:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            286M     0  286M   0% /dev
tmpfs            60M  3.4M   56M   6% /run
/dev/sda1       9.8G  983M  8.4G  11% /
tmpfs           297M     0  297M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           297M     0  297M   0% /sys/fs/cgroup
dan@instance-1:~$ 
dan@instance-1:~$ 
dan@instance-1:~$ 



dan@instance-1:~$ pwd
/home/dan
dan@instance-1:~$ 
dan@instance-1:~$ 
dan@instance-1:~$ 



dan@instance-1:~$ id
uid=1000(dan) gid=1001(dan) groups=1001(dan),4(adm),30(dip),44(video),46(plugdev),1000(google-sudoers)
dan@instance-1:~$ 
dan@instance-1:~$ 
dan@instance-1:~$ 



dan@instance-1:~$ sudo apt-get update
Ign:1 http://deb.debian.org/debian stretch InRelease
Get:2 http://deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:3 http://packages.cloud.google.com/apt cloud-sdk-stretch InRelease [6,377 B]
Get:4 http://security.debian.org stretch/updates InRelease [63.0 kB]
Get:5 http://packages.cloud.google.com/apt google-compute-engine-stretch-stable InRelease [3,843 B]
Get:6 http://deb.debian.org/debian stretch-backports InRelease [91.8 kB]
Hit:7 http://deb.debian.org/debian stretch Release
Hit:8 http://packages.cloud.google.com/apt google-cloud-packages-archive-keyring-stretch InRelease
Get:9 http://packages.cloud.google.com/apt cloud-sdk-stretch/main amd64 Packages [25.0 kB]
Get:10 http://packages.cloud.google.com/apt google-compute-engine-stretch-stable/main amd64 Packages [1,107 B]
Get:11 http://deb.debian.org/debian stretch-backports/main Sources.diff/Index [27.8 kB]
Get:12 http://deb.debian.org/debian stretch-backports/main amd64 Packages.diff/Index [27.8 kB]
Get:13 http://deb.debian.org/debian stretch-backports/main Translation-en.diff/Index [27.8 kB]
Get:15 http://deb.debian.org/debian stretch-backports/main Sources 2018-02-06-2026.31.pdiff [8,346 B]
Get:16 http://security.debian.org stretch/updates/main Sources [110 kB]
Get:17 http://deb.debian.org/debian stretch-backports/main Sources 2018-02-07-2028.51.pdiff [655 B]
Get:18 http://security.debian.org stretch/updates/main amd64 Packages [271 kB]
Get:19 http://security.debian.org stretch/updates/main Translation-en [120 kB]
Get:20 http://deb.debian.org/debian stretch-backports/main Sources 2018-02-08-0244.34.pdiff [33 B]
Get:21 http://deb.debian.org/debian stretch-backports/main Sources 2018-02-08-1427.47.pdiff [61 B]
Get:22 http://deb.debian.org/debian stretch-backports/main Sources 2018-02-08-2039.02.pdiff [1,363 B]
Get:23 http://deb.debian.org/debian stretch-backports/main Sources 2018-02-09-0244.28.pdiff [1,609 B]
Get:24 http://deb.debian.org/debian stretch-backports/main Sources 2018-02-10-2034.21.pdiff [286 B]
Get:25 http://deb.debian.org/debian stretch-backports/main Sources 2018-02-11-0226.00.pdiff [721 B]
Get:26 http://deb.debian.org/debian stretch-backports/main amd64 Packages 2018-02-06-2026.31.pdiff [13.6 kB]
Get:25 http://deb.debian.org/debian stretch-backports/main Sources 2018-02-11-0226.00.pdiff [721 B]
Get:27 http://deb.debian.org/debian stretch-backports/main amd64 Packages 2018-02-08-0244.34.pdiff [232 B]
Get:28 http://deb.debian.org/debian stretch-backports/main amd64 Packages 2018-02-09-0244.28.pdiff [1,537 B]
Get:29 http://deb.debian.org/debian stretch-backports/main amd64 Packages 2018-02-09-1007.33.pdiff [1,005 B]
Get:30 http://deb.debian.org/debian stretch-backports/main amd64 Packages 2018-02-11-0226.00.pdiff [320 B]
Get:30 http://deb.debian.org/debian stretch-backports/main amd64 Packages 2018-02-11-0226.00.pdiff [320 B]
Get:31 http://deb.debian.org/debian stretch-backports/main Translation-en 2018-02-06-2026.31.pdiff [7,494 B]
Get:32 http://deb.debian.org/debian stretch-backports/main Translation-en 2018-02-07-0231.38.pdiff [371 B]
Get:33 http://deb.debian.org/debian stretch-backports/main Translation-en 2018-02-07-1427.34.pdiff [364 B]
Get:34 http://deb.debian.org/debian stretch-backports/main Translation-en 2018-02-08-1427.47.pdiff [351 B]
Get:34 http://deb.debian.org/debian stretch-backports/main Translation-en 2018-02-08-1427.47.pdiff [351 B]
Fetched 905 kB in 2s (324 kB/s)
Reading package lists... Done
dan@instance-1:~$ 
dan@instance-1:~$ 
dan@instance-1:~$ 



dan@instance-1:~$ sudo apt-get install git
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  git-man less libcurl3-gnutls liberror-perl libperl5.24 patch perl
  perl-modules-5.24 rename rsync
Suggested packages:
  git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk
  gitweb git-arch git-cvs git-mediawiki git-svn ed diffutils-doc perl-doc
  libterm-readline-gnu-perl | libterm-readline-perl-perl make
The following NEW packages will be installed:
  git git-man less libcurl3-gnutls liberror-perl libperl5.24 patch perl
  perl-modules-5.24 rename rsync
0 upgraded, 11 newly installed, 0 to remove and 2 not upgraded.
Need to get 13.0 MB of archives.
After this operation, 73.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] 



Get:1 http://deb.debian.org/debian stretch/main amd64 perl-modules-5.24 all 5.24.1-3+deb9u2 [2,724 kB]
Get:2 http://security.debian.org stretch/updates/main amd64 libcurl3-gnutls amd64 7.52.1-5+deb9u4 [289 kB]
Get:3 http://security.debian.org stretch/updates/main amd64 rsync amd64 3.1.2-1+deb9u1 [393 kB]
Get:4 http://deb.debian.org/debian stretch/main amd64 libperl5.24 amd64 5.24.1-3+deb9u2 [3,538 kB]
Get:5 http://deb.debian.org/debian stretch/main amd64 perl amd64 5.24.1-3+deb9u2 [218 kB]
Get:6 http://deb.debian.org/debian stretch/main amd64 liberror-perl all 0.17024-1 [26.9 kB]
Get:7 http://deb.debian.org/debian stretch/main amd64 git-man all 1:2.11.0-3+deb9u2 [1,432 kB]
Get:8 http://deb.debian.org/debian stretch/main amd64 git amd64 1:2.11.0-3+deb9u2 [4,160 kB]
Get:9 http://deb.debian.org/debian stretch/main amd64 less amd64 481-2.1 [126 kB]
Get:10 http://deb.debian.org/debian stretch/main amd64 patch amd64 2.7.5-1+b2 [112 kB]
Get:11 http://deb.debian.org/debian stretch/main amd64 rename all 0.20-4 [12.5 kB]
Fetched 13.0 MB in 0s (25.1 MB/s)
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module)
(@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 /usr/local/share/perl/5.24.1
/usr/lib/x86_64-linux-gnu/perl5/5.24 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.24
/usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at
/usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7, <> line 11.)
debconf: falling back to frontend: Teletype
Selecting previously unselected package perl-modules-5.24.
(Reading database ... 31435 files and directories currently installed.)
Preparing to unpack .../00-perl-modules-5.24_5.24.1-3+deb9u2_all.deb ...
Unpacking perl-modules-5.24 (5.24.1-3+deb9u2) ...
Selecting previously unselected package libperl5.24:amd64.
Preparing to unpack .../01-libperl5.24_5.24.1-3+deb9u2_amd64.deb ...
Unpacking libperl5.24:amd64 (5.24.1-3+deb9u2) ...
Selecting previously unselected package perl.
Preparing to unpack .../02-perl_5.24.1-3+deb9u2_amd64.deb ...
Unpacking perl (5.24.1-3+deb9u2) ...
Selecting previously unselected package libcurl3-gnutls:amd64.
Preparing to unpack .../03-libcurl3-gnutls_7.52.1-5+deb9u4_amd64.deb ...
Unpacking libcurl3-gnutls:amd64 (7.52.1-5+deb9u4) ...
Selecting previously unselected package liberror-perl.
Preparing to unpack .../04-liberror-perl_0.17024-1_all.deb ...
Unpacking liberror-perl (0.17024-1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../05-git-man_1%3a2.11.0-3+deb9u2_all.deb ...
Unpacking git-man (1:2.11.0-3+deb9u2) ...
Selecting previously unselected package git.
Preparing to unpack .../06-git_1%3a2.11.0-3+deb9u2_amd64.deb ...
Unpacking git (1:2.11.0-3+deb9u2) ...
Selecting previously unselected package less.
Preparing to unpack .../07-less_481-2.1_amd64.deb ...
Unpacking less (481-2.1) ...
Selecting previously unselected package patch.
Preparing to unpack .../08-patch_2.7.5-1+b2_amd64.deb ...
Unpacking patch (2.7.5-1+b2) ...
Selecting previously unselected package rename.
Preparing to unpack .../09-rename_0.20-4_all.deb ...
Unpacking rename (0.20-4) ...
Selecting previously unselected package rsync.
Preparing to unpack .../10-rsync_3.1.2-1+deb9u1_amd64.deb ...
Unpacking rsync (3.1.2-1+deb9u1) ...
Setting up perl-modules-5.24 (5.24.1-3+deb9u2) ...
Setting up libperl5.24:amd64 (5.24.1-3+deb9u2) ...
Setting up git-man (1:2.11.0-3+deb9u2) ...
Setting up less (481-2.1) ...
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
Processing triggers for mime-support (3.60) ...
Setting up libcurl3-gnutls:amd64 (7.52.1-5+deb9u4) ...
Setting up rsync (3.1.2-1+deb9u1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/rsync.service → /lib/systemd/system/rsync.service.
Setting up perl (5.24.1-3+deb9u2) ...
update-alternatives: using /usr/bin/prename to provide /usr/bin/rename (rename) in auto mode
Setting up patch (2.7.5-1+b2) ...
Processing triggers for libc-bin (2.24-11+deb9u1) ...
Processing triggers for systemd (232-25+deb9u1) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up liberror-perl (0.17024-1) ...
Setting up rename (0.20-4) ...
update-alternatives: using /usr/bin/file-rename to provide /usr/bin/rename (rename) in auto mode
Setting up git (1:2.11.0-3+deb9u2) ...
dan@instance-1:~$ 
dan@instance-1:~$
dan@instance-1:~$

So I have just given you a very quick summary on how to start a Linux instance on GCP.

Review:

Class02


ml4.us About Blog Contact Class01 Class02 Class03 Class04 Class05 Class06 Class07 Class08 Class09 Class10 dan101 Forum Google Hangout Vboxen