Compare commits

..

23 Commits

Author SHA1 Message Date
oriol
0648f1112c Fix for ubuntu server 2025-08-03 00:11:53 +02:00
oriol
567bd34c66 QoL and minor fixes 2025-06-04 01:24:29 +02:00
savagebidoof
380e011ca9 Increased to 40 seconds since im now using a node that uses wifi so it can take a bit longer ... 2024-03-10 22:00:09 +01:00
savagebidoof
d42567a399 Quemu restart was not useful and results in error.
To start Quemu, after installing, it requires Proxmox to enable Quemu on that specific VM, then shut down and power up again, a `reboot` won't surface.
2024-03-07 05:44:03 +01:00
savagebidoof
2f6ec13ee6 Slightly updated the README.md 2024-03-07 05:21:50 +01:00
savagebidoof
169e8a8913 Fixed issues with variables (looping), so renamed them to _var 2024-03-07 05:19:58 +01:00
savagebidoof
faa63611f0 fixed typo and improved quality. 2024-03-07 05:15:12 +01:00
savagebidoof
a704da7471 Typo 2024-03-07 04:46:39 +01:00
savagebidoof
253345f99f shouldn't be commented 2024-03-07 04:35:54 +01:00
savagebidoof
0c16a178e5 Added "is_proxmox_vm" and "setup_only" to prevent joining/creating a kubernetes cluster 2024-03-07 04:35:41 +01:00
savagebidoof
d62eaa0014 Increased kubernetes version to 1.29 2024-03-07 04:21:34 +01:00
savagebidoof
e8d529ac61 Updated manifests version, in the future will be moved to helm. 2024-03-07 04:20:45 +01:00
savagebidoof
54147126fb Playbook wasn't using then user variable to format the command. 2024-01-17 10:41:29 +01:00
savagebidoof
a9b93c6407 Replaces asc key for gpg. (kubernetes repo related.) 2024-01-14 00:17:49 +01:00
savagebidoof
e47d5d6498 Added installing step to install sudo. 2024-01-14 00:17:04 +01:00
savagebidoof
b0ace19010 Updated Kubernetes repo to math version .28, instead of targeting the old one. 2024-01-13 02:26:08 +01:00
savagebidoof
359b9405e9 Just removed 2 spaces, literally who cares. 2023-12-14 18:08:32 +01:00
savagebidoof
3f378c1d8e Insignificant changes.
Added install for `nfs-common` package, required for NFS mounting.
2023-12-14 02:45:28 +01:00
savagebidoof
1103475ea7 Forgot this uncommented. 2023-12-13 18:03:45 +01:00
savagebidoof
1986a71118 Added support for x64 bit Debian. 2023-12-13 17:14:13 +01:00
savagebidoof
6902681907 Used it for my home thingie, some quality improvements.
Need to document the changes on the README.md.
2023-08-01 20:00:14 +02:00
savagebidoof
7358da26d8 Updated date. 2023-08-01 15:40:03 +02:00
savagebidoof
7144c2d74b Commit 2023-08-01 15:39:36 +02:00
13 changed files with 362 additions and 228 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
# 12/03/2023
# 01/08/2023
# Intended for armbian (bullseye, fuck ubuntu tho)
- name: Pre Setup
hosts: all
@@ -8,44 +8,113 @@
vars:
# Connect
ansible_user: "root"
ansible_password: "1234"
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: "my_user"
new_user_password: "my_password"
new_root_password: "my_root_password"
## Locales
new_locale: "en_US.UTF-8"
new_language: "en_US.UTF-8"
new_timezone: "Europe/Madrid"
# SSH with ROOT
tasks:
# Install sudo and locale thingies
- name: ping
ping:
# Install locale thingies and configure sudo for the new user
- name: apt update
ansible.builtin.apt:
update_cache: yes
#
- name: apt upgrade
ansible.builtin.apt:
name: "*"
state: latest
- name: Install sudo
#
- name: Install locale thingies and sudo
ansible.builtin.apt:
pkg:
- sudo
- locales
- locales-all
#
# - name: update facts
# setup:
#
# # Wheel group with sudo access
# # https://stackoverflow.com/a/33362805
- name: Make sure we have a 'wheel' group
group:
name: wheel
state: present
- name: update facts
setup:
# Set locale
- name: Allow 'wheel' group to have passwordless sudo
ansible.builtin.lineinfile:
dest: /etc/sudoers
state: present
regexp: '^%wheel'
line: '%wheel ALL=(ALL) PASSWD: ALL'
validate: visudo -cf %s
# # Create `orangepi` (or whatever user u want to create) user (will bother about it later) # maybe move to -> kuser (kluster user)?
- name: Add user new_user_name
ansible.builtin.user:
name: "{{ new_user_name }}"
password: "{{ new_user_password | password_hash }}"
shell: /bin/bash
#
#
- name: adding user '{{ new_user_name }}' to group wheel
ansible.builtin.user:
name: '{{ new_user_name }}'
groups: sudo
append: yes
- name: Select new user
set_fact:
ansible_user: "{{ new_user_name }}"
ansible_password: "{{ new_user_password }}"
# Set root password to whatever shit
- name: Change root default password
ansible.builtin.user:
name: root
password: "{{ new_root_password | password_hash }}"
# Disable SSH with ROOT
- name: PermitRootLogin = no
ansible.builtin.lineinfile:
dest: /etc/ssh/sshd_config
regexp: '^PermitRootLogin'
line: PermitRootLogin no
backrefs: yes
# Disable SSH with empty password users
- name: PermitEmptyPasswords = no
ansible.builtin.lineinfile:
dest: /etc/ssh/sshd_config
regexp: '^PermitEmptyPasswords'
line: PermitEmptyPasswords = no
backrefs: yes
# Set locale
# https://serverfault.com/a/981742
# https://andreas.scherbaum.la/blog/archives/941-Configuring-locales-in-Debian-and-Ubuntu,-using-Ansible-Reloaded.html
- name: Ensure localisation files for '{{ new_locale }}' are available
@@ -74,64 +143,14 @@
- name: Configure locale to '{{ new_locale }}' and language to '{{ new_language }}'
command: localectl set-locale LANG={{ new_locale }} LANGUAGE={{ new_language }}
# changed_when: locale_lang != new_locale or locale_language != new_language
# become: yes # no idea if it's needed nor I care about
# become: yes # no idea if it's needed, nor I care about
# Wheel group with sudo access
# https://stackoverflow.com/a/33362805
- name: Make sure we have a 'wheel' group
group:
name: wheel
state: present
# become: true
- name: Set timezone
command: timedatectl set-timezone {{ new_timezone }}
- name: Allow 'wheel' group to have passwordless sudo
ansible.builtin.lineinfile:
dest: /etc/sudoers
state: present
regexp: '^%wheel'
line: '%wheel ALL=(ALL) PASSWD: ALL'
validate: visudo -cf %s
# become: true
# Create `orangepi` (or whatever user u want to create) user (will bother about it later) # maybe move to -> kuser (kluster user)?
- name: Add user new_user_name
ansible.builtin.user:
name: "{{ new_user_name }}"
password: "{{ new_user_pass | password_hash }}"
shell: /bin/bash
# become: true
- name: adding user '{{ new_user_name }}' to group wheel
ansible.builtin.user:
name: '{{ new_user_name }}'
groups: sudo
append: yes
# become: true
# Set root password to whatever shit
- name: Change root default password
ansible.builtin.user:
name: root
password: "{{ new_root_pass | password_hash }}"
# become: yes
# Disable SSH with ROOT
- name: PermitRootLogin = no
ansible.builtin.lineinfile:
dest: /etc/ssh/sshd_config
regexp: '^PermitRootLogin'
line: PermitRootLogin = no
backrefs: yes
# become: yes
# REBOOT
# REBOOT
- name: reboot
ansible.builtin.reboot:
# ansible.builtin.shell: 'sleep 1 && dhclient -r && dhclient && reboot'
ignore_unreachable: true
# become: yes
# become: no
# ansible.builtin.shell: 'sleep 1 && dhclient -r && dhclient && reboot'

View File

@@ -1,11 +1,18 @@
# Intended for OrangePI5 **(might work on other devices)**
- Tested on [ARMBIAN](https://www.armbian.com/orangepi-5/) Bullseye
- Previously on the [orangepi](http://www.orangepi.org/html/hardWare/computerAndMicrocontrollers/service-and-support/Orange-pi-5.html) official Debian versions, but can't **confirm still works**
- Previously on the [orangepi](http://www.orangepi.org/html/hardWare/computerAndMicrocontrollers/service-and-support/Orange-pi-5.html)
# Requirements
- Create a username named "orangepi" with password "orangepi".
- Install `sudo`.
- Allow the user "orangepi" to have access to sudo.
- The user "orangepi" will be later deleted, so it's fine.
# Files
```yaml
arm_initial_setup.yaml: standalone playbook to normalize the initialization of an ARMBIAN device
@@ -17,7 +24,9 @@ ksetup/:
- tasks_master.yaml
- tasks_slave.yaml
- tasks_end.yaml
- kubeadm-join.command
- Exported:
- kubeadm-join.command (exported file)
- kubeconfig.conf (exported file)
inventory.yaml: Example inventory
```
@@ -36,6 +45,8 @@ For more info regarding Ansible Inventory, refer to their [documentation regardi
It will:
- `apt-get update && apt-get upgrade`
- Install locale tools and `sudo`.
- Set the `loacale` for the ROOT user
- Set the `language` for the ROOT user
- Create the `wheel` group
@@ -44,13 +55,18 @@ It will:
- Add the new user to the `wheel` group
- Change the ROOT password
- Disable SSH login to the ROOT user
- Executes `sleep 1 && dhclient -r && dhclient && reboot`. The `dhclient` is for my own usage so **modify it if it bothers you**.
- Reboots the device and ignores if you can't connect back, why? Cause might receive a different IP from the DHCP client. This is convenient for myself.
### Vars
A reminder that the point of this script, is to normalize the process of setting up a **fresh** ARMBIAN OS.
```yaml
# Initial Setup
initial_username: username used to to the first connection
initial_password: password used to to the first connection
# Connect
ansible_user: User used to connect
ansible_password: Password used to connect
@@ -82,7 +98,9 @@ ansible_become_password: Password used to execute `sudo`
# Actual vars
set_hostname: New hostname for the device, by default will obtain it's values from the variable `ansible_host` aka. the URL specified to connect to such device.
is_master: This variable determines which playbooks will run.
is_master: This variable determines which playbooks will run. (default false)
is_proxmox_vm: If true it will install the quemu agent for monitoring. (default false)
setup_only: If true will prevent creating/joining a kubernetes cluster.
# Cluster shit
kubeadm_join_path: File path that will store the `kubeadm join` command to be executed by the worker nodes.
@@ -97,9 +115,10 @@ _kubeadm_join_command: Placeholder, will be populated at later stages of the scr
- Update -> Upgrade.
- Uninstalls `containerd`.
- Installs Docker (Debian) and Kubernetes repos.
- Installs `containerd.io`, `kubelet`, `kubeadm`, `kubectl`, `git`, `vim`.
- Installs `containerd.io`, `kubelet`, `kubeadm`, `kubectl`, `git`, `vim`. (and others)
- If the variable `is_proxmox_vm` is set to true, will also install the quemu agent.
- Sets default config for `containerd` with cGroups enabled.
- Enables some `iptables`.
- Enables some `iptables` modules.
- "Resets" `/etc/hosts` file
#### tasks_master.yaml
@@ -107,24 +126,28 @@ _kubeadm_join_command: Placeholder, will be populated at later stages of the scr
##### Will only be executed if the variable `is_master` is set to `True`
- Executes `kubeadm init` aka initializes the node without further arguments assigned.
- Sets the `kubectl` conf to the user specified.
- Deploys `Calico` network plugin (might change in the future)
- Export the `kubeconfig` file.
- Removes `node-role.kubernetes.io/control-plane` taint to allow deploying containers in the control plane node.
- Generates a "join cluster" command and stores it in a file **LOCALLY** as `kubeadm-join.command`, this file will be later used by the slave nodes, who will execute this file's contents.
- Deploys `Calico` CNI network plugin.
- Deploys `MetalLB` CRDs.
- Generates a "join cluster" command and stores it in a file **LOCALLY** as `/Exported/ubeadm-join.command`, this file will be later used by the slave nodes, who will execute this file's contents.
#### tasks_slave.yaml
##### Will only be executed if the variable `is_master` is set to `False`
- Executes the "command" stored in the file `kubeadm-join.command` located **LOCALLY**.
- Executes the "command" stored in the file `./Exported/kubeadm-join.command` located **LOCALLY**.
#### tasks_end.yaml
- As per the moment, only reboots.
- As per the moment, deletes the "default user specified" (usually orangepi, on my scenario atleast) then reboots the system.
# USAGE
## Update Calico/MetalLB versions
Open the file `tasks_master.yaml` and update the .yaml files for Calico and MetalLB to match the desired/newer versions.
## Setup
On my infrastructure/environment, **I** use a DHCP and DNS to connect / communicate the nodes.
@@ -143,6 +166,16 @@ dd if=Armbian_23.02.2_Orangepi5_bullseye_legacy_5.10.110_minimal.img of=/dev/sdg
### arm_initial_setup.yaml
#### Log in Values
I set up the variables on the `inventory.yaml` file.
```yaml
initial_username: username used to to the first connection
initial_password: password used to to the first connection
```
#### Change the values of the desired variables
@@ -168,14 +201,10 @@ ansible_user: "root"
ansible_password: "1234"
```
## Run (?)
# License
## DWTFUW

View File

@@ -1,11 +1,22 @@
masters:
hosts:
pi4.filter.home:
# masterk.filter.home:
vars:
is_master: yes
#slaves:
#masters:
# hosts:
# slave[01:01].filter.home:
# pi4.filter.home:
# vars:
# is_master: no
# is_master: yes
# initial_username: root
# initial_password: ""
# delete_user_name: orangepi
slaves:
hosts:
slave[04:04].filter.home:
vars:
is_master: no
is_proxmox_vm: true
# setup_only: false
initial_username: orangepi
initial_password: orangepi
delete_user_name: orangepi
all:
vars:
kubernetes_version: 1.32

View File

View File

@@ -1,7 +1,7 @@
# Author: Oriol Filter
# 11/03/2023
# 13/12/2023
# Intended for armbian (bullseye, fuck ubuntu tho) it's aarch64
# Maybe still works for orangepi "official" versions, but I don't care about them unless I used soooooo... gl!
# Maybe still works for orangepi "official" versions, but I only care of make it work for myself soooooo... gl!
# https://medium.com/karlmax-berlin/how-to-install-kubernetes-on-raspberry-pi-53b4ce300b58
- name: Preparethings
order: inventory
@@ -10,39 +10,54 @@
vars:
# Testing purposes
ansible_user: "kuser" # Testing purposes
ansible_password: "kuser1234" # Testing purposes
ansible_user: "adminuser" # Testing purposes
ansible_password: "adminpassword" # Testing purposes
ansible_become_password: "{{ ansible_password }}" # Testing purposes
# Kubernetes version
target_kubernetes_version: "{{ kubernetes_version }}" # Testing purposes
# Actual vars
set_hostname: "{{ ansible_host }}"
# is_master: Figurative
# Cluster shit
kubeadm_join_path: "./kubeadm-join.command"
_kubeadm_join_command: "" #placeholder
kubeadm_join_path: "./Exported/kubeadm-join.command"
_kubeadm_join_command: "" # Placeholder
# Others
_is_master: "{{ is_master | default('false') | bool }}" # Prevent creating/joining a cluster
_is_proxmox_vm: "{{ is_proxmox_vm | default('false') | bool }}" # Prevent creating/joining a cluster
_setup_only: "{{ setup_only | default('false') | bool }}" # Prevent creating/joining a cluster
tasks:
## - check vars
# - debug: var=set_hostname
# - debug: var=is_master
#
## Init / Basic setup
# - name: set up node
# import_tasks: tasks_prepare_node.yaml
# become: true
# check vars
- debug: var=set_hostname
- debug: var=_is_master
- debug: var=_is_proxmox_vm
- debug: var=_setup_only
- debug: var=target_kubernetes_version
# If is_master: init
- name: Ping check
ping:
# Init / Basic setup
- name: set up node
import_tasks: tasks_prepare_node.yaml
become: true
# If _is_master: init
- name: init cluster
import_tasks: tasks_master.yaml
when: is_master
#
## else: join
# - name: join cluster
# import_tasks: tasks_slave.yaml
# when: not is_master
#
## Do other stuff
# - name: post setup
# import_tasks: tasks_end.yaml
when: _is_master and not _setup_only
become: true
# else: join
- name: join cluster
import_tasks: tasks_slave.yaml
when: not _is_master and not _setup_only
# Do other stuff
- name: post setup
import_tasks: tasks_end.yaml
become: true

View File

@@ -1,3 +1,37 @@
# https://stackoverflow.com/questions/46515704/how-to-kill-a-running-process-using-ansible
- name: Get running processes
shell: "ps -ef | grep -v grep | grep -w ^{{ delete_user_name }} | awk '{print $2}'"
register: running_processes
when: delete_user_name is defined and delete_user_name | length > 0
- name: Debug Running processes
debug: var=running_processes
- name: Kill running processes
shell: "kill {{ item }}"
with_items: "{{ running_processes.stdout_lines }}"
when: (delete_user_name is defined) and (delete_user_name | length > 0) and (running_processes | length > 0)
- wait_for:
path: "/proc/{{ item }}/status"
state: absent
with_items: "{{ running_processes.stdout_lines }}"
ignore_errors: yes
register: killed_processes
when: (delete_user_name is defined) and (delete_user_name | length > 0) and (running_processes | length > 0)
- name: Force kill stuck processes
shell: "kill -9 {{ item }}"
with_items: "{{ killed_processes.results | select('failed') | map(attribute='item') | list }}"
when: (delete_user_name is defined) and (delete_user_name | length > 0) and (running_processes | length > 0)
- name: Delete user
ansible.builtin.user:
name: "{{ delete_user_name }}"
remove: true
state: absent
when: delete_user_name is defined and delete_user_name | length > 0
#reboot
- name: reboot

View File

@@ -1,84 +1,49 @@
## Init
#- name: Init cluster
# ansible.builtin.command: "kubeadm init"
# become: true
- name: Init cluster
ansible.builtin.command: "kubeadm init"
### get kubectl file
## Export kubeconfig file
- name: Export remote kubeconfig file
ansible.builtin.fetch:
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 --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
ansible.builtin.command: "kubectl create --kubeconfig /etc/kubernetes/admin.conf -f https://raw.githubusercontent.com/projectcalico/calico/v3.27.2/manifests/calico.yaml"
## 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
ansible.builtin.command: "kubectl create --kubeconfig /etc/kubernetes/admin.conf -f https://raw.githubusercontent.com/metallb/metallb/v0.14.3/config/manifests/metallb-native.yaml"
#- name: Calico custom
# ansible.builtin.command: "kubectl create --kubeconfig /etc/kubernetes/admin.conf -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.1/manifests/custom-resources.yaml"
# become: true
## Export join command
- name: Generate join token
shell: kubeadm token create --kubeconfig /etc/kubernetes/admin.conf --print-join-command
register: kubeadm_join_cmd
- set_fact:
kubeadm_join_command: "{{ kubeadm_join_cmd.stdout }}"
## Set kubectl tool
#- user:
# name: "{{ ansible_user_id }}"
# state: present
# register: user_info_registered
#- name: create .kube directory
# become: yes
# become_user: "{{ ansible_user_id }}"
# file:
# path: "{{ user_info_registered.home }}/.kube"
# state: directory
# mode: 0755
#- debug: var=user_info_registered.home
#- name: copy admin.conf to user's kube config
# copy:
# src: /etc/kubernetes/admin.conf
# remote_src: yes
# dest: "{{ user_info_registered.home }}/.kube/config"
# owner: "{{ ansible_user_id }}"
# become: true
## Network Plugin
#- name: Calico
# ansible.builtin.command: "kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/calico.yaml"
#
## Remove taints
#- name: Remove Taint (allows deployment in control plane)
# ansible.builtin.shell: "kubectl taint nodes --all node-role.kubernetes.io/control-plane-"
#
## Join token / command
#- name: Generate join token
# shell: kubeadm token create --print-join-command
# register: kubeadm_join_cmd
#
#- set_fact:
# kubeadm_join_command: "{{ kubeadm_join_cmd.stdout }}"
#
#- debug: var=kubeadm_join_command
#
#- name: Store join command in "{{ kubeadm_join_path }}"
# copy:
# dest: "{{ kubeadm_join_path }}"
# content: |
# {{ kubeadm_join_command }}
# delegate_to: localhost
- debug: var=kubeadm_join_command
- name: Store join command in "{{ kubeadm_join_path }}"
copy:
dest: "{{ kubeadm_join_path }}"
content: |
{{ kubeadm_join_command }}
delegate_to: localhost
become: false

View File

@@ -4,7 +4,6 @@
ansible.builtin.hostname:
name: "{{ set_hostname }}"
# Swap
- name: Swapoff
ansible.builtin.command: swapoff -a
@@ -25,21 +24,32 @@
- ansible_architecture == "aarch64"
- ansible_distribution | lower == "ubuntu" or ansible_distribution | lower == "debian"
- name: Sed when x86_64
ansible.builtin.command: sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
when:
- ansible_architecture == "x86_64"
- ansible_distribution | lower == "ubuntu" or ansible_distribution | lower == "debian"
# INTENDED FOR ARM DISTROS FUCK U
#- name: Sed when x86_64
# ansible.builtin.command: sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
# when: ansible_architecture == "x86_64"
- name: Sed when x86_64 (needed for ubuntu server atleast)
ansible.builtin.command: sed -i 's/^\/swap.img.*/##&/' /etc/fstab
when:
- ansible_architecture == "x86_64"
- ansible_distribution | lower == "ubuntu" or ansible_distribution | lower == "debian"
# Packages
# Delete default containerd
## Looking forward the version 1.6
- name: apt prune containerd
## Delete default containerd and kuberelated thingies
- name: apt prune containerd and other kube related
ansible.builtin.apt:
name: containerd
name:
- containerd
- kubelet
- kubeadm
- kubectl
state: absent
purge: true
allow_change_held_packages: true
## BnB
- name: apt update
@@ -65,27 +75,36 @@
mode: '0755'
# ignore_errors: true
## Docker repo
## Docker repo ARM/x64
- name: Add Docker GPG key
apt_key:
url: https://download.docker.com/linux/debian/gpg
state: present
- name: Add Docker APT repository
- name: Add Docker APT repository (ARM Arch)
apt_repository:
repo: deb [arch=arm64] https://download.docker.com/linux/debian bullseye stable
state: present
when:
- ansible_architecture == "aarch64"
## Kubeshit repo
- name: Add Docker APT repository (x64 Arch)
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/debian bullseye stable
state: present
when:
- ansible_architecture == "x86_64"
# Kubeshit repo
- name: Add Kubernetes GPG key
apt_key:
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
url: "https://pkgs.k8s.io/core:/stable:/v{{ target_kubernetes_version }}/deb/Release.key"
state: present
keyring: "/etc/apt/keyrings/kubernetes-apt-keyring-{{ target_kubernetes_version }}.gpg"
- name: Add Kubernetes APT repository
apt_repository:
repo: deb https://apt.kubernetes.io/ kubernetes-xenial main
repo: "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring-{{ target_kubernetes_version }}.gpg] https://pkgs.k8s.io/core:/stable:/v{{ target_kubernetes_version }}/deb/ /"
state: present
@@ -100,6 +119,7 @@
- kubelet
- kubeadm
- kubectl
- nfs-common # Required for NFS mounts
- git # fuck it, you will need it, maybe
- vim # fuck it, I need it.
@@ -180,7 +200,7 @@
name: containerd
enabled: true
### Restart
### Restart containerd
- name: Enable kubelet
ansible.builtin.systemd:
name: kubelet
@@ -206,3 +226,16 @@
ff02::2 ip6-allrouters
## ProxmoxVM related
- name: Install quemu-guest-agent
ansible.builtin.apt:
pkg:
- qemu-guest-agent
when: is_proxmox_vm
- name: Enable quemu-guest-agent
ansible.builtin.systemd:
name: qemu-guest-agent
enabled: true
# Quemu requires to be enabled on the Proxmox VM, after installing also requires to be shut down, and started again from the Proxmox GUI

View File

@@ -1,8 +1,8 @@
- 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
- name: Join kubeadm (this can take a while ... like 20 mins?? idk. probably lot less)
ansible.builtin.command: "{{ _kubeadm_join_command }}"
become: yes

View File

@@ -1,21 +0,0 @@
# Main issues I ran into
## kubeadm init
### Something something API V1
Probably ~~(surely)~~ the `containerd` version you are using is 1.4 something, that's due being the default version installed / from the default repositories.
To fix it, install `containerd.io`.
If currently can't find `containerd.io`, follow the [Set up the repository](https://docs.docker.com/engine/install/debian/#install-using-the-repository) to set up the repositories and finally run `apt-get install containerd.io`
You can check the version by running `containerd --version`
## CNI plugin initializing
Wait, if after a while it still this way, confirm that you actually deployed the (right) network plugin.
```shell
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/calico.yaml
```

7
run.sh
View File

@@ -1,11 +1,8 @@
#!/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 $IP, Initial_Setup/armbian_initial_setup.yaml && sleep 25 # Wait for reboot
ansible-playbook -i inventory.yaml Initial_Setup/armbian_initial_setup.yaml && printf "Giving some time (40s) to catch up to the reboot command ...\n" &&
sleep 40 && # Wait for reboot
ansible-playbook -i inventory.yaml ksetup/playbook.yaml