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