paint-brush
DevOps101: How To Provide Infrastructure To Your Startup In 6 Easy Stepsby@rafaelbelchior
1,527 reads
1,527 reads

DevOps101: How To Provide Infrastructure To Your Startup In 6 Easy Steps

by Rafael BelchiorDecember 14th, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

<em>I’m currently a teacher assistant </em>👨‍💻<em>@ </em><a href="https://tecnico.ulisboa.pt/en/" target="_blank"><em>Técnico Lisboa</em></a><em>, and I’m working closely with </em><a href="https://fenix.tecnico.ulisboa.pt/homepage/ist40132" target="_blank"><em>Dr. Professor Rui Cruz</em></a> 👨‍🏫<em>at the </em><a href="https://fenix.tecnico.ulisboa.pt/disciplinas/AGISIT/2018-2019/1-semestre" target="_blank"><em>It Infrastructure Management and Administration</em></a><em> </em>🖥<em>, a </em>masters level course <em>@ </em><a href="https://tecnico.ulisboa.pt/en/" target="_blank"><em>Técnico Lisboa</em></a>.

Company Mentioned

Mention Thumbnail
featured image - DevOps101: How To Provide Infrastructure To Your Startup In 6 Easy Steps
Rafael Belchior HackerNoon profile picture

I’m currently a teacher assistant 👨‍💻_@_ Técnico Lisboa, and I’m working closely with Dr. Professor Rui Cruz 👨‍🏫_at the_ It Infrastructure Management and Administration 🖥_, a_ masters level course @ Técnico Lisboa.

Why?

My experience as a professor opened my mind on how to use certain tools to achieve goals that me, as a student, want to reach. As a student, I’m responsible for a student’s group, GCE. Our project had some problems: it was very difficult and time-consuming to move from the conceptualization of an idea to its actually delivery.

A good, automated infrastructure was the answer to our problem. It allowed saving lots of time and effort, which translated into a better product delivered faster. This technique is meant for the ones that want to deliver as much as possible to the client as quickly as possible.

How?

Our app runs the MEAN stack. Feel free to check on this project’s repository, if you need some inspiration. One can achieve that by creating a pipeline in Heroku such:

  • We have three different apps for our three different environments (development, staging, and production).
  • All the apps have MongoLab installed, and a utility to manage logs (Papertrail).
  • Each app is linked with a branch of our repository

This allows for extreme flexibility. The workflow can be something like:

  1. Developer João creates a branch dedicated to implementing a matchmaking between companies and students — branch “matchmaking”.
  2. João codes all night.
  3. João makes a pull request to the branch “develop”. A battery of tests is run when the request is made (we didn’t implement this so far).
  4. Inês, a product manager, checks the pull request. Tests pass and she sees everything is fine. She accepts the pull request.
  5. By now, Heroku is building the development application — automatically.
  6. The whole team can see and interact with the new version of the product, in a test environment.
  7. When there is enough functionality on the branch “develop”, one pull request can be made to the branch “staging” (has an environment similar to production) and after that to the branch “master” (production).

At the end of the day, you have saved lots of precious minutes, which can be very representative in one semester.

Okay, I’m convinced. Let’s get to the action!

The idea is to have a virtual machine as the machine which will configure our infrastructure on Heroku, through Terraform. We will manage this virtual machine using Vagrant.

If you want to know how Terraform works, check this tutorial (up to “Requirements”, 1min read). You can achieve the same purpose without a virtual machine. In that case, skip directly to Step 2. What we will do is well condensed in the following scheme:

Step 1: Installing Vagrant

In this article, I show step by step how to configure it.

Step 2: Start the Virtual Machine

Now, open your console and run:

$ vagrant up --provision && vagrant ssh

The virtual machine is booting, installing all the required dependencies. This may take a while.

Wait a bit. Done. Nice. Kudos to you 👍

Step 3: Getting the Support Files

Fork this repository containing the support files and then clone it to your computer. Put it in the folder that is being synced with your guest machine.

Step 4: Analyse Terraform Files

Now, replace the GitHub repositories and Heroku credentials on the file terraform-vars.tfvars.

Notice what it’s being done on terraform-apps.tf.

Step 5: Authenticate in Heroku through the Cli

To authenticate, run:

$ heroku login --interactive

Put your credentials and login. Next, we need to generate an access token to Terraform to be able to communicate with Heroku. Run:

$ heroku authorizations:create

This will return you something like this:

Go to terraform-vars.tf and paste the token obtained in the field “heroku_api_key”.

Step 6: Initialize Terraform

By running:

$ terraform init

Step 7: Deploy Your Infrastructure

To know what you are going to deploy, run:

$ terraform plan

If everything is correct, run:

$ terraform apply --auto-aprove

The output should be similar to this

Congratulations, your infrastructure is on! 💯

Double check it on Heroku’s dashboard:

That looks fine. Don’t forget to add yourself as the owner of the pipeline

I recommend you to configure the deployment method on each app, by choosing a GitHub repository and associate it with a branch. For instance, we could associate the “develop” branch to the development app. When a commit occurs, it will be automatically deployed.

Destroying the infrastructure

With two commands you will end the experiment and shut down the virtual machine. These are:



$ terraform destroy -auto-approve$ exit$ vagrant halt

If you want to destroy the virtual machine you created, run:

$ vagrant destroy --auto-approve

Congratulations! 💯 You reached the end! 🦄

Next steps:

This is a very good infrastructure for MVPs, although it might not be the best in the long run. Nextly, I’m going to talk about Kubernetes and how we can deliver an infrastructure similar to this, but much more scalable. Stay tuned 😀

Entrepreneurship 🔥


My Journey As A Computer Science Student on Medium_And some tips on how to start writing._medium.com


Top 8 lessons I’ve learned in European Innovation Academy 2017_Imagine you are seeing the opportunity to improve yourself at every level. Would you take it?_blog.startuppulse.net