GithubHelp home page GithubHelp logo

rdwinter2 / kubernetes-homelab Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lisenet/kubernetes-homelab

0.0 1.0 0.0 1.08 MB

Building a Kubernetes homelab

Home Page: https://www.lisenet.com/2021/install-and-configure-a-multi-master-ha-kubernetes-cluster-with-kubeadm-haproxy-and-keepalived-on-centos-7/

License: BSD 3-Clause "New" or "Revised" License

Mustache 28.56% Dockerfile 1.23% Jinja 28.14% HCL 33.64% Shell 8.43%

kubernetes-homelab's Introduction

kubernetes-homelab

A repository to keep resources and configuration files used with my Kubernetes homelab.

version license last commit commit activity

Content of the Repository

  • alertmanager - configuration files to deploy Alertmanager.
  • ansible - Ansible playbooks to deploy Kubernetes homelab.
  • calico - configuration files to deploy Calico CNI.
  • charts - Helm charts.
  • dashboard - configuration files to deploy Kubernetes dashboard.
  • docs - images and documentation files.
  • grafana - configuration files to deploy Grafana.
  • httpd-healthcheck - configuration files deploy a simple httpd healthcheck for Istio ingressgateway.
  • istio - configuration files to deploy Istio.
  • istio-addons - configuration files to deploy Istio add-ons (e.g. Kiali).
  • kube-state-metrics - configuration files to deploy kube-state-metrics.
  • kubecost - configuration files to deploy Kubecost.
  • metallb - configuration files to deploy MetalLB.
  • mikrotik-exporter - configuration files to deploy a Prometheus exporter for Mikrotik devices.
  • pii-demo - a demo PII application based on Apache, PHP and MySQL to test Istio's mTLS.
  • pii-demo-blue-green - a demo PII application based that uses blue/green deployment.
  • prometheus - configuration files to deploy Prometheus monitoring.
  • pxe - configuration files for PXE boot and Kickstart.
  • regcred - docker registry credentials.
  • terraform - configuration files to manage Kubernetes with Terraform.
  • truenas-nfs - configuration files to deploy democratic-csi with TrueNAS NFS.

Pre-requisites

A TrueNAS NFS server is required to create persistent volumes claims using democratic-csi.

Deployment

Ansible-defined Kubernetes Homelab

See ansible/README.md.

Manage Kubernetes Homelab with Terraform

See terraform/README.md.

Kubernetes Resources

Create a monitoring namespace:

$ kubectl apply -f ./monitoring-ns-istio-injection-enabled.yml

kube-state-metrics

Deploy kube-state-metrics:

$ kubectl apply -f ./kube-state-metrics

Prometheus

Create a secret called prometheus-cluster-name that contains the cluster name the Prometheus instance is running in:

$ kubectl -n monitoring create secret generic \
  prometheus-cluster-name --from-literal=CLUSTER_NAME=kubernetes-homelab

Deploy prometheus:

$ kubectl apply -f ./prometheus

Grafana

Deploy grafana:

$ kubectl apply -f ./grafana

Alertmanager

Alertmanager uses the Incoming Webhooks feature of Slack, therefore you need to set it up if you want to receive Slack alerts.

Update the config map alertmanager/alertmanager-config-map.yml and specify your incoming webhook URL. Deploy alertmanager:

$ kubectl apply -f ./alertmanager

Mikrotik-exporter

Update the secret file mikrotik-exporter/mikrotik-exporter-secret.yml and specify your password for the Mikrotik API user. Deploy mikrotik-exporter:

$ kubectl apply -f ./mikrotik-exporter

X509 Certificate Exporter

Deploy the Helm chart:

$ helm upgrade --install x509-certificate-exporter \
  ./charts/x509-certificate-exporter/ \
  --namespace monitoring \
  --debug

MetalLB

Update the config map metallb/metallb-config-map.yml and specify the IP address range. Deploy MetalLB network load-balancer:

$ kubectl apply -f ./metallb

Install Istio

The Istio namespace must be created manually.

$ kubectl create ns istio-system

The kubectl apply command may show transient errors due to resources not being available in the cluster in the correct order. If that happens, simply run the command again.

kubectl apply -f ./istio/istio-kubernetes.yml

Install httpd-healthcheck:

$ kubectl apply -f ./httpd-healthcheck

Install Istio Addons - Prometheus

$ kubectl apply -f istio-addons/prometheus

Install Istio Addons - Kiali

$ kubectl apply -f istio-addons/kiali

Create a Homelab ROOT CA

Create your own Certificate Authority (CA) for homelab environment. Run the following a CentOS 7 server:

$ vim /etc/pki/tls/certs/make-dummy-cert
$ openssl req -newkey rsa:2048 -keyout homelab-ca.key -nodes -x509 -days 3650 -out homelab-ca.crt

Create a Kubernetes Wildcard Cert Signed by the ROOT CA

$ DOMAIN=wildcard.apps.hl.test
$ openssl genrsa -out "${DOMAIN}".key 2048 && chmod 0600 "${DOMAIN}".key
$ openssl req -new -sha256 -key "${DOMAIN}".key -out "${DOMAIN}".csr
$ openssl x509 -req -in "${DOMAIN}".csr -CA homelab-ca.crt -CAkey homelab-ca.key -CAcreateserial -out "${DOMAIN}".crt -days 1825 -sha256

Blog Posts

Homelab Network Diagram

Homelab Network Diagram

Average Kubernetes Homelab Power Consumption

~80W

Monthly, my homelab costs (((80W * 24h) / 1000) * £0.16/kWh * 365days) / 12months = £9.34 (~13$).

kubernetes-homelab's People

Contributors

lisenet avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.