Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
geerlingguy committed Aug 2, 2022
0 parents commit dc1c904
Show file tree
Hide file tree
Showing 12 changed files with 285 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are supported funding model platforms
---
github: geerlingguy
patreon: geerlingguy
56 changes: 56 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Configuration for probot-stale - https://github.com/probot/stale

# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 90

# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
daysUntilClose: 30

# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
onlyLabels: []

# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
exemptLabels:
- pinned
- security
- planned

# Set to true to ignore issues in a project (defaults to false)
exemptProjects: false

# Set to true to ignore issues in a milestone (defaults to false)
exemptMilestones: false

# Set to true to ignore issues with an assignee (defaults to false)
exemptAssignees: false

# Label to use when marking as stale
staleLabel: stale

# Limit the number of actions per hour, from 1-30. Default is 30
limitPerRun: 30

pulls:
markComment: |-
This pull request has been marked 'stale' due to lack of recent activity. If there is no further activity, the PR will be closed in another 30 days. Thank you for your contribution!
Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark pull requests as stale.
unmarkComment: >-
This pull request is no longer marked for closure.
closeComment: >-
This pull request has been closed due to inactivity. If you feel this is in error, please reopen the pull request or file a new PR with the relevant details.
issues:
markComment: |-
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
Please read [this blog post](https://www.jeffgeerling.com/blog/2020/enabling-stale-issue-bot-on-my-github-repositories) to see the reasons why I mark issues as stale.
unmarkComment: >-
This issue is no longer marked for closure.
closeComment: >-
This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: CI
'on':
pull_request:
push:
branches:
- master

jobs:

lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Check out the codebase.
uses: actions/checkout@v2

- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install test dependencies.
run: pip3 install yamllint

- name: Lint all the YAMLs.
run: yamllint .
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
hosts.ini
config.yml
ansible_collections
roles/geerlingguy.*
11 changes: 11 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
extends: default
rules:
line-length:
max: 140
level: warning
truthy: false

ignore: |
**/.github/workflows/ci.yml
**/stale.yml
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Jeff Geerling

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# DeskPi Super6c 6-node Pi Cluster

[![CI](https://github.com/geerlingguy/deskpi-super6c-cluster/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/geerlingguy/deskpi-super6c-cluster/actions?query=workflow%3ACI)

This repository contains examples and automation used in DeskPi Super6c-related videos on [Jeff Geerling's YouTube channel](https://www.youtube.com/c/JeffGeerling).

You might also be interested in another Raspberry-Pi cluster I've maintained for years, the [Raspberry Pi Dramble](https://www.pidramble.com), which is a Kubernetes Pi cluster in my basement that hosts [www.pidramble.com](https://www.pidramble.com). I also set up a [Turing Pi 2 Cluster](https://github.com/geerlingguy/turing-pi-2-cluster) in a similar fashion.

## Usage

1. Make sure you have [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html) installed.
2. Copy the `example.hosts.ini` inventory file to `hosts.ini`. Make sure it has the `control_plane` and `node`s configured correctly (for my examples I named my nodes `deskpi[1-6].local`).
3. Copy the `example.config.yml` file to `config.yml`, and modify the variables to your liking.

### Raspberry Pi Setup

I am running Raspberry Pi OS (64-bit, lite) on a set of six Raspberry Pi Compute Module 4s with 8GB of RAM and no built-in eMMC. I am using [32 GB SanDisk Extreme microSD cards](https://amzn.to/3G35QbY) to boot each node.

I flashed Raspberry Pi OS to the Pis using Raspberry Pi Imager.

To make network discovery and integration easier, I edited the advanced configuration in Imager (press Shift + Ctrl + X), and set the following options:

- Set hostname: `deskpi1.local` (set to `2` for node 2, `3` for node 3, etc.)
- Enable SSH: 'Allow public-key', and paste in my public SSH key(s)

After setting all those options, making sure the hostname is unique to each node (and matches what is in `hosts.ini`), I inserted the microSD cards into the respective slots on the underside of the board, and booted the cluster.

### SSH connection test

To test the SSH connection from my Ansible controller (my main workstation, where I'm running all the playbooks), I connected to each server individually, and accepted the hostkey:

```
ssh [email protected]
```

This ensures Ansible will also be able to connect via SSH in the following steps. You can test Ansible's connection with:

```
ansible all -m ping
```

It should respond with a 'SUCCESS' message for each node.

### Cluster configuration

Run the playbook:

```
ansible-playbook main.yml
```

TODO.

### Upgrading the cluster

Run the upgrade playbook:

```
ansible-playbook upgrade.yml
```

### Monitoring the cluster

TODO.

### Shutting down the cluster

The safest way to shut down the cluster is to run the following command:

```
ansible all -B 500 -P 0 -a "shutdown now" -b
```

Then after you confirm the nodes are shut down, hold down the power button for about 5 seconds, and the board will power off the CM4 slots. Then you can switch off or disconnect your power supply.

## Author

The repository was created in 2022 by [Jeff Geerling](https://www.jeffgeerling.com), author of [Ansible for DevOps](https://www.ansiblefordevops.com), [Ansible for Kubernetes](https://www.ansibleforkubernetes.com), and [Kubernetes 101](https://www.kubernetes101book.com).
6 changes: 6 additions & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[defaults]
nocows = true
inventory = hosts.ini
roles_path = roles
collections_paths = ./
interpreter_python = /usr/bin/python3
1 change: 1 addition & 0 deletions example.config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
16 changes: 16 additions & 0 deletions example.hosts.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[control_plane]
deskpi1.local

[nodes]
deskpi2.local
deskpi3.local
deskpi4.local
deskpi5.local
deskpi6.local

[cluster:children]
control_plane
nodes

[cluster:vars]
ansible_user=pi
36 changes: 36 additions & 0 deletions main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
- name: Set up cluster-wide configuration.
hosts: cluster
gather_facts: false
become: true

handlers:
- name: reboot-pi
reboot:

vars_files:
- config.yml

tasks: []


- name: Configure the control plane (node 1).
hosts: control_plane
gather_facts: false
become: true

vars_files:
- config.yml

tasks: []


- name: Configure the nodes (nodes 2-6).
hosts: nodes
gather_facts: false
become: true

vars_files:
- config.yml

tasks: []
24 changes: 24 additions & 0 deletions upgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
- name: Upgrade everything on the cluster.
hosts: cluster
become: true

tasks:
- name: Upgrade all software.
ansible.builtin.apt:
update_cache: true
upgrade: dist

- name: Check if a reboot is required.
stat:
path: /var/run/reboot-required
get_md5: no
register: reboot_required_file

- name: Reboot the server (if required).
reboot:
when: reboot_required_file.stat.exists == true

- name: Remove dependencies that are no longer required.
apt:
autoremove: yes

0 comments on commit dc1c904

Please sign in to comment.