Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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)

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 6/32 What is k3s?

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 14/32 Get started

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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/

Slide 17

Slide 17 text

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 30s v1.14.1-k3s.4 # Run without running the agent $ k3s server --disable-agent

Slide 18

Slide 18 text

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 1h v1.14.1-k3s.4 k3s-server Ready 1h v1.14.1-k3s.4

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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 19d v1.14.1-k3s.4 raspi-1 Ready 16d v1.14.1-k3s.4

Slide 25

Slide 25 text

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()

Slide 26

Slide 26 text

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" ]

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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 The LED blinks!!

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

2019/5/16 Running k3s on Raspberry Pi 127.0.0.1:5500/#1 32/32 Thank you!