• This repository has been archived on 04/Mar/2021
  • Stars
    star
    146
  • Rank 251,243 (Top 5 %)
  • Language
    Shell
  • Created almost 5 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

k3s cluster backed by Flux (GitOps) up and running on a cluster of RPi4

IMPORTANT NOTE

This repository is really out of date, I have moved onto Flux v2 and do not use Raspberry Pis anymore. This is now archived and I will leave it up for people to read.

k3s-gitops-arm

Kubernetes

Discord

Build a Kubernetes (k3s) cluster with RPis and utilize GitOps for managing cluster state. I would like to give a shout-out to k8s-gitops, the big brother of this repo, created by @billimek.

This repo uses a lot of multi-arch images provided by raspbernetes/multi-arch-images.

Note: A lot of files in this project have @CHANGEME comments, these are things that are specific to my set up that you may need to change.


Prerequisites

Hardware

  • 3x Raspberry Pi 4 (recommended 4GB RAM model)
  • 3x SD cards (recommended 32GB)
  • 3x USB 3.x flash drives (recommended for local storage)
  • A NFS server for storing persistent data (recommended for shared storage)

Software

Note: I use the fish shell for a lot of my commands. Some will work in Bash but others will not, see here for more information.


Directory topology

.
├── ./ansible        # Ansible playbook to run after the RPis have been flashed
├── ./deployments    # Flux will only scan and deploy from this directory
├── ./setup          # Setup of the cluster
├── ./secrets        # Scripts to generate secrets for Sealed Secrets
└── ./docs           # Documentation

Network topology

image

IP Function
192.168.1.1 Router (USG)
192.168.1.170 NFS Server
192.168.42.1/24 k3s cluster CIDR, VLAN 42
192.168.42.23 k3s master (k3s-master)
192.168.42.24 k3s worker (k3s-worker-a)
192.168.42.25 k3s worker (k3s-worker-b)

Let's get started

1. Flash SD Card with Ubuntu

See ubuntu.md

2. Provision RPis with Ansible

Ansible is a great automation tool and here I am using it to provision the RPis.

See ansible.md and review the files in the ansible folder.

3. Install k3s on your RPis using k3sup

k3sup is a neat tool provided by @alexellis that helps get your k3s cluster up and running quick.

For manual deployment see k3sup.md, and for an automated script see bootstrap-cluster.sh

4. Flux and Helm Operator

Helm is a package manager for Kubernetes.

Flux is the GitOps tool I've chosen to have this Git Repository manage my clusters state.

For manual deployment see helm-flux.md, and for an automated script see bootstrap-cluster.sh

Additional Components

Sealed Secrets

Sealed Secrets are a "one-way" encrypted Secret that can be created by anyone, but can only be decrypted by the controller running in the target cluster. The Sealed Secret is safe to share publicly, upload to git repositories, give to the NSA, etc. Once the Sealed Secret is safely uploaded to the target Kubernetes cluster, the sealed secrets controller will decrypt it and recover the original Secret.

See sealed-secrets.md and review the files in the secrets folder.

MetalLB

MetalLB is a load-balancer implementation for bare metal Kubernetes clusters, using standard routing protocols.

Review the file metallb.yaml

Cert Manager

Cert-Manager will automatically provision and manage TLS certificates in Kubernetes. In this setup I am using Cloudflare as the DNS challenge.

NGINX Ingress /engine x/

NGINX Ingress Controller is an Ingress controller that uses ConfigMap to store the NGINX configuration.

Review the file nginx-ingress.yaml

More Repositories

1

home-ops

Wife approved HomeOps driven by Kubernetes and GitOps using Flux
Shell
1,912
star
2

cluster-template

A template for deploying a Talos Kubernetes cluster including Flux for GitOps
Python
1,757
star
3

exportarr

AIO Prometheus Exporter for Sabnzbd, Bazarr, Prowlarr, Lidarr, Readarr, Radarr, and Sonarr
Go
530
star
4

containers

My collection of container images
Dockerfile
287
star
5

k3s-homeops-ansible

Bootstrap a k3s cluster on top of Ubuntu 20.04
HTML
54
star
6

sops-pre-commit

Sops pre-commit hook
Jinja
41
star
7

home-operations

Highly opinionated Ansible playbooks, Ansible roles, and other things that are used to maintain my home-cluster
Dockerfile
28
star
8

unofficial-builds-for-vyos

Unofficial builds for VyOSâ„¢ - Because the cost to get LTS is too damn high for our Home Labs
26
star
9

home-service

My home service stack running on a Beelink EQ12 with Fedora IoT. These podman services are supporting my home infrastructure including, DNS and Kubernetes clusters.
Shell
25
star
10

intel-gpu-exporter

Python
23
star
11

dotfiles

My fish compatible dotfiles managed by chezmoi
Shell
15
star
12

gluctl

The glue that helps maintain a Kubernetes Home Lab
JavaScript
12
star
13

kubanetics

A container with various scripts for Kubernetes
Shell
12
star
14

qbittorrent-prune

Remove torrents from qBittorrent that are reported unregistered by a tracker
Shell
8
star
15

dns-in-a-bottle

AIO container for running bind, blocky and dnsdist
Dockerfile
6
star
16

hass-config

Home Assistant configuration for my home
Python
5
star
17

opnsense-coredns

A CoreDNS FreeBSD build specifically for OPNsense which includes some additional plugins
Dockerfile
5
star
18

qbittorrent-scripts

Python
4
star
19

sonarr-episode-prune

Delete episodes from specified series in Sonarr
Python
4
star
20

containers-mirror

Stop-gap container registry mirror of upstream applications that only use Docker Hub
Dockerfile
4
star
21

radarr-exporter

Prometheus Exporter for Radarr
Go
3
star
22

sonarr-exporter

Prometheus Exporter for Sonarr
Go
3
star
23

opaws

CLI tool to sign into AWS (MFA) accounts using 1Password
Shell
2
star
24

custom-error-pages

My custom error pages for the nginx-ingress controller
HTML
2
star
25

doks-cluster

Testing Flux with Digital Ocean Kubernetes Service
HCL
2
star
26

flux-repository-collection

A collection of various (Bucket|Git|Helm|OCI) Repositories for use with Flux
2
star
27

k3s-staging

Jinja
2
star
28

pi4-cluster-example

Test Flux2 GitOps Cluster
Shell
2
star
29

fcos-build

1
star
30

vyos-config

My VyOS configuration
1
star
31

makejinja-mjfilter-example

Python
1
star
32

draft-on-labels-action

GitHub Action to update a pull request to a draft based on labels
TypeScript
1
star
33

onedr0p.github.io

Support Devin
HTML
1
star
34

onedr0p

1
star
35

.github

1
star
36

container-images-refactor

1
star