Post

Wife Said No Server Rack

Welcome to our latest guide, designed for experienced sysadmins and DevOps engineers who wish to set up a compact homelab without the need for a server rack. This tutorial will.

# Wife Said No Server Rack: A Compact Homelab Solution for DevOps Enthusiasts

Welcome to our latest guide, designed for experienced sysadmins and DevOps engineers who wish to set up a compact homelab without the need for a server rack. This tutorial will walk you through creating a self-hosted infrastructure using open-source tools for automation and management. Let’s get started!


Prerequisites

Before diving into the solution, make sure you have the following prerequisites:

  1. Ubuntu 20.04 LTS (Focal Fossa): This tutorial is optimized for this Ubuntu version. You can download it from official Ubuntu website.

  2. Docker CE v5.0.8: Docker provides the foundation for our self-hosted infrastructure. You can install it using the following command:
    1
    
    apt update && apt install docker-ce=5.0.8 -y
    

    Note that this version is specific to Ubuntu 20.04 LTS.

  3. Docker Compose v1.27.4: Docker Compose simplifies defining and running multi-container Docker applications. Install it with:
    1
    
    apt install docker-compose=1.27.4 -y
    

Solution

Follow these numbered steps to set up your compact homelab solution.

1. Create a new directory for your project and navigate into it:

1
   mkdir homelab && cd homelab

2. Create a docker-compose.yml file with the following content (explained in subsequent steps):

1
2
3
4
5
6
7
version: '3.8'
services:
  # Your services go here

networks:
  homelab_net:
    driver: bridge

3. Define your services:

  • GitLab Runner: This service will be responsible for executing CI/CD jobs for your projects.
  • Prometheus: Monitor your homelab with this open-source system monitoring and alerting tool.
  • Grafana: Visualize your data using Grafana’s intuitive dashboards.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
services:
  gitlab-runner:
    image: docker.io/docker/docker:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ${GITLAB_RUNNER_HOME}:/${GITLAB_RUNNER_HOME}
    environment:
      GITLAB_REGISTRATION_TOKEN: YOUR_TOKEN # Replace this with your GitLab Runner registration token.
    deploy:
      mode: global
    networks:
      homelab_net: {}

  prometheus:
    image: prom/prometheus:v2.25.1
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml # Update this path with your Prometheus configuration file.
    ports:
      - "9090:9090"
    networks:
      homelab_net: {}

  grafana:
    image: grafana/grafana:7.5.4
    volumes:
      - ./grafana.ini:/etc/grafana/grafana.ini # Update this path with your Grafana configuration file.
    ports:
      - "3000:3000"
    networks:
      homelab_net: {}

4. Verify that Docker Compose is working correctly:

1
   docker-compose up --verbose

This command will start your services and display verbose output to help troubleshoot issues if they arise.


Troubleshooting

If you encounter any errors, double-check the following:

  1. Ensure that you have correctly configured your docker-compose.yml file.
  2. Verify that the specified versions of Docker CE and Docker Compose are installed correctly.
  3. Make sure that the GitLab Runner registration token is correct.
  4. Check the configuration files for Prometheus and Grafana if you’re having issues with those services.

Conclusion

With this compact homelab solution, you can continue to develop your DevOps skills without requiring a dedicated server rack. By using open-source tools such as Docker, Docker Compose, Prometheus, and Grafana, you have a self-hosted infrastructure that allows for automation and monitoring of your projects. Keep in mind potential security considerations when exposing services to the internet, and don’t forget to optimize performance wherever possible. Happy DevOps-ing!

This post is licensed under CC BY 4.0 by the author.