Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add link to GCP regions and zones #23

Open
wants to merge 93 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
aea34c5
Add link to GCP regions and zones
CharlesTBetz Mar 22, 2020
a24960b
minor adjustment
CharlesTBetz Mar 22, 2020
784485b
Offending ECDSA key error fix
CharlesTBetz Mar 22, 2020
96d0c8d
allow unauthenticated mongodb install
CharlesTBetz Mar 22, 2020
5a774cc
Update 03-scripts.md
CharlesTBetz Mar 22, 2020
e873ba9
Update 01-prerequisites.md
CharlesTBetz Mar 28, 2020
92b1d4c
Update 01-prerequisites.md
CharlesTBetz Mar 28, 2020
e903a21
Update 01-prerequisites.md
CharlesTBetz Mar 28, 2020
c2c5380
Update 04-packer.md
CharlesTBetz Mar 28, 2020
5adb1a5
Update 01-prerequisites.md
CharlesTBetz Mar 28, 2020
dbfca3e
Update 01-prerequisites.md
CharlesTBetz Mar 28, 2020
d9b5cdb
Update 01-prerequisites.md
CharlesTBetz Mar 28, 2020
b1a6dc6
Update 02-manual-operations.md
CharlesTBetz Mar 28, 2020
c8078bc
Update 05-terraform.md
CharlesTBetz Mar 29, 2020
49d4390
Update 04-packer.md
CharlesTBetz Mar 29, 2020
b6ad2ac
Update 04-packer.md
CharlesTBetz Mar 29, 2020
1ebe5bc
Update 03-scripts.md
CharlesTBetz Mar 29, 2020
0f175c6
Update 03-scripts.md
CharlesTBetz Mar 29, 2020
ee3af8d
Update 03-scripts.md
CharlesTBetz Mar 29, 2020
01fd6af
Update 04-packer.md
CharlesTBetz Mar 29, 2020
0003eac
Update 04-packer.md
CharlesTBetz Mar 29, 2020
9bba4fa
Update 04-packer.md
CharlesTBetz Mar 29, 2020
d0b9617
Update 04-packer.md
CharlesTBetz Mar 29, 2020
eccb914
Update 05-terraform.md
CharlesTBetz Mar 29, 2020
d6f4c64
Update 05-terraform.md
CharlesTBetz Mar 29, 2020
7d1a247
Update 05-terraform.md
CharlesTBetz Mar 29, 2020
4a9b500
Update 05-terraform.md
CharlesTBetz Mar 29, 2020
45454ae
Update 05-terraform.md
CharlesTBetz Mar 29, 2020
c73c016
Update 05-terraform.md
CharlesTBetz Mar 29, 2020
d22b064
Update 05-terraform.md
CharlesTBetz Mar 29, 2020
51d938d
Update 05-terraform.md
CharlesTBetz Mar 29, 2020
f988981
Update 05-terraform.md
CharlesTBetz Mar 29, 2020
a2a7b07
Update 05-terraform.md
CharlesTBetz Mar 30, 2020
a47bf8b
Update 06-ansible.md
CharlesTBetz Mar 30, 2020
4c9d16f
Update 07-vagrant.md
CharlesTBetz Mar 30, 2020
0b496f8
Update 08-docker.md
CharlesTBetz Mar 30, 2020
d2d4d9f
image
CharlesTBetz-test Mar 30, 2020
e7c3f88
image
CharlesTBetz-test Mar 30, 2020
f873201
Update 08-docker.md
CharlesTBetz Mar 30, 2020
db5dd68
Update 08-docker.md
CharlesTBetz Mar 31, 2020
ab93ecc
images
CharlesTBetz-test Mar 31, 2020
ac3c24c
Update 08-docker.md
CharlesTBetz Mar 31, 2020
cefe752
Update 08-docker.md
CharlesTBetz Mar 31, 2020
ee91124
Update 08-docker.md
CharlesTBetz Mar 31, 2020
9384f10
Update 09-docker-compose.md
CharlesTBetz Mar 31, 2020
60b1fdc
Update 10-kubernetes.md
CharlesTBetz Mar 31, 2020
7f6f3e8
Update 08-docker.md
CharlesTBetz Apr 3, 2020
b152cd6
Update 08-docker.md
CharlesTBetz Apr 3, 2020
218b65d
Update 10-kubernetes.md
CharlesTBetz Apr 3, 2020
35ab8d6
Update 10-kubernetes.md
CharlesTBetz Apr 3, 2020
ef62fe7
Update 03-scripts.md
CharlesTBetz Apr 4, 2020
1ff26cf
Update README.md
CharlesTBetz Apr 4, 2020
e389cac
Update 02-manual-operations.md
CharlesTBetz Apr 4, 2020
573623a
Update 02-manual-operations.md
CharlesTBetz Apr 4, 2020
5928689
Update 03-scripts.md
CharlesTBetz Apr 4, 2020
42d5574
Update 03-scripts.md
CharlesTBetz Apr 4, 2020
88b0693
Update 03-scripts.md
CharlesTBetz Apr 4, 2020
c78a957
Update 03-scripts.md
CharlesTBetz Apr 4, 2020
85fd480
Update 03-scripts.md
CharlesTBetz Apr 4, 2020
1d54207
Update 04-packer.md
CharlesTBetz Apr 4, 2020
209efa6
Update 04-packer.md
CharlesTBetz Apr 4, 2020
6757adf
Update 04-packer.md
CharlesTBetz Apr 4, 2020
21eeffe
Update 05-terraform.md
CharlesTBetz Apr 4, 2020
1ad25db
Update 08-docker.md
CharlesTBetz Apr 4, 2020
8fef76f
Update 09-docker-compose.md
CharlesTBetz Apr 4, 2020
b641a6c
Update 10-kubernetes.md
CharlesTBetz Apr 4, 2020
1fc4be7
Update 10-kubernetes.md
CharlesTBetz Apr 4, 2020
9181a55
Update 10-kubernetes.md
CharlesTBetz Apr 4, 2020
4b97c21
Update 10-kubernetes.md
CharlesTBetz Apr 4, 2020
6dc8502
Update 02-manual-operations.md
CharlesTBetz Apr 25, 2020
6f5e8c2
Update 02-manual-operations.md
CharlesTBetz Apr 25, 2020
7622511
Update README.md
CharlesTBetz May 18, 2020
ddeae27
Update README.md
CharlesTBetz Aug 10, 2020
64b7756
Update 02-manual-operations.md
CharlesTBetz Aug 10, 2020
6beee9f
Update 02-manual-operations.md
CharlesTBetz Aug 11, 2020
223ea27
Update 02-manual-operations.md
CharlesTBetz Aug 11, 2020
773264a
Update 02-manual-operations.md
CharlesTBetz Aug 11, 2020
6b61ccf
Update 02-manual-operations.md
CharlesTBetz Aug 11, 2020
88c58a8
Update 02-manual-operations.md
CharlesTBetz Aug 11, 2020
77ced44
Update 02-manual-operations.md
CharlesTBetz Aug 11, 2020
92b4857
Update 02-manual-operations.md
CharlesTBetz Aug 11, 2020
7b710b1
finished 02 first cut
CharlesTBetz-test Aug 12, 2020
af87948
Update 02-manual-operations.md
CharlesTBetz Aug 12, 2020
8b2d03e
updating 02
CharlesTBetz-test Aug 15, 2020
d9a3e2a
02 work
CharlesTBetz-test Aug 15, 2020
5934d1e
04 updates
CharlesTBetz-test Aug 15, 2020
2f6c857
05 working
CharlesTBetz-test Aug 15, 2020
c7f2189
05 terraform
CharlesTBetz-test Aug 15, 2020
4f1c89d
06
CharlesTBetz-test Aug 16, 2020
ddbd5d3
many changes
CharlesTBetz-test Aug 16, 2020
b21c891
08
CharlesTBetz-test Aug 16, 2020
9f94d9b
adoc conversion
CharlesTBetz-test Aug 22, 2020
a9e3b9e
removed md
CharlesTBetz-test Aug 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
51 changes: 0 additions & 51 deletions README.md

This file was deleted.

23 changes: 23 additions & 0 deletions docs/00-introduction.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
= Introduction

Let's dream for a little bit...

Imagine that you're a young developer who developed a web application.
You run and test your application locally and everything works great, which makes you very happy.
You believe that this is going to blow the minds of Internet users and bring you a lot of money.

Then you realize that there is a small problem.
You ask yourself a question: "How do I make my application available to the Internet users?"

You're thinking that you can't run the application locally all the time, because your old laptop will become slow for other tasks and will probably crash if a lot of users will be using your app at the same time.
Besides, your ISP changes randomly the public IP for your router, so you don't know on which IP address your application will be accessible to the public at any given moment.

You start realizing that the problem you're facing is not as small as you thought.
In fact, there is a whole new craft for you to learn in IT world about running software applications and making sure they are always available to the users.

The craft is called *IT operations*.
And in almost every IT department, there is an operations (Ops) team who manages the platform where the applications are running.

The tutorial you are about to begin will give you, a young developer, a bit of a glance into what operations work look like and how you can do this work more efficiently by using *Infrastructure as Code* approach.

Next: xref:01-prerequisites.adoc[Prerequisites]
17 changes: 0 additions & 17 deletions docs/00-introduction.md

This file was deleted.

38 changes: 38 additions & 0 deletions docs/01-prerequisites.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
= Prerequisites

== Google Cloud Platform

In this tutorial, we use the https://cloud.google.com/[Google Cloud Platform] to provision the compute infrastructure.
You have already signed up.

Start in the Google Cloud Shell.
https://cloud.google.com/shell/docs/using-cloud-shell[(review)]

== Google Cloud Platform

=== Set a Default Project, Compute Region and Zone

This tutorial assumes a default compute region and zone have been configured.

Set a default compute region appropriate to your location (https://cloud.google.com/compute/docs/regions-zones[GCP regions and zones]):

[source,bash]
----
$ gcloud config set compute/region us-central1
----

Set a default compute zone appropriate to the zone:

[source,bash]
----
$ gcloud config set compute/zone us-central1-c
----

Verify the configuration settings:

[source,bash]
----
$ gcloud config list
----

Next: xref:02-manual-operations.adoc[Manual operations]
51 changes: 0 additions & 51 deletions docs/01-prerequisites.md

This file was deleted.

195 changes: 195 additions & 0 deletions docs/02-manual-operations.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
= Manual Operations

To better understand the `Infrastructure as Code` (`IaC`) concept, we will first define the problem we are facing and deal with it with manually to get our hands dirty and see how things work overall.

== Intro

Imagine you have developed a new cool application called https://github.com/dm-academy/node-svc-v1[node-svc].

You want to run your application on a dedicated server and make it available to the Internet users.

You heard about the `public cloud` thing, which allows you to provision compute resources and pay only for what you use.
You believe it's a great way to test your idea of an application and see if people like it.

You've signed up for a free tier of https://cloud.google.com/[Google Cloud Platform] (GCP) and are about to start deploying your application.

== Provision Compute Resources

First thing we will do is to provision a virtual machine (VM) inside GCP for running the application.

Use the following gcloud command in your terminal to launch a VM with Ubuntu 16.04 distro:

[source,bash]
----
$ gcloud compute instances create node-svc\
--image-family ubuntu-minimal-2004-lts \
--image-project ubuntu-os-cloud \
--boot-disk-size 10GB \
--machine-type f1-micro
----

== Create an SSH key pair

Generate an SSH key pair for future connections to the VM instances (run the command exactly as it is):

[source,bash]
----
$ ssh-keygen -t rsa -f ~/.ssh/node-user -C node-user -P ""
----

Create an SSH public key for your project:

[source,bash]
----
$ gcloud compute project-info add-metadata \
--metadata ssh-keys="node-user:$(cat ~/.ssh/node-user.pub)"
----

Check your ssh-agent is running:

[source,bash]
----
$ echo $SSH_AGENT_PID
----

If you get a number, it is running.
If you get nothing, then run:

[source,bash]
----
$ eval `ssh-agent`
----

Add the SSH private key to the ssh-agent:

$ ssh-add ~/.ssh/node-user

Verify that the key was added to the ssh-agent:

[source,bash]
----
$ ssh-add -l
----

== Install Application Dependencies

To start the application, you need to first configure the environment for running it.

Connect to the started VM via SSH using the following two commands:

[source,bash]
----
$ INSTANCE_IP=$(gcloud --format="value(networkInterfaces[0].accessConfigs[0].natIP)" compute instances describe node-svc)
$ ssh node-user@${INSTANCE_IP}
----

Install Node and npm:

[source,bash]
----
$
$ sudo apt-get install -y nodejs npm
----

Check the installed version of Node:

[source,bash]
----
$ node -v
----

Install `git`:

[source,bash]
----
$ sudo apt -y install git
----

Clone the application repo into the home directory of `node-user` user (reminder, how do you clone to the right location?):

[source,bash]
----
$ git clone https://github.com/dm-academy/node-svc-v1
----

Navigate to the repo (`cd node-svc-v1`) and check out the 02 branch (matching this lesson)

[source,bash]
----
$ git checkout 02
Branch 02 set up to track remote branch 02 from origin.
Switched to a new branch '02'
----

Initialize npm (Node Package Manager) and install express:

[source,bash]
----
$ npm install
$ npm install express
----

== Start the Application

Look at the server.js file (`cat`).
We will discuss in class.

Start the Node web server:

[source,bash]
----
$ nodejs server.js &
Running on 3000
----

Test it:

[source,bash]
----
$ curl localhost:3000
Successful request.
----

== Access the Application

Open a firewall port the application is listening on (note that the following command should be run on the Google Cloud Shell):

[source,bash]
----
$ gcloud compute firewall-rules create allow-node-svc-tcp-3000 \
--network default \
--action allow \
--direction ingress \
--rules tcp:3000 \
--source-ranges 0.0.0.0/0
----

Get the public IP of the VM:

[source,bash]
----
$ gcloud --format="value(networkInterfaces[0].accessConfigs[0].natIP)" compute instances describe node-svc-instance
----

Now open your browser and try to reach the application at the public IP and port 3000.

For example, I put in my browser the following URL http://104.155.1.152:3000, but note that you'll have your own IP address.

== Conclusion

Congrats!
You've just deployed your application.
It is running on a dedicated set of compute resources in the cloud and is accessible by a public IP.
Now Internet users can enjoy using your application.

Now that you've got the idea of what sort of steps you have to take to deploy your code from your local machine to a virtual server running in the cloud, let's see how we can do it more efficiently.

Destroy the current VM and firewall rule and move to the next step:

[source,bash]
----
$ gcloud compute instances delete -q node-svc
$ gcloud compute firewall-rules delete -q allow-node-svc-tcp-9292
----

Next: xref:03-scripts.adoc[Scripts]
Loading