DEV Community

Oni Toluwalope
Oni Toluwalope

Posted on • Edited on

Learning DevOps: Setting Up a Local Workflow System Without the Cloud

DevOps has become an essential practice in modern software development and IT operations, with the cloud playing a significant role in enabling automation, scalability, and collaboration. However, cloud platforms often come with recurring costs and require an internet connection, which may not always be ideal for beginners or enthusiasts. Building your own personal setup provides an excellent alternative for learning DevOps concepts in a hands-on, cost-effective manner.

In this article, we’ll explore why a personal setup is valuable, what you need to set one up, and how to create your own DevOps practice setup without relying on the cloud. In the basic form of cloud computing, the main thing that makes the cloud different is accessing computing resources over the internet, so what if you could do the same on your PC without subscribing to a cloud provider.

Why Consider a Personal Setup Instead of the Cloud?

Advantages:
Cost Savings: No monthly subscription fees for cloud services. You can repurpose old hardware.
Offline Access: Learn and experiment even without an internet connection.
Privacy and Control: Complete ownership of your data and setup.
Hands-On Learning: Gain deeper insights into infrastructure, networking, and system administration by managing everything locally.

What you need to setup one

Essential Components of a Personal Setup

  1. Hardware Requirements
    PCs or Laptops: Ensure adequate RAM (8GB minimum), CPU (4 cores or more), and storage (SSD recommended).

  2. Software and Tools
    Virtualization Tools:
    VirtualBox for lightweight virtualization needs.
    VMware Workstation is another software for managing virtual machines.

Operating Systems
Linux distributions such as Ubuntu Server, CentOS, or Debian for hosting services.

Networking Tools and remote connection tools
OpenVPN or OpenSSH for remote access on your personal setup

  1. Tools for DevOps Practice

Version Control: Git for managing code.
CI/CD Pipelines: Jenkins, GitLab CI, or GitHub Actions.
Configuration Management: Ansible, Chef, or Puppet.
Infrastructure as Code (IaC): Terraform for provisioning infrastructure.
Monitoring and Logging: Prometheus, Grafana, and ELK stack.
Containerization Platforms:
Docker for running and managing containers.
Kubernetes (K3s or MicroK8s) for orchestrating containerized applications.

Setting Up Your Personal Setup (the real deal)

Step 1: Define Your Goals

First things first, determine what you want to achieve with your personal setup. Common goals include:
Learning Linux system administration.
Hosting a website or web software locally.
Practicing containerization and orchestration with Docker and Kubernetes.
Building and deploying CI/CD pipelines.
Exploring networking concepts.

Step 2: Set Up the Setup

The setup here will be for a web software
Prepare the Hardware:
Choose a machine
Ensure adequate RAM (8GB minimum), CPU (4 cores or more), and storage
If you are on a windows enable virtualization from your BIOS
Install a hypervisor like VirtualBox.
Install any of the linux distros as base operating system on the hypervisor, there are 2 ways you can go about this.
a. Install from scratch
Use a stable Linux distribution from scratch such as Ubuntu Server or Debian.
Configure SSH for remote access.

b. Install via osboxes.org, which is what we will be doing. Preconfigured images are found here( I advise you go for this, since it is faster and you will be using it for practice)

Select the VM images dropdown
Click on virtual box images at the top, it will take you to page with a list of operating systems.
Go to https://www.osboxes.org/ and download your preferred linux distro.
Image description

Select ubuntu on the new page (choose the distro of your choice).
Download VirtualBox (VDI) image
I am downloading Ubuntu in this case.
Image description
The good thing about osboxes is that it is very fast to install

Download the your preferred version. I am downloading the 24.10 Oracular Oriole, and my hardware is a 64bit version (choose what matches your hardware)
Take note of the username and password in the info section
Image description

Save and extract the OS image to a folder.

On the virtual box interface, click on new, name your OS and select its type and version.
Image description

The folder is where my VMs are stored, you can use any foler of your choice.
Image description

Next allocate memory (RAM- 2 or 4GB) and processors(you can use 2), that will be available for the new virtual machine, then click next
Image description

Select "Use an existing virtual hard disk file" and browse to the folder that contains the extracted disk image. The disk must be present in this path must be present for the machine to work.
Image description

Click Finish
Image description

Your new virtual machine has been created.
Image description

Right click on the new OS and click on settings
You can reset the processor, storage you want to allocate to the virtual machine.

NETWORK
Go to network
Set the network to bridged adapter, this helps the virtual machine to get its own IP address as well as connect to the internet.
Image description

Start the VM to test, configure the settings as desired, and install anything you will need for the other machines as this will serve as the base for other machines, then shut it down after testing, to create clones.
the password is at info section of the osboxes website

Example tools you might need to install:
Docker and Kubernetes:
check if openssh is present
Install Docker for containerization.
Set up Kubernetes (K3s for lightweight clusters).
Ansible, Jenkins or GitLab CI for building and applications.
And many more softwares required

type ifconfig to check for the ip address
if 'ifconfig' is not installed, follow the installation process. use

 sudo apt install net-tools
Enter fullscreen mode Exit fullscreen mode

Image description

run ifconfig again
I blocked you from seeing my ip address
Image description

check if openssh is present

sudo systemctl status ssh 
Enter fullscreen mode Exit fullscreen mode

If not, follow the following commands to install:

sudo apt update
Enter fullscreen mode Exit fullscreen mode

Install the OpenSSH server package with the following command:

sudo apt install openssh-server
Enter fullscreen mode Exit fullscreen mode

Check the status of the SSH service to ensure it's installed and running:

sudo systemctl status ssh
Enter fullscreen mode Exit fullscreen mode

Start the SSH service:

sudo systemctl start ssh
Enter fullscreen mode Exit fullscreen mode

Enable the SSH service to start on boot:

sudo systemctl enable ssh
Enter fullscreen mode Exit fullscreen mode

Check the status of the SSH service again to ensure it's installed and running:

sudo systemctl status ssh
Enter fullscreen mode Exit fullscreen mode

Image description

if it does not work as shown, follow the steps from the ssh section again.

shutdown the machine.

If you are on a windows machine, you can use mobaxterm to test and connect your VM via ssh.

CLONE THE VIRTUAL MACHINES

Right click on the newly created virtual machine and click clone.
Image description

name the first clone, I am naming mine "client machine" because that is what I intend to use as my local PC.
Ensure Generate new MAC addresses for all network adapters is selected
Image description

Click on linked clone(it saves space), then select finish
Image description

Repeat the cloning process for main-server, target-server1, target-server2. You will have something like at the end.
Remember: Generate new MAC addresses for all network adapters is selected
Image description

Sample setup
Start the client-machine and the target-server1.

let's change the name of the virtual machines from 'osboxes' to a preferred name. I am using 'clientmachine and targetserver1.

sudo nano /etc/hostname
Enter fullscreen mode Exit fullscreen mode

Image description

sudo nano /etc/hosts
Enter fullscreen mode Exit fullscreen mode

Image description
restart the machine and see the hostname change

open target-server1 machine and repeat the same steps, if you are familiar with ssh, login with ssh.

your output should look like this
Image description

Restart the machine and see the hostname change.
Image description

Next, follow this step-by-step guide to create a basic HTML website, test it locally, and then host it on your server with Nginx:
If you are familiar with creating basic HTML site and setting up nginx server, you can skip this part

create a basic html page on your client and test it.
Create the project folder:

mkdir my-website
cd my-website
Enter fullscreen mode Exit fullscreen mode

Create the HTML file: Create an index.html file in the my-website folder:

<!DOCTYPE html>
<html lang="en">
<head>
<title>Page Title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
  font-family: Arial, Helvetica, sans-serif;
}
</style>
</head>
<body>

<h1>My Website</h1>
<p>A website created by me.</p>

</body
</html>
Enter fullscreen mode Exit fullscreen mode

example from w3schools

Enter firefox index.html in the cli to view the website

  1. setup your server with this guide
  2. Access the server: Use SSH to access your server: you can access it directly since it is on your computer, but I advise you use ssh, so you learn how to get into a real cloud environment
ssh user@your-server-ip
Enter fullscreen mode Exit fullscreen mode
  1. Update and install necessary packages:

Update the system:

sudo apt update && sudo apt upgrade -y
Enter fullscreen mode Exit fullscreen mode

Install Nginx:

sudo apt install nginx -y
Enter fullscreen mode Exit fullscreen mode
  1. Verify Nginx installation: Start Nginx:
sudo systemctl start nginx
Enter fullscreen mode Exit fullscreen mode

Check the status:

sudo systemctl status nginx
Enter fullscreen mode Exit fullscreen mode

Step 3: Upload Your Website to the Server
Copy files to the server:
Use scp to upload your website files:

Ensure you run this command from the client machine when

scp -r my-website/* user@your-server-ip:/home/user/my-website/
Enter fullscreen mode Exit fullscreen mode

Move files to the Nginx directory:
SSH into the server and move the website files to the default Nginx web directory:

sudo mv /home/user/my-website/* /var/www/html/
Enter fullscreen mode Exit fullscreen mode

Step 4: Configure Nginx for Your Website
Edit the Nginx configuration:

Open the Nginx configuration file:

sudo nano /etc/nginx/sites-available/default
Enter fullscreen mode Exit fullscreen mode

Update the server block to look like this:

server {
    listen 80;
    server_name your-domain.com;

    root /var/www/html;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}
Enter fullscreen mode Exit fullscreen mode

Test the Nginx configuration:

sudo nginx -t
Enter fullscreen mode Exit fullscreen mode

Reload Nginx:

sudo systemctl reload nginx
Enter fullscreen mode Exit fullscreen mode

Step 5: Verify the Website on the Server
Open your server’s IP address (e.g., http://your-server-ip) in a browser. You should see your website. Your server ip is the one that is shown when you use the ifconfig command.

If you have a domain, point it to your server’s IP address by updating the domain’s DNS settings. After DNS propagation, you can access the site using your domain.

Take note that the IP that is being mapped to this domain must be consistent with the ip of your server at any point in time, so be sure to update the ip accordingly whenever there is a restart, shutdown of server or any event that can trigger a change in the ip of your server machine.

If you do not want to go through the stress of constantly updating the DNS on a global accessibility scale, you can simply limit the availability and change to your local client machine by updating its hosts files in the /etc/hosts file

sudo nano /etc/hosts
Enter fullscreen mode Exit fullscreen mode

Your output will be something like this
Image description

Run this system for other tools like ansible and kubernetes like you would have done on a cloud sever, using the main server and the target servers on local like you would on the cloud.

Top comments (0)