Preface
WARNING Currently longhorn does not support kubernetes 1.25 ( automatic upgrades have been disabled due to this for the future as well. Going to do it manually )
This repository contains basic HELM local charts for application installation as well as FluxCD2 HelmReleases for GitOps. I'm not going to move away from the local helm charts where possible as they make this repository pretty beginner-friendly.
๐ Check out the Documentation
๐ Getting Started
Main tools used
- FluxCD 2 - GitOps for my HomeLab.
- Renovate - Checks for updates to actions, helm charts, helm releases, docker containers.
- ingress-nginx - Kubernetes ingress. This is used to access services using reverse proxy instead of exposing them on a port.
- cert-manager + reflector - cert-manager generates certificates for my services and reflector duplicates the generated ssl
certificate secret to all the namespaces. The secret is called
ingress
. - Longhorn - K8S native storage.
- SimpleSecrets - Kubernetes secret manager.
- Calico - Provides Networking for my HomeLab
- Ansible - Used to provision the architecture
- Velero - K8S and PVC backup. Free and open source by VMware
- Kube-vip - For a Virtual IP that I can use to access all my servers
๐ง
GitOps GitOps is applied wherever possible using Flux2. CI/CD is done by bootstrapping flux into my cluster. Flux polls GitHub for changes and applies them automatically on my server. It is currently pretty stable and works fine
Image updates
Image updates are done via Renovate Bot
Accessing services ( ingress-nginx, cert-manager )
Apps are currently exposed by ingress-nginx and have SSL certificates provided by cert-manager.
A wildcard certificate is issued for my domain *.stefangenov.site
and when the secret is created
it is replicated in all namespace as ingress
to be consumed by the ingress resources. This replication is
needed because Let's encrypt
rate limits certificate requests.
๐ฅ๏ธ Exposing Apps
As a legacy approach I used to expose my apps via NodePort. This ability is removed but can be easily enabled by removing the commented out nodePort values in the Helm Charts, and I also try to add this functionality to future apps and services I install.
Storage ( Longhorn )
Longhorn is a great replicated storage option with a great UI for better visualisation. It's fast and tailor made for k8s. Developed by the same people responsible for k3s/rancher and other great tools. Official site
Networking ( Calico CNI )
Calico is a great and mature CNI/IPAM software that is fast, scalable and feature rich. Source code
SimpleSecrets ( Secrets Management )
This is a tool that I've been developing in my spare time. It is not audited or tested by security professionals !
It allows for you to store secrets via the UI/API and create K8S Secrets by creating a SimpleSecrets object instead, allowing
me to commit SimpleSecrets
to git, while not exposing anything to the internet.
Backup ( Velero )
Velero allows me to back up selected namespaces and ( with the help of restic ) ship the data to different sources. In my case I'm using the velero AWS plugin.
The velero backup runs on a schedule every day during the evening hours and I pay around ~ $4 each month
What if I don't want to use Flux
Well it's absolutely fine. You can go to Helm/apps
and install any app you want ( e.g. helm install media media -n media --create-namespace
).
However things like ingress, cert-management, longhorn are handled only via Flux. Information on the helm chart that is
used can be found in the helm-release.yaml
for the specific service. Let's look at an example:
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: longhorn-system # What to call the deployment
namespace: longhorn-system # Where to install the helm chart
spec:
interval: 5m # How often do we poll for changes
install:
createNamespace: true # Same as --create-namespace
chart:
spec:
chart: longhorn # Which chart to use
version: 1.2.4 # Which version of the chart
interval: 5m
# Where to find information for this chart ( in my case I have a HelmRepository defined in cluster/homelab/helm/longhorn-system
sourceRef:
kind: HelmRepository
name: longhorn-system
namespace: flux-system
# Overwriting some values
values:
ingress:
enabled: true
host: longhorn.stefangenov.site
ingressClassName: nginx
tls: true
tlsSecret: ingress
service:
ui:
type: NodePort
nodePort: 30030
This would be the same as:
-
Creating a new file with the content:
values.yaml
:ingress: enabled: true host: longhorn.stefangenov.site ingressClassName: nginx tls: true tlsSecret: ingress service: ui: type: NodePort nodePort: 30030
-
Running:
helm repo add longhorn https://charts.longhorn.io; helm repo update
to add the longhorn helm repo -
Running:
helm install longhorn/longhorn --name longhorn --create-namespace -n longhorn-system -f values.yaml