Skip to content

tron4x/kubeone-hetzner

Repository files navigation

The code install an 1 control plane and 2 worker nodes, K8S cluster and one pool server for deployments.

Also we install and configure ingress-nginx and metallb.

Prometheus, Grafana and Keycloak will be deployed over ArgoCD with kustomization configuration.

Caution !

There are costs as soon as the servers were created. LoadBalancer and Cloud Volume ( pvc for Grafana ) are also created.

My costs are between 15-20 euros per month ( As of today: November 2021 )

New Update 01/31/2022

  1. Added os update for ubuntu/debian in main.tf .

    upgrade_os is an binary create with golang. You can see the source here: upgrade_os.go

Requirements

Terraform

Helm

Kubeone

Hcloud ( Optional )

Installation of Infrastructure Cluster

 terraform init
 terraform plan
 terraform apply
 terraform output -json > tf.json

Deploy K8S Cluster with KubeOne

ssh-add ~/.ssh/id_rsa
kubeone apply -m kubeone.yaml -t tf.json
  • export ks config:
export KUBECONFIG=$PWD/k8s-config

Install Metallb

See: https://metallb.universe.tf/installation/

I use layer 2 configuration

I have configured metallb as single-ip address pool.

File is metallb-l2.yaml

Install ingress-nginx

kubectl apply -f ingress_deploy.yaml

Prometheus & Grafana

Both will be deployed over ArgoCD alt text

All yaml files are in direcrory "monitoring"

If you want to change the service type for ArgoCD, from Load balancer to NodePort then execute this:

kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "NodePort"}}'

alt text alt text

Now you are ready to work with your K8S Cluster 👍

Encrypt your Secret into a SealedSecret

https://github.com/bitnami-labs/sealed-secrets#installation

https://artifacthub.io/packages/helm/bitnami-labs/sealed-secrets

Install with helm3:

helm install --namespace kube-system sealed sealed-secrets/sealed-secrets

Keycloak

Deployment over ArgoCD.

alt text

Kubernetes Dashboard

Deployment over Argocd:

https://github.com/tron4x/kubeone-hetzner/tree/main/service/k8s-ddashboard

You have to login with token.

Token can be viewed with:

kubectl -n kubernetes-dashboard get secret $(kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}") -o go-template="{{.data.token | base64decode}}"

pod,svc and pvc outputs

Pods

alt text

Services

alt text

PVC

alt text