K3S : Lightweight Kubernetes. 5 less than k8s.

K3S : Lightweight Kubernetes. 5 less than k8s.

2019-11-04 0 Par seuf

Today, I will talk about a tool I discovered recently that I use a lot to create local Kubernetes environments : k3s

k3s allow you to create local k8s cluster, and try your application deployments before pushing it to production.

You can use the k3s quick start, or use the k3d binary to deploy a Kubernetes cluster in docker.

Just download the latest k3d release from the github releases page of the project, chmod +x the binary and put it somewhere in your $PATH

curl -Lf https://github.com/rancher/k3d/releases/download/v1.3.4/k3d-linux-amd64 -o k3d
chmod +x k3d
sudo mv k3d /usr/local/bin/

Then, you can follow the following steps to play :

  • Create the k3s cluster :
k3d create --workers 3
  • Fetch the credentials of the cluster :
export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')"
  • Install the local-path storage driver (if you want to use pvclaim)
kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml

Note : You must set the storage class to local-path in your pvclaims to use this driver.

  • Get the Traefik Loadbalancer IP (wait for traefik to be ready)
kubectl -n kube-system get svc traefik -o jsonpath='{.status.loadBalancer.ingress[0].ip}'

-> sudo vim /etc/hosts with your desired ingress name       foobar.aperogeek.fr

Now you can deploy an application within your cluster with your kubectl / kustomize config files !

You can even use the terraform kubernetes provider if you configure it like this :

provider "kubernetes" {
  config_path = "/home/seuf/.config/k3d/k3s-default/kubeconfig.yaml"

Enjoy 🙂