Aperogeek.fr

"De la bière et du Linux."


K3S : Lightweight Kubernetes. 5 less than k8s.

k3s

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 :

k3d create --workers 3
export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')"
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.

kubectl -n kube-system get svc traefik -o jsonpath='{.status.loadBalancer.ingress[0].ip}'

-> sudo vim /etc/hosts with your desired ingress name

/etc/hosts
172.18.0.2       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 🙂