Skip to content

K3S

Creating Kubernetes Cluster with k3s

K3s is a lightweight Kubernetes distribution that Rancher Labs, which is fully certified Kubernetes offering by CNCF. In K3s, we see that the memory footprint or binary which contains the components to run a cluster is small. It means that K3s is small in size.

Requirements

  • docker to be able to use k3d at all
  • kubectl to interact with the Kubernetes cluster
    sudo apt install docker.io
    sudo snap install kubectl --classic
    

Setup

curl -sfL https://get.k3s.io | sh -

export KUBECONFIG=/etc/rancher/k3s/k3s.yaml

sudo chmod 644 $KUBECONFIG
k3d cluster create mycluster
Deletes all clusters
k3d cluster delete -a 
Deletes specified cluster
k3d cluster delete [name] 

kind: Simple
apiVersion: k3d.io/v1alpha2
name: my-cluster
image: rancher/k3s:v1.20.4-k3s1
servers: 1
agents: 2
ports:
- port: 80:80
    nodeFilters:
    - loadbalancer

Multi-Node Cluster Setup

 k3d cluster create [NAME] --servers 3