Skip to content

Instantly share code, notes, and snippets.

@htuscher
Last active April 24, 2023 12:01
Show Gist options
  • Save htuscher/948abb589e0e44dfbdd0db02ebd6de31 to your computer and use it in GitHub Desktop.
Save htuscher/948abb589e0e44dfbdd0db02ebd6de31 to your computer and use it in GitHub Desktop.
MicroK8s on Hetzner Cloud

Installation

apt-get install snapd
snap install microk8s --classic --channel=1.18/stable
microk8s enable dns dashboard registry helm3 ingress storage

Dashboard

Dashboard URL (change IP address): https://116.203.232.90:16443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#/statefulset?namespace=default

Obtain user and password from cat /var/snap/microk8s/current/credentials/basic_auth.csv

Bearer Token for Dashboard itself:

token=$(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)
microk8s kubectl -n kube-system describe secret $token

Remote control

mkdir /etc/microk8s
microk8s.config > /etc/microk8s/microk8s.conf

Download the file /etc/microk8s/microk8s.conf to $HOME/.kube/config-m8s (or any other filename).

Tell the kubectl command to read the additional config file via export KUBECONFIG=$HOME/.kube/config:$HOME/.kube/config-m8s (this ENV variable defines a list of config files that kubectl will use). Add this to your .bashrc or similar to make it permanent.

Switch to the cluster context

kubectl config use-context microk8s
kubectl get all --all-namespaces

Letsencrypt via cert-manager

kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v0.14.1/cert-manager.yaml
kubectl create namespace cert-manager
helm repo add jetstack https://charts.jetstack.io
helm install \
  cert-manager jetstack/cert-manager \
  --namespace cert-manager \
  --version v0.14.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment