Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for hybrid cluster (x86 nodes and RaspberryPI) #124

Merged
merged 8 commits into from
Apr 21, 2023
Merged
15 changes: 10 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
.EXPORT_ALL_VARIABLES:

GPG_EMAIL=ricsanfre@gmail.com
GPG_NAME=Ricardo Sanchez

RUNNER=ansible-runner/ansible-runner.sh

KUBECONFIG = $(shell pwd)/ansible-runner/runner/.kube/config

.PHONY: default
default: clean
Expand Down Expand Up @@ -41,7 +38,7 @@ gateway-setup:

.PHONY: nodes-setup
nodes-setup:
${RUNNER} ansible-playbook setup_picluster.yml --tags "nodes"
${RUNNER} ansible-playbook setup_picluster.yml --tags "node"

.PHONY: external-services
external-services:
Expand Down Expand Up @@ -86,3 +83,11 @@ shutdown-k3s-master:
.PHONY: shutdown-gateway
shutdown-gateway:
${RUNNER} ansible -b -m shell -a "shutdown -h 1 min" gateway

.PHONY: get-argocd-passwd
get-argocd-passwd:
kubectl get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' -n argocd | base64 -d;echo

.PHONY: get-elastic-passwd
get-elastic-passwd:
kubectl get secret efk-es-elastic-user -o jsonpath='{.data.elastic}' -n logging | base64 -d;echo
2 changes: 1 addition & 1 deletion ansible/backup_configuration.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

- name: Configure Pi-cluster nodes backup
hosts: raspberrypi
hosts: picluster:gateway
gather_facts: true
tags: [backup]
become: true
Expand Down
8 changes: 6 additions & 2 deletions ansible/inventory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ all:
hostname: pimaster
ansible_host: localhost
ansible_connection: local
ip: 10.0.0.10
mac: 08:00:27:f3:6b:dd
external:
hosts:
s3:
Expand Down Expand Up @@ -46,6 +44,11 @@ all:
ansible_host: 10.0.0.15
ip: 10.0.0.15
mac: e4:5f:01:d9:ec:5c
khazad-dum:
hostname: khazad-dum
ansible-host: 10.0.0.20
ip: 10.0.0.20
mac: 18:60:24:21:1c:d4
raspberrypi:
hosts:
node[1:5]:
Expand All @@ -58,3 +61,4 @@ all:
k3s_worker:
hosts:
node[2:5]:
khazad-dum:
11 changes: 11 additions & 0 deletions ansible/roles/basic_setup/tasks/disable_swap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---

- name: System Configuration (2) | Disable swap at runtime
ansible.builtin.command: swapoff -a
when: ansible_swaptotal_mb > 0
- name: System Configuration (2) | Disable swap at boot
ansible.posix.mount:
name: "{{ item }}"
fstype: swap
state: absent
loop: ["none", "swap"]
29 changes: 5 additions & 24 deletions ansible/roles/basic_setup/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,12 @@
include_tasks: remove_snap.yaml
when: "'snapd' in ansible_facts.packages"

- name: Execute RaspberryPi specific setup tasks
include_tasks: raspberrypi_tasks.yml
when: "'raspberrypi' in group_names"

- name: Install common packages
apt:
name: "{{ basic_packages }}"
update_cache: true
state: present

- name: Copy utility scripts
copy:
src: "scripts/{{ item }}"
dest: "/usr/local/bin/{{ item }}"
owner: "root"
group: "root"
mode: "u=rwx,g=rx,o=rx"
with_items:
- pi_temp
- pi_throttling

- name: Set GPU memory split to 16 MB
lineinfile:
path: /boot/firmware/config.txt
line: "gpu_mem=16"
create: true
mode: 0755
notify: reboot
- name: Disable swap memory
include_tasks: disable_swap.yml

- name: Blacklist storage devices in multipath configuration
include_tasks: multipath_blacklist.yml
26 changes: 26 additions & 0 deletions ansible/roles/basic_setup/tasks/raspberrypi_tasks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---

- name: Install common packages
apt:
name: "{{ basic_packages }}"
update_cache: true
state: present

- name: Copy utility scripts
copy:
src: "scripts/{{ item }}"
dest: "/usr/local/bin/{{ item }}"
owner: "root"
group: "root"
mode: "u=rwx,g=rx,o=rx"
with_items:
- pi_temp
- pi_throttling

- name: Set GPU memory split to 16 MB
lineinfile:
path: /boot/firmware/config.txt
line: "gpu_mem=16"
create: true
mode: 0755
notify: reboot
3 changes: 2 additions & 1 deletion ansible/roles/k3s/prereq/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@
- net.bridge.bridge-nf-call-iptables
- net.bridge.bridge-nf-call-ip6tables

# Enable cgroups
# Enable cgroups RaspberryPi
- name: Enable cgroup via boot commandline if not already enabled for Ubuntu on a Raspberry Pi
lineinfile:
path: /boot/firmware/cmdline.txt
backrefs: true
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$'
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
when: "'raspberrypi' in group_names"
notify: reboot
1 change: 1 addition & 0 deletions ansible/setup_picluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,6 @@
- name: Configure Local Storage
include_role:
name: ricsanfre.storage
when: "'raspberrypi' in group_names"
when: not centralized_san
tags: [storage]
2 changes: 1 addition & 1 deletion ansible/update.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- hosts: raspberrypi
- hosts: all
become: true
gather_facts: false

Expand Down