Pro Yearly is on sale from $80 to $50! »

Running k3s on Raspberry Pi

0f5f81b602e9ad7f24e7ebe9b994d04c?s=47 kyo
May 15, 2019

Running k3s on Raspberry Pi

Slides for in-house study meeting.

0f5f81b602e9ad7f24e7ebe9b994d04c?s=128

kyo

May 15, 2019
Tweet

Transcript

  1. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 1/32 Running k3s

    on Raspberry Pi
  2. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 2/32 Kyohei Mizumoto(@kyohmizu)

    C# Software Engineer Interests Docker/Kubernetes Go Security whoami
  3. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 3/32 Target People

    who: haven't used k3s haven't run k3s on Raspberry Pi are interested in k3s cluster management
  4. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 4/32 Preferred Knowledge

    The basic knowledge of: Docker Kubernetes Virtual Machine(Microsoft Azure)
  5. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 5/32 Agenda What

    is k3s? Get started Control Raspberry Pi using k3s
  6. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 6/32 What is

    k3s?
  7. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 7/32 kubernetes =

    k8s
  8. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 8/32 k3s =

    k(8-5)s
  9. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 9/32 Lightweight Kubernetes

    Easy to install Half the memory Single binary less than 40MB k3s - 5 less than k8s
  10. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 10/32 Great for

    Edge IoT CI ARM k3s - 5 less than k8s
  11. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 11/32 Changes

  12. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 12/32 How It

    Works
  13. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 13/32 k3s Pronounce

    "Kubes"...? https://github.com/rancher/k3s/issues/55
  14. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 14/32 Get started

  15. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 15/32 Download Binary

    https://github.com/rancher/k3s/releases/latest
  16. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 16/32 Download Binary

    DOWNLOADPATH: https://github.com/rancher/k3s/releases/download/v0.5.0/k3s $ wget [DOWNLOADPATH] $ ls k3s $ chmod +x k3s $ sudo mv k3s /usr/bin/
  17. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 17/32 Run Server

    # Run in the background $ sudo k3s server & # Kubeconfig is written to /etc/rancher/k3s/k3s.yaml $ k3s kubectl get node NAME STATUS ROLES AGE VERSION k3s-server Ready <none> 30s v1.14.1-k3s.4 # Run without running the agent $ k3s server --disable-agent
  18. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 18/32 Join Nodes

    # NODE_TOKEN comes from # /var/lib/rancher/k3s/server/node-token on the server $ sudo k3s agent --server https://myserver:6443 \ --token ${NODE_TOKEN} Show nodes on server: $ k3s kubectl get node NAME STATUS ROLES AGE VERSION k3s-agent Ready <none> 1h v1.14.1-k3s.4 k3s-server Ready <none> 1h v1.14.1-k3s.4
  19. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 19/32 Control Raspberry

    Pi using k3s
  20. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 20/32 Raspberry Pi

    https://www.raspberrypi.org/
  21. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 21/32 Configuration

  22. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 22/32 Raspberry Pi

    Configuration
  23. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 23/32 Raspberry Pi

    Configuration Raspberry Pi 3 B+ Breadboard LED Resistor Jump wire
  24. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 24/32 Required Preparation

    Create VM on Microsoft Azure Run k3s server on the VM (with a node) Join k3s node on Raspberry Pi $ k3s kubectl get node NAME STATUS ROLES AGE VERSION k3s-server Ready <none> 19d v1.14.1-k3s.4 raspi-1 Ready <none> 16d v1.14.1-k3s.4
  25. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 25/32 Sample Program(sample.py)

    import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO.setup(2,GPIO.OUT) while True: GPIO.output(2,True) time.sleep(1) GPIO.output(2,False) time.sleep(1) GPIO.cleanup()
  26. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 26/32 Dockerfile FROM

    python:3 ADD sample.py / RUN pip install rpi.gpio CMD [ "python", "./sample.py" ]
  27. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 27/32 Create Docker

    Image # [NAME] is an account name of Docker Hub $ docker build -t [NAME]/raspi-sample # Run container $ docker run --privileged [NAME]/raspi-sample # Login to Docker Hub $ docker login $ docker push [NAME]/raspi-sample
  28. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 28/32 Manifest(sample.yaml) apiVersion:

    v1 kind: Pod metadata: name: sample spec: containers: - name: sample image: [NAME]/raspi-sample securityContext: privileged: true nodeSelector: kubernetes.io/arch: arm
  29. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 29/32 Deploy on

    Raspberry Pi $ k3s kubectl apply -f sample.yaml pod/sample created # The pod was deployed on Raspberry Pi $ k3s kubectl get po -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES sample 1/1 Running 0 48s 10.42.0.6 raspi-1 <none> <none> The LED blinks!!
  30. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 30/32 Demo

  31. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 31/32 Links https://k3s.io/

    https://github.com/rancher/k3s
  32. 2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 32/32 Thank you!