Used it for my home thingie, some quality improvements.

Need to document the changes on the README.md.
This commit is contained in:
savagebidoof 2023-08-01 20:00:14 +02:00
parent 7358da26d8
commit 6902681907
8 changed files with 77 additions and 28 deletions

View File

@ -1,8 +1,60 @@
# Pi4
# Raspberry Pi 4
For debian [Pi4 images](https://raspi.debian.net/tested-images/):
## For debian [Pi4 images](https://raspi.debian.net/tested-images/):
- Use a keyboard and a screen to log in into `root` (password is empty) and set whatever.
- install `python3, python3-apt`.
- I used the `raspberry pi imager` tool to add one of the images to the USB SSD for the pi4.
- mounted the storage partition and modified the SSH config to allow SSH to empty password users and root. (the script removes those things to it's fine)
- `apt-get update && apt-get install -y python3 python3-apt`.
- `ln -s /usr/bin/python3 /usr/bin/python`
## For [Armbian](https://www.armbian.com/rpi4b/)
Same as OPI5
- No need to set a MAC manually tho
- Gave me some kernel panics so can't recommend.
# Orange Pi 5
For Opi5
- https://www.armbian.com/orangepi-5/
- I used the `raspberry pi imager` tool to add one of the images to an NVME for the opi5.
- Connected a screen and a keyboard, added a password for the `root` user, added a user `orangepi:orangepi`.
## Random MAC every power on
http://www.orangepi.org/orangepibbsen/forum.php?mod=viewthread&tid=
https://www.reddit.com/r/OrangePI/comments/14sleyi/orange_pi_5_mac_address_keeps_changing/
```shell
nano /etc/network/interfaces
```
Add the following lines
```text
auto eth0
iface eth0 inet dhcp
hwaddress ether AA:BB:CC:DD:EE:FF
```
||\
||\
V
```text
source /etc/network/interfaces.d/*
# Network is managed by Network manager
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
hwaddress ether AA:BB:CC:DD:EE:FF
```

View File

@ -1,5 +1,5 @@
# Author: Oriol Filter
# 01/07/2023
# 01/08/2023
# Intended for armbian (bullseye, fuck ubuntu tho)
- name: Pre Setup
hosts: all
@ -8,15 +8,15 @@
vars:
# Connect
ansible_user: "{{ initial_user }}"
ansible_user: "{{ initial_username }}"
ansible_password: "{{ initial_password }}"
ansible_become_password: "{{ ansible_password }}"
# New values
## Users
new_user_name: "kuser"
new_user_pass: "kuser1234"
new_root_pass: "1234"
new_user_name: "kluser"
new_user_pass: "kluser_1234"
new_root_pass: "root_1234"
## Locales
new_locale: "en_US.UTF-8"
@ -139,7 +139,7 @@
# REBOOT
- name: reboot
ansible.builtin.reboot:
# ansible.builtin.shell: 'sleep 1 && dhclient -r && dhclient && reboot'
# ansible.builtin.reboot:
ansible.builtin.shell: 'sleep 1 && dhclient -r && dhclient && reboot'
ignore_unreachable: true
# become: yes

View File

@ -5,6 +5,7 @@ masters:
is_master: yes
initial_username: root
initial_password: ""
delete_user_name: orangepi
slaves:
hosts:

View File

@ -10,8 +10,8 @@
vars:
# Testing purposes
ansible_user: "kuser" # Testing purposes
ansible_password: "kuser1234" # Testing purposes
ansible_user: "kluser" # Testing purposes
ansible_password: "kluser_1234" # Testing purposes
ansible_become_password: "{{ ansible_password }}" # Testing purposes
# Actual vars
@ -20,7 +20,7 @@
# Cluster shit
kubeadm_join_path: "./Exported/kubeadm-join.command"
_kubeadm_join_command: "" #placeholder
_kubeadm_join_command: "" # Placeholder
tasks:
# - check vars
@ -36,6 +36,7 @@
- name: init cluster
import_tasks: tasks_master.yaml
when: is_master
become: true
# else: join
- name: join cluster
@ -45,3 +46,4 @@
# Do other stuff
- name: post setup
import_tasks: tasks_end.yaml
become: true

View File

@ -3,8 +3,8 @@
name: "{{ delete_user_name }}"
remove: true
state: absent
when: not is_master
become: true
when: delete_user_name != ""
#reboot
- name: reboot

View File

@ -1,7 +1,6 @@
## Init
- name: Init cluster
ansible.builtin.command: "kubeadm init"
become: true
## Export kubeconfig file
@ -11,31 +10,29 @@
src: /etc/kubernetes/admin.conf
dest: ./Exported/kubeconfig.conf
flat: true
become: true
## Taints
### Schedule pods on master
- name: Remove Taint (allows deployment in control plane node)
ansible.builtin.shell: "kubectl taint nodes --all node-role.kubernetes.io/control-plane-"
ansible.builtin.shell: "kubectl taint nodes --kubeconfig /etc/kubernetes/admin.conf --all node-role.kubernetes.io/control-plane-"
## CNI
### Calico
- name: Calico
ansible.builtin.command: "kubectl create --kubeconfig /etc/kubernetes/admin.conf -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.1/manifests/calico.yaml"
become: true
## Extras
### MetalLB
- name: MetalLB
ansible.builtin.command: "kubectl create --kubeconfig /etc/kubernetes/admin.conf -f https://raw.githubusercontent.com/metallb/metallb/v0.13.10/config/manifests/metallb-native.yaml"
become: true
## Export join command
- name: Generate join token
shell: kubeadm token create --print-join-command
shell: kubeadm token create --kubeconfig /etc/kubernetes/admin.conf --print-join-command
register: kubeadm_join_cmd
- set_fact:
@ -49,3 +46,4 @@
content: |
{{ kubeadm_join_command }}
delegate_to: localhost
become: false

View File

@ -1,7 +1,7 @@
- name: Populate {{ _kubeadm_join_command }}
ansible.builtin.set_fact: _kubeadm_join_command="{{ lookup('file', kubeadm_join_path ) }}"
- debug: var=kubeadm_join_command
- debug: var=_kubeadm_join_command
- name: Join kubeadm
ansible.builtin.command: "{{ _kubeadm_join_command }}"

6
run.sh
View File

@ -1,11 +1,7 @@
#!/bin/bash
export ANSIBLE_HOST_KEY_CHECKING=False
# Replace for an inventory
#IP="192.168.1.2"
#IP="192.168.1.50,192.168.1.51"
ansible-playbook -i inventory.yaml Initial_Setup/armbian_initial_setup.yaml && sleep 25 # Wait for reboot
#ansible-playbook -i inventory.yaml Initial_Setup/armbian_initial_setup.yaml && sleep 25 # Wait for reboot
ansible-playbook -i inventory.yaml ksetup/playbook.yaml