Skip to content

Latest commit

 

History

History
122 lines (89 loc) · 4.38 KB

README.md

File metadata and controls

122 lines (89 loc) · 4.38 KB

Pi Infrastructure

Repository for managing infrastructure as code and containerized applications in a k3s cluster deployed on a Raspberry Pi setup. Experimenting with lightweight Kubernetes and localized development.

image

What's hosted?

I got tired of having to pick what to eat for dinner each month, thus recipe-maker was born. recipe-maker selects and renders a month's worth of recipes, including related grocery list. Executes in two modes: server deployment, and email cronjob.

Server deployment:

Deployed on k3s using a Deployment + NodePort Service. This allows viewing this month + next month's meals from my phone, laptop, or tablet by hitting the same URL. Links are clickable for finding related recipes.

Screenshot from 2024-09-28 15-54-16

Email CronJob:

Deployed on k3s using a CronJob. Every Friday, finds next week's recipes and compiles a grocery list for all items, combining like items by quantity, and assigning each item to its respective aisle. This is then formatted and emailed to me and my partner. | image

|

Data:

Recipes are stored in a JSON file in a private repository shared with my partner. This repo has CI/CD setup to validate the contents, and push the JSON file's latest state to S3. This state is then pulled by the recipe-maker.

While we could just pull from the GitHub repo itself, CD in this way is far more fun! | Screenshot from 2024-09-28 13-27-38

|


I (too often) leave for work, round the corner, and immediately second guess whether I closed the garage door. So, I fixed this concern.

This Garage door monitoring system uses a Raspberry Pi 2 W hooked up with a magnetic door sensor. The magnetic door sensor detects when the garage door is in the "closed" position. Metrics are exposed via a Prometheus exporter, which are scraped by a Prometheus deployment I'm using across these projects. Finally, a dashboard is available to view the yes/no question through Grafana.

image

Note: Getting started with the Hardware portion, particularly reading the state of the GPIO pin, was super doable thanks to this book Automate Your Home Using Go


Setup

Ansible install: $ sudo apt install ansible-core

Terraform install: https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli#install-terraform

Required non-checked files:

  • ansible/inventory/pi:

    [common]
    <FILL IN>
    
    [artifactors]
    <FILL IN>
    
    [all:vars]
    ansible_python_interpreter=/usr/bin/python3
    
    
  • ansible/roles/common/vars/vars.yml:

    pub_ssh_key_path: <FILL IN>
    
  • ansible/roles/workers/vars/vars.yml:

    k3s_token: <FILL IN>
    k3s_url: <FILL IN>
    
  • terraform/nexus/local.tfvars:

    nexus_url = <FILL IN>
    nexus_username = <FILL IN>
    nexus_password = <FILL IN>
    nexus_docker_repo_port = <FILL IN>
    

Can I see the cluster?

Sure! Mind the dust 😹 image_123650291