Skip to content

thebongcook/k3s_tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

k3s-tutorial

k3s tutorial is a self-learning toolkit to learn k8s on a raspberry pi cluster.

It is inspired and driven by Rancher Labs' k3s, a lightweight yet highly functional k8s distribution built for IoT & Edge Computing.

Hacks

  • Force deployment on worker node
  • Spread pods across zones

Force deployment on worker node

Deployment is distributed automatically by k8s across nodes based on available resource (eg. memory). However if you want to force deployment on a particular node, in this case worker node, you can do so using nodeSelector.

First, create the label for the node.

kubectl label nodes raspiworker1 nodetype=worker

Then, add the nodeSelector in the spec of the deployment to select the node(s).

spec:
  template:
    spec:
      nodeSelector:
        nodetype: worker

Spread pods across zones

This is similar to zones (and also regions) in GCP. The original motivation was to distribute workload between both powerful Raspberry Pi 4 and weak Raspberry Pi 4 nodes. By default all pods would be deployed on the Pi 4.

We can use topologySpreadConstraints to spread pods across zones (and effectively nodes).

First, create the label for the node.

kubectl label nodes raspberrypi zone=zoneA
kubectl label nodes raspiworker1 zone=zoneB

Then, add the topologySpreadConstraints in the spec of the deployment to select the node(s).

spec:
  template:
    spec:
      topologySpreadConstraints:
      - maxSkew: 3
        topologyKey: zone
        whenUnsatisfiable: DoNotSchedule
        labelSelector:
          matchLabels:
            app: hello-world

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages