Yet Another Raspberry Pi Cluster

The slides of a lecture/presentation on 2016-03-20 @ Chemnitzer Linux Tage

Christian Prior

Slides available

http://www.helotism.de \ ⏎
/business/marketing/presentation/CLT_2016-03-20

## about me ![](/business/marketing/presentation/images/about-cpr.svg) https://www.facebook.com/profile.php?id=100010639868228 https://github.com/cprior

Content of today's presentation

[Maker] CNC, CAD&CAM development boards power supply [SysAdmin] Config Mgt monitoring [Data Analysis] data provider visualization [Documentation]

Helotism

Wiktionary.org: Helotism (zoology): A form of mutualism in which one species is forced to perform tasks for another, for their mutual benefit.

The Goals

boards
  • keeping up with IT changes
  • solid Linux sysadmin skills are the foundation for "Big Data"
  • getting most out of these boards
  • getting ahead of the complexity curve

The Roadmap

The Repo

https://github.com/helotism

  • all-in one repo
    • hardware
    • software
    • promotion
  • Issues welcome! ;)
##Jekyll Website helotism.de ```YAML #_config.yml destination: ./business/marketing/website/_site ```
## ERP ![](/business/production/HowThingsAreMade.svg)

TOGAF: Architecture Development Method

TOGAF ADM
  • P Prerequisites
  • A Vision
  • B Business Plan/Action
  • C Information System Plan/Actual
  • D Technology Plan/Actual
  • E Opportunities and Solutions
  • F Migration Planning
  • G Implementation Governance
  • H Change Management
  • R Requirements
##TOGAF: "Domains" & Building Blocks ![](/business/planning/images/PRDV_TOGAF-Cube_BusinessDataApplicationTechnology.jpg)
##Maker - DXF - chipping vs. 3D-printing - CAD4c Computer-Aided Design for clamping

Enthusiast's Small Batch Manufacturing

  • This material is easy to mill…
  • …but quite expensive so nesting was important.
  • Quite some work ahead!
  • Chamfered parts.
  • Additional hardware attached.
  • Testrun paiting technique.

Development Boards

The market for development boards is confusing: https://en.wikipedia.org/wiki/Comparison_of_single-board_computers is a good overview.
##Development Boards: Common Features - Computation: Processor and Memory - Communication through Ethernet/… - Powersupply: Consumption, buttons - Interaction via GPIO - Fixture: Mounting holes and dimensions - Storage: SD cards and beyond - Synchronization: RTC time

Dimensions

-> see repo

##Power Consumption Rule of thumb: - 1 Pi idle == 2.5W (5V * 0,5 A) - 1 Pi under load, no USB == 5W (5V * 1 A) Caveat: GPIO-pins are no USB ports ;) - 5V passed straight through from USB - 3.3V rail max 50mA - GPIO pins 16ma in total

Minnowboard

UEFI

##Operating System 1. archlinuxarm.org * all saltstack dependencies met 2. archlinuxarm.org * up-to-date systemd (229-3 in march 2016) 3. archlinuxarm.org * pre-compiled ;) 4. Raspbian/DietPi/Debian Jessie * Raspbian "Jessie" December 2015, systemd "216"
##Circuits ![](/technology/logical/images/MIT_CircuitsElectronics_Lec1_outline.svg)
##Alles wegabstrahieren! ![](/business/marketing/presentation/images/cpr_travel_pictures_2013-08-28_IMG_0533_1024-360.jpg)
##Noise ![](/technology/logical/images/ElectricalWireNoise.svg)
##Discretization ![](/technology/logical/images/ElectricalDiscretization.svg)
##Debouncing ![](/technology/logical/images/ElectricalSwitchDebounce.svg)
##Powersupply - prevent brown-out - one switch for all boards
##On-Off-Switch - hardware - code ![](/technology/physical/myrack-v0.5/circuit/helotism_powersupply_bb_640x312.png) [raspberry-pi-geek.com On-Off-Switch](http://www.raspberry-pi-geek.com/Archive/2013/01/Adding-an-On-Off-switch-to-your-Raspberry-Pi "Adding an On/Off switch to your Raspberry Pi")
##scale out
##Python logic… ```Python b = mraa.Gpio(20) b.dir(mraa.DIR_IN) b.isr(mraa.EDGE_FALLING, handleInterrupt, handleInterrupt) ``` ```Python def handleInterrupt(args): #print("handleInterrupt") button20.pressed = True #that's a fact, but... button20.pressed_debounced = False interrupted_at = datetime.datetime.now() debounce_until = interrupted_at + datetime.timedelta(0,3) while True: if (datetime.datetime.now() > debounce_until): #print("past debounce") journal.send('GPIO20 pressed DEBOUNCED.', FIELD2='GPIO20') button20.pressed_debounced = True return else: #print("not debounced yet") journal.send('GPIO20 pressed, not debounced', FIELD2='GPIO20') time.sleep(0.5) #inside this interrupt handler only ```
##…and systemd daemonization. ```INI [Unit] Description=An GPIO interrupt listener After=local-fs.target [Service] Type=simple ExecStart=/bin/bash -c 'cd /opt/helotism/powersupply-env; \ source bin/activate; \ python ./mraa_interrupt.py' [Install] WantedBy=multi-user.target ```
##SaltStack Ecosystem ![](/application/physical/images/saltstack-ecosystem.svg)
##SaltStack top file ```YAML base: # environment 'web*': # targeted minions - apache # state file 'apache.sls' ``` - the top.sls is a special state file as "entry point" into the fileserver - "apache" references ```./apache.sls``` file
##SaltStack state file ```YAML #apache.sls {% if grains['os'] == 'Debian' %} apache: apache2 {% elif grains['os'] == 'RedHat' %} apache: httpd {% endif %} ``` - Jinja2 template language - one should read the fine manual: http://jinja.pocoo.org/docs/dev/
##SaltStack environments ```YAML file_roots: dev: - /srv/salt/dev base: - /srv/salt ``` - environments are configured in the master config file
##SaltStack fileserver ```YAML fileserver_backend: #first filename match wins - roots - git gitfs_remotes: - git://github.com/example/first.git - https://github.com/example/second.git - root: salt #subdirectory - mountpoint: salt://sub/dir - base: myTag05 #git branch - file:///root/third #top_file_merging_strategy: merge #same #env_order: ['base', 'dev', 'prod'] ``` - these are powerful configuration mechanisms: "infrastructure as code" served from a Git repo - many ways to segment or override
##Sample Salt Usage ```bash #remote execution? salt '*' cmd.run 'uname -a' ``` ```bash #listing and accepting keys salt-key -L salt-key -A ``` ```bash #salt.modules.test.ping salt '*' test.ping ``` ```bash #targeting by grains salt -G 'os:(RedHat|Debian)' test.ping ``` ```bash #more sound than test.ping salt-run manage.up ``` ```bash #apply common.sls on all (accepted) minions salt '*' state.sls common #This is the "endgame" in salt salt '*' state.highstate #remote execution! salt '*' cmd.run 'uname -a' ```
##ToDo: Scale-down and Simplify - three RPi 2 or RPi3 - bootstrap.sh script from ArchLinux ARM iso to "cluster" - keep formfactor to a minimum - still a switch is needed - and a button - and a RTC
##ToDo: More Hardware Diversity - PINE64 - GBit ethernet wanted
##ToDo: Config Mgt and IoT ![Microsoft Applications on Linux](/business/marketing/presentation/images/kickstarter_micro-python.jpg)