Skip to content

rxbn/k8s-gitops

Repository files navigation

k8s-gitops

Kubernetes

📢  About

This repository contains my entire Kubernetes cluster setup built on K3s and managed by Flux v2.
Secrets are encrypted and managed with SOPS.

📂  Repository Structure

This Git Repository contains the following directories and are ordered below by how Flux will apply them:

  • core directory is where Flux deployments are located
  • crds directory (depends on core) contains CustomResourceDefinitions that need to exist before anything else
  • infra directory (depends on crds) contains infrastructure applications such as ingress-nginx, MetalLB and so on
  • base directory (depends on infra) contains applications that are useful for cluster operations such as kube-prometheus-stack, K8up and so on
  • apps directory (depends on base) is where common applications are located

These directories are not tracked by Flux but are useful nonetheless:

  • .github directory contains GitHub related files
  • .taskfiles directory contains go-tasks
  • hack directory contains useful scrips

↩️  Install pre-commit Hooks

Install all pre-commit hooks so they are executed every time before a commit occurs.

pre-commit install --hook-type pre-commit

🔧  Initial Deployment

  1. Install K3s
  2. Install Cilium
  3. Create flux-system namespace
    kubectl create namespace flux-system
  4. Apply sops private key secret
    kubectl apply -f sops-secret.yaml
  5. Apply cluster-settings configmap
    kubectl apply -f core/cluster-settings.yaml
  6. Bootstrap cluster (may needs to be executed twice)
    kubectl apply --kustomize=./core/flux-system

🤖  Automation

  • Renovate is a very useful tool that when configured will start to create PRs in your GitHub repository when Docker images, Helm charts or anything else that can be tracked has a newer version. The configuration for Renovate is located here

There are also a couple GitHub workflows included in this repository that will help automate some processes.

🤗  Thanks

Huge thanks to the community at k8s@home for the awesome templates and the Kubernetes at home logo!