DevOps

In this year we will be learning and exploring devops as one of our development goals.

What is DevOps?

DevOps is an amalgamation of two terms  – developers and operations.

Development here refers to idea till you build your idea into a product or service.

Operations include everything after you have built your product. That  means you are thinking about system administration,deployment,monitoring,security etc.

In this journey on learning devops, we will be using the pareto principle(80/20) rule to master the most useful and industry needed tools and technologies. We will concentrate on workflows not just tools.

Our Plan and Workflow

  • Installation
  • Basic Usage
  • Advanced Usage
  • Building Something
  • Teaching and Sharing What You’ve learn

Tools To Master

  • Linux Bash
  • Programming Languages(Python,Bash,Go,Nodejs,Julia)
  • Git/Github/Bitbucket
  • Docker
  • Kubernetes
  • Hashicorp Tools
  • Cloud Computing
  • GCP,AWS,Azure
  • Heroku
  • Nginx
  • Automation

Setting Up Our WorkSpace Locally

We will be setting up a workspace or a lab for our devops journey. So let us see what we will need for our workspace.

Linux – Ubuntu

  • Gemu-KVM
  • Docker -CE
  • Minikube/Kubernetes
  • Git
  • Heroku
  • OpenSSH

Windows

  • Hypervisor/VirtualBox
  • Windows Terminal or CMDer or Putty
  • WSL
  • Docker/Kubernetes
  • etc
How to Install Docker on Ubuntu

Docker is a containerization software for building containers and images that virtualized  the entire process you would have used a hardware for.

Installing Docker
sudo apt install apt-transport-https ca-certificates curl software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Verify Fingerprint

sudo apt-key fingerprint 0EBFCD88

Add Docker to Apt Repo Locally

sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

Update,Download and Install Docker Community Edition

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

Check Status of Docker

 sudo systemctl status docker
Installing Virtual Manager or Virtualization

Let us check to see if our system has virtualization enabled with this code before installing kubernetes.

grep -E –color ‘vmx|svm’ /proc/cpuinfo

If there is an empty output, that means you have virtualization enabled other wise you will have to enable virtualization.

Installing QEMU-KVM – Virtual Machine Manager

Let us install Qemu-KVM a virtual machine manager on our system.

sudo apt-get install qemu-kvm qemu virt-manager virt-viewer libvirt-bin

To start your virtual manager you can type

sudo virt-manager

You can then add the various OS as you wish

Installing VirtualBox on Ubuntu

You can also install virtualbox instead of KVM. Both are virtualization softwares that achieve the same thing. You can install virtualbox using either the software manager or via the commandline

sudo add-apt-repository multiverse && sudo apt-get update
sudo apt install virtualbox
How to Install Kubernetes or Minikube on Ubuntu

To work with kubernetes and minikube you will need to have virtualization enabled and then install kubectl as follows

Download Kubectl

curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl

Make the kubectl binary executable.

chmod +x ./kubectl

Move the binary in to your PATH.

sudo mv ./kubectl /usr/local/bin/kubectl

Test to ensure the version you installed is up-to-date:

kubectl version

Via Package Manager

Or You can use the second method via the package manager


sudo apt-get update && sudo apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl
Installing Minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
&& chmod +x minikube

How to add the Minikube executable to your path

sudo mkdir -p /usr/local/bin/
sudo install minikube /usr/local/bin/

Checking If minikube was installed

minikube

How to Add A VM Driver for minikube

There are several vm drivers that minikube support such as

minikube start --vm-driver=<driver_name>
minikube start --vm-driver=<kvm2>

Go For Infrastructure

The Go programming language is very popular among the devops world and usually useful for infrastructure production and management. Hence we will have to add that know-how to our arsenal of skills.

Installing Go Lang on Ubuntu

Method 1 : Using Snap or Apt-get

sudo snap install go # version 1.13.5, or
sudo snap info go # for more info about versions

Method 2 : Using  Apt-get

sudo apt install golang-go
sudo apt install gccgo-go

Method 3: Using The Downloaded tarball file

We will be downloading Go from their official website either manually or with curl

cd ~
curl -O https://dl.google.com/go/go1.13.5.linux-amd64.tar.gz

Extract in the Home Directory

tar xvf go1.13.5.linux-amd64.tar.gz

Create a go directory with our file and move that directory to the /usr/local

mkdir go

Move to /usr/local

sudo chown -R root:root ./go
sudo mv go /usr/local

Adding /Setting Go To Paths
First, set Go’s root value, which tells Go where to look for its files inside the .profile file

sudo nano ~/.profile

At the end of the file, add this line:

export GOPATH=$HOME/work
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin

If you chose an alternate installation location for Go, add these lines instead to the same file. This example shows the commands if Go is installed in your home directory:

export GOROOT=$HOME/go
export GOPATH=$HOME/work
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

With the appropriate line pasted into your profile, save and close the file

Finally, refresh your profile by running:

source ~/.profile

You are good to go

Working With GCP

GCP – Google Cloud Platform

Installing GCP SDK

Using Apt-Get(For Debian and Ubuntu)

echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
sudo apt-get install apt-transport-https ca-certificates gnupg
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt-get update && sudo apt-get install google-cloud-sdk
sudo apt-get install google-cloud-sdk-app-engine-python

You can now initialize it with the

gcloud init