Skip to content

Ansible scripts for k3s installation on raspberry

License

Notifications You must be signed in to change notification settings

xclemence/k3s-raspberry-ansible

Repository files navigation

k3s raspberry ansible

This repository contains Ansible scripts to deploy a k3s on Raspberry PI.

Scripts are based on k3s.io scripts, you can found the original scripts here

Raspberry preparation

Install Raspberry Pi

Enable SSH connection

  • Add empty ssh file on the boot partition

Change hostname

sudo raspi-config
  • 1 - System Options
  • S4 Hostname

Set SSH key for connection

  • Run powershell as administrator

  • Generate public/private ecdsa key pair.

ssh-keygen -t ecdsa -b 521
  • Apply public key on all servers
$PUBKEYPATH="$HOME\.ssh\id_ecdsa.pub" # public key localisation
$HOSTS= @("pi@192.168.0.150","pi@192.168.0.151","pi@192.168.0.155") # servers list

$HOSTS | Foreach-Object { 
    $pubKey=(Get-Content "$PUBKEYPATH" | Out-String); ssh $_ "mkdir -p ~/.ssh && chmod 700 ~/.ssh && echo '${pubKey}' >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys" 
}
  • Initialise ssh agent and add current key
Set-Service ssh-agent -StartupType Automatic
Start-Service ssh-agent

ssh-add

Ansible Scripts

Inventory

  • master: Kubernetes master
  • node: Kubernetes worker node
  • tools: server with tools to manage the Kubernetes server (kubectl, helm)

Playbook

Tools/plugins installed:

  • k3s
  • Kubernetes dashboard (Helm)
  • Longhorn (Helm)
  • Ingress nginx (Helm)

Ansible galaxy collections required:

  • community.general
  • community.kubernetes

Install the k3s

ansible-playbook site.yml -i inventory/hosts.ini

uninstall the k3s

ansible-playbook reset.yml -i inventory/hosts.ini

Reminders

Dashboard access

  • run
kubectl proxy

Find kubernetes dashboard secrets token

kubectl -n dashboard describe secret $(kubectl -n dashboard get secret | where-object { $_.startswith('dashboard-token') } | ForEach-Object { $_ -Split '\s+' } | Select -First 1)

About

Ansible scripts for k3s installation on raspberry

Topics

Resources

License

Stars

Watchers

Forks