Implementing Lightweight
Kubernetes(K3s) on Raspberry Pi Stack
3 Aug 2019
Docker Bangalore
Meetup #45 -
Docker,
Kubernetes & IoT
$Whoami
Sangam Biradar
Github-sangam14
Twitter-BiradarSangam
$curl engineitops.icu
- My Personal Blog Website
- Over 100+ blog post on docker | Golang and kubernetes and
cloud
- Unique 10000+ hits
- Research Papers Presented/Published in the Conference
Proceedings(IEEE)
1.“Build Minimal Docker Container Using Golang’’- presented
and published in the proceedings of the International
Conference ICICCS2018 at Vaigai College Of Engineering,
Madurai 14 June 18
Agenda
- Why the IoT needs Kubernetes?
- Introducing k3s
- How k3s works
- What is k3sos?
- Demo
- Questions?
Why the IoT Needs Kubernetes?
- Enabling DevOps for IoT.
- Scalability
- High availability
- Efficient use of cloud resources
- Deployment to the IoT edge
Introducing k3s
• Lightweight certified Kubernetes distro
• Built for production operations
• 40MB binary, 250MB memory consumption
• Single process w/ integrated Kubernetes
master, Kubelet, and containerd
• SQLite in addition to etcd
• Simultaneously released for x86_64, ARM64,
and ARMv7
• Open source project, not yet a Rancher
product
To build k3s removed unnecessary
code and made a few enhancements
How k3s works
Process
– Server
• Standup k3s as server
on raspberry pi
• Get node-token for
agents
– Agents
• Install binary (just
because – can be done
with scripted version
also)
• View resource utilization
• Connect agent to server
What is k3sos
The Kubernetes Operating System
k3OS is purpose-built to simplify Kubernetes
operations in low-resource computing
environments. Installs fast. Boots faster.
Managed through Kubernetes.
Why Should You Use k3OS?
1.First...
It’s GREAT For EDGE, IoT, CI, And ARM
You get ALL the benefits of using k3s, the optimized, simplified, and streamlined Kubernetes distribution.
2. Fast...
Fast Installation
You can boot up with k3s available in under 10 seconds, with fast cluster scaling
3. Easy...
Easy Configuration Via Cloud-Init
You can turn a standard k3OS image into a configured system during boot time.
4. Simple...
Manage The OS From Within Kubernetes
You don’t need to log into remote nodes. k3OS simplifies installation and upgrading.
Demo
1.Enable SSH to perform remote login
2.Enable container features in Kernel
Edit /boot/cmdline.txt on both the Raspberry Pi node
root@raspberrypi:~# echo "cgroup_enable=cpuset cgroup_memory=1
cgroup_enable=memory" >>/boot/cmdline.txt
3. Installing K3s
root@raspberrypi:~# curl -sfL https://get.k3s.io | sh –
4.Listing K3s Nodes
# k3s kubectl get node -o wide
5.# k3s kubectl get po,svc,deploy
6.Running Nginx Pods
root@raspberrypi:~# k3s kubectl run mynginx --image=nginx --
replicas=3 --port=80
7.Listing the Nginx Pods
# k3s kubectl get po
8.Exposing the Deployment
# k3s kubectl expose deployment mynginx --port 80
9. Verifying the endpoints controller for Pods
# k3s kubectl get endpoints mynginx
10. Testing Nginx application
# curl 10.42.0.10:80
root@raspberrypi:~# cat /var/lib/rancher/k3s/server/node-token
K108b8e370b380bea…….
11.Adding a new Node to K3s Cluster
12.Creating variable
# NODETOKEN=K108b8e370b380bea…….
root@pi-node1:~# k3s agent --server https://192.168.43.134:6443 --token
${NODETOKEN}
13. # k3s kubectl get nodes
root@raspberrypi:~# k3s kubectl run mynginx --
image=nginx --replicas=3 --port=80
14 .Setting up Nginx
15. Verifying the endpoints controller for Pods
# k3s kubectl get endpoints mynginx
16.Delete all pods
# kubectl delete --all pods
Questions?
k3s.io
Thanks

Implementing Lightweight Kubernetes(K3s) on Raspberry Pi Stack - Sangam Biradar

  • 1.
    Implementing Lightweight Kubernetes(K3s) onRaspberry Pi Stack 3 Aug 2019 Docker Bangalore Meetup #45 - Docker, Kubernetes & IoT
  • 2.
    $Whoami Sangam Biradar Github-sangam14 Twitter-BiradarSangam $curl engineitops.icu -My Personal Blog Website - Over 100+ blog post on docker | Golang and kubernetes and cloud - Unique 10000+ hits - Research Papers Presented/Published in the Conference Proceedings(IEEE) 1.“Build Minimal Docker Container Using Golang’’- presented and published in the proceedings of the International Conference ICICCS2018 at Vaigai College Of Engineering, Madurai 14 June 18
  • 3.
    Agenda - Why theIoT needs Kubernetes? - Introducing k3s - How k3s works - What is k3sos? - Demo - Questions?
  • 4.
    Why the IoTNeeds Kubernetes? - Enabling DevOps for IoT. - Scalability - High availability - Efficient use of cloud resources - Deployment to the IoT edge
  • 5.
    Introducing k3s • Lightweightcertified Kubernetes distro • Built for production operations • 40MB binary, 250MB memory consumption • Single process w/ integrated Kubernetes master, Kubelet, and containerd • SQLite in addition to etcd • Simultaneously released for x86_64, ARM64, and ARMv7 • Open source project, not yet a Rancher product
  • 6.
    To build k3sremoved unnecessary code and made a few enhancements
  • 7.
  • 8.
    Process – Server • Standupk3s as server on raspberry pi • Get node-token for agents – Agents • Install binary (just because – can be done with scripted version also) • View resource utilization • Connect agent to server
  • 9.
    What is k3sos TheKubernetes Operating System k3OS is purpose-built to simplify Kubernetes operations in low-resource computing environments. Installs fast. Boots faster. Managed through Kubernetes.
  • 10.
    Why Should YouUse k3OS? 1.First... It’s GREAT For EDGE, IoT, CI, And ARM You get ALL the benefits of using k3s, the optimized, simplified, and streamlined Kubernetes distribution. 2. Fast... Fast Installation You can boot up with k3s available in under 10 seconds, with fast cluster scaling 3. Easy... Easy Configuration Via Cloud-Init You can turn a standard k3OS image into a configured system during boot time. 4. Simple... Manage The OS From Within Kubernetes You don’t need to log into remote nodes. k3OS simplifies installation and upgrading.
  • 11.
  • 12.
    1.Enable SSH toperform remote login
  • 13.
    2.Enable container featuresin Kernel Edit /boot/cmdline.txt on both the Raspberry Pi node root@raspberrypi:~# echo "cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory" >>/boot/cmdline.txt
  • 14.
    3. Installing K3s root@raspberrypi:~#curl -sfL https://get.k3s.io | sh –
  • 15.
    4.Listing K3s Nodes #k3s kubectl get node -o wide
  • 16.
    5.# k3s kubectlget po,svc,deploy
  • 17.
    6.Running Nginx Pods root@raspberrypi:~#k3s kubectl run mynginx --image=nginx -- replicas=3 --port=80
  • 18.
    7.Listing the NginxPods # k3s kubectl get po
  • 19.
    8.Exposing the Deployment #k3s kubectl expose deployment mynginx --port 80
  • 20.
    9. Verifying theendpoints controller for Pods # k3s kubectl get endpoints mynginx 10. Testing Nginx application # curl 10.42.0.10:80
  • 21.
    root@raspberrypi:~# cat /var/lib/rancher/k3s/server/node-token K108b8e370b380bea……. 11.Addinga new Node to K3s Cluster 12.Creating variable # NODETOKEN=K108b8e370b380bea……. root@pi-node1:~# k3s agent --server https://192.168.43.134:6443 --token ${NODETOKEN}
  • 22.
    13. # k3skubectl get nodes
  • 23.
    root@raspberrypi:~# k3s kubectlrun mynginx -- image=nginx --replicas=3 --port=80 14 .Setting up Nginx
  • 24.
    15. Verifying theendpoints controller for Pods # k3s kubectl get endpoints mynginx 16.Delete all pods # kubectl delete --all pods
  • 25.
  • 26.