Code Monkey home page Code Monkey logo

rpi-cluster-assistant's Introduction

Raspberry Cluster Assistant

Scripts to assist with the creation of a raspberry pi kubernetes cluster.

About

This repository will help and guide you on setting up a cluster with multiple raspberries pi.

Currently it can generate a master and N-workers where N is the number of nodes chosen in the conf.json.

It configures a DHCP server making the master node start assigning IPs to the worker nodes. It is expected for the raspberries to be connected to the same switch. The eth0 interface should be reserved for the cluster.

The objective of this project is to make it easy to configure a cluster in order to start playing with Kubernetes.

Quickstart

git clone https://github.com/Woile/rpi-cluster-assistant.git
cd rpi-cluster-assistant/
./scripts/init
./scripts/flash-cluster

Once the SD cards have been flashed, plug them in the raspberries. I'd recommend starting with the SD containing the master node.

Features

  • Access using SSH to the nodes.
  • DHCP Server and master node with static IP 10.0.0.1
  • Range of IPs assigned to nodes goes from 10.0.0.2 to 10.0.0.50
  • All the nodes have access to wifi. This might be useful later to play with multi-master nodes.
  • Provision a kubernetes cluster
  • Support for multiple pod networks: flannel, weavenet
  • Include kubernetes addons, currently only dashboard.
  • Prompt asking for the configuration of the cluster.

Prerequisites

  • Linux Debian based OS.
  • Python 3.x

Usage

1. Initialization

Execute:

./scripts/init

Explanation:

  1. Installs OS dependencies (debian) in your machine (the host).
  2. Downloads Hypriot OS and flash.
  3. Create 'conf.json' using the assistant if file is not present.

2. Flash to SD cards

Before:

  • Update config.json values.

Execute:

./scripts/flash-cluster

Explanation:

  1. Show information of what is going to happen and ask for confirmation.
  2. Render cluster files.
  3. If master node is true, it will be the first to be flashed.
  4. The worker nodes will be flashed.

Extra commands

Assistant

Execute:

./scripts/assistant.py

Explanation:

  1. Questions about the cluster are prompted.
  2. A conf.json file is generated.

Flash one

Before:

  • Update config.json values.

Execute:

./scripts/flash-one

Explanation:

  1. Prompt the user for some information.
  2. Render cluster files.
  3. Flash one SD card based on the node type (master or worker) chosen.

Render template

Before:

  • Update the values in conf.json.
  • Use the raw wifi password because it will be automatically converted using wpa_passphrase.
  • If you don't have a ssh key, create one using this tutorial.

Execute:

./scripts/render.py

Explanation:

  1. Reads information from conf.json.
  2. Creates files for Raspberry cluster inside output folder.

Configuration

The configuration file can be created based on the conf.example.json

cp conf.example.json conf.json

All the values are required, if you don't know what to put, leave the default.

Variable Description Default
username The username used to log in to the node hypriot
wifi_ssid_name The name of your wifi -
wifi_password Raw password of your wifi -
wifi_country Country where you are, check the codes NL
ssh_public_key Public SSH Key to access from outside the nodes ~/.ssh/id_rsa.pub
hostname_prefix Name of the machine. It will look like: node-1 node
number_of_nodes Number of raspberries to be flashed 4
node_range_start Offset to the number of nodes. Example range: [5..8] with range start: 5 1
include_master Decide whether to flash a master node or only workers. true
pod_network Pod Network. Options: weavenet, flannel flannel

Provisioning kubernetes cluster

Master node

  1. As root follow the steps located in /root/k8s-cluster.
  2. As normal user follow the steps located in /home/<user>/k8s-config

Notes:

  • Observe the output located in /root/k8s-cluster/kubeadm-init.out because you will
  • have to run the kubeadm join ... after provisioning the worker nodes.

Worker nodes

Remember that this must be executed after running all the scripts above

  1. As root follow the steps located in /root/k8s-cluster.
  2. Run kubeadm join ... command which appears in the master node.

Finally

You can run the addons included in /home/<user>/k8s-addons.

rpi-cluster-assistant's People

Contributors

t04glovern avatar woile avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rpi-cluster-assistant's Issues

Configure `ufw` firewall

Goal
Have a more secure cluster.

Context
I was failing to create a cluster and I don't know if it was ufw or not, so for now I've removed it.
The cluster is working now, so it's possible to add this feature.

Proposal

  • Add ufw to the install dependencies in the template yaml.
  • Find a way to run all of this:
ufw --force reset  # ok
ufw allow ssh
ufw allow 6443 # Kubernetes API (master)
ufw allow 80  # HTTP
ufw allow 443  # HTTPS
ufw allow 8443  # kubectl proxy
ufw allow 10250  # Kubelet API (master and worker)
ufw allow 10251  # kube-scheduler (master)
ufw allow 10252  # kube-controller-manager (master)
ufw allow 2379:2380/tcp  # etcd server client API (master)
ufw allow 30000:32767/tcp  # NodePort Services** (worker)
ufw default deny incoming
yes | ufw enable
  • Find which other ports should be opened

Extras:

WeaveNet

TCP 6783 and UDP 6783/6784

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.