Skip to content

A lightweight DevOps platform for home servers using Raspberry Pi and Kubernetes. This platform enables easy deployment, scaling, and management of containerized applications on low-cost hardware. Ideal for learning Kubernetes, automating home projects, or running self-hosted services with minimal resources.

License

Notifications You must be signed in to change notification settings

n4en/devops-on-pi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DevOps on Pi

A lightweight DevOps platform for home servers using Raspberry Pi and Kubernetes. This platform enables easy deployment, scaling, and management of containerized applications on low-cost hardware. It is ideal for learning Kubernetes, automating home projects, or running self-hosted services with minimal resources.

Prerequisites

  • Raspberry Pi 4 (recommended 4GB or 8GB RAM)
  • Raspberry Pi OS (64-bit recommended for better performance)
  • MicroSD card (32GB or larger recommended)
  • Power supply (5V/3A recommended for Pi 4)
  • Network connection (Ethernet or WiFi)

System Requirements

  • Minimum: 2GB RAM, 16GB storage
  • Recommended: 4GB+ RAM, 32GB+ storage
  • OS: Raspberry Pi OS 64-bit (Bullseye or newer)

Installation Guide

1. Initial System Setup

First, ensure your Raspberry Pi is up to date:

sudo apt update && sudo apt upgrade -y
sudo apt install git curl wget -y

2. Configure cgroups (Required for Kubernetes)

K3s requires cgroups to be enabled. Run the setup script:

chmod +x Scripts/setup_cgroups.sh
sudo ./Scripts/setup_cgroups.sh

Note: This script modifies /boot/firmware/cmdline.txt to enable memory cgroups. A reboot is required after this step.

3. Reboot the System

sudo reboot

4. Install K3s (Lightweight Kubernetes)

After rebooting, install K3s:

curl -sfL https://get.k3s.io | sh -

Wait for K3s to start (usually takes 1-2 minutes), then verify installation:

sudo k3s kubectl get nodes

5. Configure kubectl Access

Set up kubectl to work with your user account:

sudo chmod 644 /etc/rancher/k3s/k3s.yaml
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml

To make this permanent, add to your shell profile:

echo 'export KUBECONFIG=/etc/rancher/k3s/k3s.yaml' >> ~/.bashrc
# Or for zsh:
echo 'export KUBECONFIG=/etc/rancher/k3s/k3s.yaml' >> ~/.zshrc

6. Install ArgoCD (GitOps Platform)

Create the ArgoCD namespace and install it:

kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

Wait for all pods to be ready:

kubectl get pods -n argocd

7. Access ArgoCD

Option A: NodePort (Recommended for home setup)

kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "NodePort"}}'

Get the NodePort:

kubectl get svc argocd-server -n argocd

Access ArgoCD at: https://<YOUR_PI_IP>:<NODEPORT>

Option B: Port Forward (Alternative)

kubectl port-forward svc/argocd-server -n argocd 8080:443

Access ArgoCD at: https://localhost:8080

8. Get ArgoCD Admin Password

kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d

Default username: admin

9. Install ArgoCD CLI (Optional)

curl -sSL -o argocd-linux-arm64 https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-arm64
sudo install -m 555 argocd-linux-arm64 /usr/local/bin/argocd
rm argocd-linux-arm64

Login via CLI:

argocd login <YOUR_PI_IP>:<NODEPORT>

10. Add Helm Repository (Optional)

argocd repo add https://charts.bitnami.com/bitnami --type helm --name bitnami

Optional Tools

Enhanced Shell Setup

Install Zsh

sudo apt install zsh -y

Install Oh My Zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Install Zsh Plugins

# Autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

# Syntax highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

# Completions
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions

Configure Zsh Plugins

Edit ~/.zshrc and add plugins:

plugins=(git zsh-autosuggestions zsh-syntax-highlighting zsh-completions)

Troubleshooting

Common Issues

1. Memory Cgroup Error

Error: Failed to find memory cgroup: You may need to add "cgroup_memory=1 cgroup_enable=memory"

Solution:

  • Ensure you ran the cgroups setup script
  • Reboot the system: sudo reboot
  • Verify cgroups are enabled: cat /boot/firmware/cmdline.txt

2. K3s Not Starting

Check logs:

sudo journalctl -u k3s -f

Common fixes:

  • Ensure enough disk space: df -h
  • Check memory: free -h
  • Verify network connectivity

3. ArgoCD Pods Not Ready

Check pod status:

kubectl get pods -n argocd
kubectl describe pods -n argocd

Common solutions:

  • Wait longer (first startup can take 5-10 minutes)
  • Check resource usage: kubectl top nodes
  • Restart ArgoCD: kubectl delete pods -n argocd --all

Enable Traefik Dashboard (Optional)

If you want to access the Traefik dashboard:

  1. Edit the Traefik configuration:
sudo nano /var/lib/rancher/k3s/server/manifests/traefik.yaml
  1. Add dashboard configuration:
api:
  dashboard: true
  insecure: false

additionalArguments:
  - "--api.dashboard=true"
  - "--api=true"
  - "--entrypoints.websecure.http.tls=true"
  1. Create an IngressRoute for the dashboard:
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: traefik-dashboard
  namespace: kube-system
spec:
  entryPoints:
    - web
  routes:
    - match: PathPrefix(`/dashboard`) || PathPrefix(`/api`)
      kind: Rule
      services:
        - name: api@internal
          kind: TraefikService
  1. Access the dashboard:
curl http://<YOUR_PI_IP>:8080/dashboard/

Next Steps

  1. Deploy your first application using ArgoCD
  2. Set up monitoring with Prometheus and Grafana
  3. Configure persistent storage for your applications
  4. Set up backups for your cluster configuration
  5. Explore the ecosystem of Kubernetes applications

Security Notes

  • Change default passwords
  • Use HTTPS for all web interfaces
  • Regularly update your system and applications
  • Consider using a firewall
  • Keep your cluster behind a router with NAT

Support

For issues and questions:

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A lightweight DevOps platform for home servers using Raspberry Pi and Kubernetes. This platform enables easy deployment, scaling, and management of containerized applications on low-cost hardware. Ideal for learning Kubernetes, automating home projects, or running self-hosted services with minimal resources.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages