This commit is contained in:
2023-05-08 21:41:45 +02:00
parent d79ddef5a8
commit 3efaf3000f
9 changed files with 84 additions and 52 deletions

View File

@@ -1,6 +1,6 @@
--- ---
title: "Setup a HA Kubernetes cluster for less than $60 / month" title: "Setup a HA Kubernetes cluster for less than $60 / month"
date: 2022-12-08 date: 2023-06-08
description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..." description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..."
tags: ["kubernetes"] tags: ["kubernetes"]
draft: true draft: true
@@ -14,16 +14,16 @@ Build your self-hosted Kubernetes cluster and be free from any SaaS solutions by
This guide is mainly intended for any developers or some SRE who want a Kubernetes cluster that respect following conditions : This guide is mainly intended for any developers or some SRE who want a Kubernetes cluster that respect following conditions :
1. Free from any big cloud providers (AWS, GCP, Azure) which offers managed Kubernetes 1. On-Premise management (The Hard Way), no managed Kubernetes provider
2. Completely bare-metal and self-hosted, with some GitOps way steps 2. Follow the GitOps principles
3. High availability with cloud Load Balancer 3. High availability with cloud Load Balancer and resilient storage and DB
4. Not too much expensive (targeting between $30 and $50 depending on your needs). 4. Fully monitored
5. Complete CI/CD pipeline
I will not risk saying that it's production ready, but I think it's at least a very good way to build your own bare-metal Kubernetes platform and quick learning all his ecosystem with practice. 6. Not too much expensive (from $30 to $70 /month depending on your needs)
### You may don't need Kubernetes ### You may don't need Kubernetes
If you prefer to stay away of all overwhelming Kubernetes features, but always interested in a very simple self-hosted orchestration platform, keep in mind that **Docker Swarm** is probably the best solution for you. It should be always supported as long as Docker CE live, as it's built in into the Docker Engine, and it's far easier and cheaper to maintain it than K8S. If you prefer to stay away of all overwhelming Kubernetes features, but just interested in a very simple self-hosted orchestration platform (as 99% of any personal usage), keep in mind that **Docker Swarm** is probably the best solution for you. Don't listen people that say it's outdated, because [it's not](https://dockerlabs.collabnix.com/intermediate/swarm/difference-between-docker-swarm-vs-swarm-mode-vs-swarmkit.html) and will always be supported as long as Docker CE live, as it's built in into the Docker Engine, and it's far easier and cheaper to maintain it than K8S. The downside is that there is no longer any new features added to Swarm.
I wrote a [complete dedicated guide here]({{< ref "/posts/02-build-your-own-docker-swarm-cluster" >}}) that explains all steps in order to have a production grade Swarm cluster. I wrote a [complete dedicated guide here]({{< ref "/posts/02-build-your-own-docker-swarm-cluster" >}}) that explains all steps in order to have a production grade Swarm cluster.
@@ -31,37 +31,70 @@ I wrote a [complete dedicated guide here]({{< ref "/posts/02-build-your-own-dock
As a HA Kubernetes cluster can be quickly expensive, a good cloud provider is an essential part. As a HA Kubernetes cluster can be quickly expensive, a good cloud provider is an essential part.
After testing Digital Ocean, Vultr, Linode, Civo (which is completly optimized for Kubernetes), OVH, Scaleway, it becomes very clear that nothing can really compete with Hetzner in terms of QoS for that price **in my opinion** : After testing many providers, as Digital Ocean, Vultr, Linode, Civo , OVH, Scaleway, it seems like **Hetzner** is very well suited **in my opinion** :
* Very competitive price for middle-range performance (plan only around **$6** for 2CPU/4GB for each node) * Very competitive price for middle-range performance (plan only around **$6** for 2CPU/4GB for each node)
* Cloud Load Balancer, VPC and Firewall support, so no need to reinvent the wheel for these cases * No frills, just the basics, VMs, block volumes, load balancer, DNS, firewall, and that's it
* Very good UI, and with dark mode support which of course absolutely mandatory for my taste * Simple nice UI + CLI tool
* Perfect CLI tool
* cert-manager [DSN01 challenge support](https://github.com/vadimkim/cert-manager-webhook-hetzner) (but not official)
* Official [Terraform support](https://registry.terraform.io/providers/hetznercloud/hcloud/latest), so GitOps ready * Official [Terraform support](https://registry.terraform.io/providers/hetznercloud/hcloud/latest), so GitOps ready
* cert-manager [DSN01 challenge support](https://github.com/vadimkim/cert-manager-webhook-hetzner)
Please let me know in below comments if you have other better suggestions ! Please let me know in below comments if you have other better suggestions !
### Requirements
## Final goal 🎯
TODO
### 1. Cluster & routing 🌍
Cluster + Traefik
### 3. Databases & testing with some apps 💾
### 5. Monitoring 📈
### 6. CI/CD setup 💻
Concourse / FluxCD
## Cluster Architecture 🏘️ ## Cluster Architecture 🏘️
Note as this cluster will be intended for developer user with complete self-hosted CI/CD solution. So for a good cluster architecture starting point, we can imagine the following nodes :
| server | description |
| --------------- | ----------------------------------------------------------------------------------------------------- |
| `controller-0x` | The control planes nodes, use at least 3 or any greater odd number (when etcd) for HA kube API server |
| `worker-0x` | Workers for your production/staging apps, at least 3 for running Longhorn for resilient storage |
| `data-0x` | Data nodes for any DB / critical statefulset pods |
| `monitor-0x` | Workers dedicated to monitoring |
| `runner-0x` | Workers dedicated to CI/CD pipelines execution |
```mermaid
flowchart TD
lb((Load Balancer))
subgraph worker-01
traefik-01([Traefik])
apps-01[Apps]
longhorn-01[/Longhorn/]
traefik-01 --> apps-01
longhorn-01 --> apps-01
end
subgraph worker-02
traefik-02([Traefik])
apps-02[Apps]
longhorn-02[/Longhorn/]
traefik-02 --> apps-02
longhorn-02 --> apps-02
end
subgraph worker-03
traefik-03([Traefik])
apps-03[Apps]
longhorn-03[/Longhorn/]
traefik-03 --> apps-03
longhorn-03 --> apps-03
end
lb --> traefik-01
lb --> traefik-02
lb --> traefik-03
subgraph data-01
postgresql[(PostgreSQL Primary)]
end
subgraph data-02
postgresql-replica[(PostgreSQL Replica)]
end
apps-01 --> postgresql
apps-02 --> postgresql
apps-03 --> postgresql
postgresql --> postgresql-replica
```
## Cheap solution with Hetzner VPS 🖥️ ## Cheap solution with Hetzner VPS 🖥️
## Lets party 🎉 ## Lets party 🎉

View File

@@ -1,6 +1,6 @@
--- ---
title: "Setup a HA Kubernetes cluster Part II - Cluster initialization with Terraform" title: "Setup a HA Kubernetes cluster Part II - Cluster initialization with Terraform"
date: 2022-12-09 date: 2023-06-09
description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..." description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..."
tags: ["kubernetes", "terraform", "hetzner", "k3s", "gitops"] tags: ["kubernetes", "terraform", "hetzner", "k3s", "gitops"]
draft: true draft: true

View File

@@ -1,8 +1,8 @@
--- ---
title: "Setup a HA Kubernetes cluster Part III - Ingress & HA storage" title: "Setup a HA Kubernetes cluster Part III - Ingress & HA storage"
date: 2022-12-10 date: 2023-06-10
description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..." description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..."
tags: ["kubernetes", "traefik", "cert-manager", "longhorn", "minio", "s3"] tags: ["kubernetes", "traefik", "cert-manager", "longhorn"]
draft: true draft: true
--- ---
@@ -12,8 +12,7 @@ Build your self-hosted Kubernetes cluster and be free from any SaaS solutions by
1. Traefik & cert-manager 1. Traefik & cert-manager
2. Resilient Storage with Longhorn 2. Resilient Storage with Longhorn
3. Samples with Portainer & Minio 3. Test with PgAdmin (valid both ingress and storage)
4. S3 Backup with longhorn
## 2nd check ✅ ## 2nd check ✅

View File

@@ -1,8 +1,8 @@
--- ---
title: "Setup a HA Kubernetes cluster Part IV - Databases with HA & backups" title: "Setup a HA Kubernetes cluster Part IV - Databases with HA & backups"
date: 2022-12-11 date: 2023-06-11
description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..." description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..."
tags: ["kubernetes", "mysql", "postgresql", "minio", "restic"] tags: ["kubernetes", "postgresql", "longhorn"]
draft: true draft: true
--- ---
@@ -11,10 +11,11 @@ Build your self-hosted Kubernetes cluster and be free from any SaaS solutions by
{{< /lead >}} {{< /lead >}}
1. Add data-01 node 1. Add data-01 node
2. MySQL and PostgreSQL 2. PostgreSQL
3. Web management apps with PMA & PGA 3. Access through PgAdmin
4. Job backups 4. Job backups
5. Clustering with additional data-02 and postgreSQL cluster 5. S3 Backup with longhorn
6. Clustering with additional data-02 and postgreSQL cluster
## 3rd check ✅ ## 3rd check ✅

View File

@@ -1,8 +1,8 @@
--- ---
title: "Setup a HA Kubernetes cluster Part V - Installing some apps & NoCode tools" title: "Setup a HA Kubernetes cluster Part V - Installing some apps & NoCode tools"
date: 2022-12-13 date: 2023-06-13
description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..." description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..."
tags: ["kubernetes", "nocode", "nocodb", "n8n", "redmine", "analytics", "umami"] tags: ["kubernetes", "nocode", "nocodb", "n8n", "analytics", "umami"]
draft: true draft: true
--- ---
@@ -12,9 +12,8 @@ Build your self-hosted Kubernetes cluster and be free from any SaaS solutions by
1. Build and deploy simple blog 1. Build and deploy simple blog
2. Analytics with Umami 2. Analytics with Umami
3. Redmine 3. NocoDB
4. NocoDB 4. n8n
5. n8n
## 5th check ✅ ## 5th check ✅

View File

@@ -1,6 +1,6 @@
--- ---
title: "Setup a HA Kubernetes cluster Part V - Monitoring Stack" title: "Setup a HA Kubernetes cluster Part V - Monitoring Stack"
date: 2022-12-12 date: 2023-06-12
description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..." description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..."
tags: ["kubernetes", "prometheus", "loki", "grafana"] tags: ["kubernetes", "prometheus", "loki", "grafana"]
draft: true draft: true

View File

@@ -1,8 +1,8 @@
--- ---
title: "Setup a HA Kubernetes cluster Part VI - VCS & CI" title: "Setup a HA Kubernetes cluster Part VI - VCS & CI"
date: 2022-12-14 date: 2023-06-14
description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..." description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..."
tags: ["kubernetes", "gitea", "concourse"] tags: ["kubernetes", "ci", "gitea", "concourse"]
draft: true draft: true
--- ---

View File

@@ -1,8 +1,8 @@
--- ---
title: "Setup a HA Kubernetes cluster Part VII - CD, GitOps way" title: "Setup a HA Kubernetes cluster Part VII - CD, GitOps way"
date: 2022-12-15 date: 2023-06-15
description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..." description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..."
tags: ["kubernetes", "fluxcd", "gitops"] tags: ["kubernetes", "cd", "fluxcd", "gitops"]
draft: true draft: true
--- ---

View File

@@ -1,6 +1,6 @@
--- ---
title: "Setup a HA Kubernetes cluster Part VIII - Load testing & tracing" title: "Setup a HA Kubernetes cluster Part VIII - Load testing & tracing"
date: 2022-12-16 date: 2023-06-16
description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..." description: "Follow this opinionated guide as starter-kit for your own Kubernetes platform..."
tags: ["kubernetes", "k6", "jaeger"] tags: ["kubernetes", "k6", "jaeger"]
draft: true draft: true