Compare commits

..

13 Commits

17 changed files with 81 additions and 30 deletions
+1
View File
@@ -3,6 +3,7 @@
terraform.tfstate terraform.tfstate
terraform.tfstate.backup terraform.tfstate.backup
ansible/lookup_plugins ansible/lookup_plugins
ansible/galaxy_roles
!.gitignore !.gitignore
!.editorconfig !.editorconfig
+7 -3
View File
@@ -4,16 +4,17 @@ opentofu_dir := "infra/"
ansible_proton_pass_plugin_ref := "4bd0741c347646060ec59c73f8adf7ed8e706cf3" ansible_proton_pass_plugin_ref := "4bd0741c347646060ec59c73f8adf7ed8e706cf3"
ansible_proton_pass_plugin_url := "https://raw.githubusercontent.com/protonpass/proton-pass-ansible-integration/" + ansible_proton_pass_plugin_ref + "/lookup_plugins/proton_pass.py" ansible_proton_pass_plugin_url := "https://raw.githubusercontent.com/protonpass/proton-pass-ansible-integration/" + ansible_proton_pass_plugin_ref + "/lookup_plugins/proton_pass.py"
init: tofu-init fetch-ansible-deps fetch-ansible-plugins
up: tofu-apply ansible-run-playbook up: tofu-apply ansible-run-playbook
down: tofu-destroy down: tofu-destroy
tofu-init: tofu-init:
tofu -chdir={{ opentofu_dir }} init -upgrade tofu -chdir={{ opentofu_dir }} init -upgrade
tofu-apply: tofu-init tofu-apply:
tofu -chdir={{ opentofu_dir }} apply -auto-approve tofu -chdir={{ opentofu_dir }} apply -auto-approve
tofu-destroy: tofu-init tofu-destroy:
tofu -chdir={{ opentofu_dir }} apply -auto-approve -destroy tofu -chdir={{ opentofu_dir }} apply -auto-approve -destroy
tofu-destroy-instances: tofu-destroy-instances:
@@ -30,6 +31,9 @@ headlamp:
clean: tofu-destroy clean: tofu-destroy
git clean -fdx git clean -fdx
fetch-plugins: fetch-ansible-deps:
ansible-galaxy install --role-file ansible/requirements.yml --roles-path ansible/galaxy_roles
fetch-ansible-plugins:
mkdir -p ansible/lookup_plugins mkdir -p ansible/lookup_plugins
curl -fsSL -o ansible/lookup_plugins/proton_pass.py {{ ansible_proton_pass_plugin_url }} curl -fsSL -o ansible/lookup_plugins/proton_pass.py {{ ansible_proton_pass_plugin_url }}
+11 -2
View File
@@ -1,5 +1,8 @@
# Home Infrastructure # Home Infrastructure
An Ansible + OpenTofu project for installing a minimal Kubernetes installation
to bare-metal and virtual machines.
## Quick Start ## Quick Start
Get started with a local Kubernetes cluster which can be used to design and test Get started with a local Kubernetes cluster which can be used to design and test
@@ -13,13 +16,19 @@ new configuration before pushing them to real machines.
export SSH_AUTH_SOCK="$HOME/.ssh/proton-pass-agent.sock" export SSH_AUTH_SOCK="$HOME/.ssh/proton-pass-agent.sock"
``` ```
2. Launch Incus virtual machines 2. Install the Proton Pass plugin for Ansible
```shell
just fetch-plugins
```
3. Launch Incus virtual machines
```shell ```shell
just up just up
``` ```
3. Tear down the Incus virtual machines 4. Tear down the Incus virtual machines
```shell ```shell
just down just down
+1
View File
@@ -1,3 +1,4 @@
[defaults] [defaults]
roles_path = ansible/roles:ansible/galaxy_roles
lookup_plugins = ansible/lookup_plugins lookup_plugins = ansible/lookup_plugins
callback_result_format = yaml callback_result_format = yaml
@@ -1,8 +0,0 @@
masters:
hosts:
vineta:
ansible_host: 10.0.0.201
rotfront:
ansible_host: 10.0.0.202
leng:
ansible_host: 10.0.0.203
@@ -3,5 +3,6 @@ ansible_become_exe: sudo.ws
ansible_user: kolibri ansible_user: kolibri
vip_interface: eno1 vip_interface: eno1
vip_address: 10.0.0.200 vip_address: 10.0.0.200
cluster_name: hive
cluster_pod_subnet: 172.16.0.0/16 cluster_pod_subnet: 172.16.0.0/16
cluster_service_subnet: 10.96.0.0/16 cluster_service_subnet: 10.96.0.0/16
+8
View File
@@ -0,0 +1,8 @@
masters:
hosts:
vineta:
ansible_host: vineta.local
rotfront:
ansible_host: rotfront.local
leng:
ansible_host: leng.local
@@ -2,5 +2,6 @@ ansible_python_interpreter: /usr/bin/python3
ansible_user: kolibri ansible_user: kolibri
vip_interface: enp5s0 vip_interface: enp5s0
vip_address: 10.150.0.100 vip_address: 10.150.0.100
cluster_name: hive
cluster_pod_subnet: 172.16.0.0/16 cluster_pod_subnet: 172.16.0.0/16
cluster_service_subnet: 10.96.0.0/16 cluster_service_subnet: 10.96.0.0/16
+7
View File
@@ -0,0 +1,7 @@
---
- name: Configure performance tuning
hosts: all
become: true
roles:
- giovtorres.tuned
- irqbalance
+1
View File
@@ -10,6 +10,7 @@
groups: groups:
- sudo - sudo
shell: /bin/bash shell: /bin/bash
system: true
- name: Ensure authorised keys for Kolibri - name: Ensure authorised keys for Kolibri
ansible.posix.authorized_key: ansible.posix.authorized_key:
+6
View File
@@ -0,0 +1,6 @@
---
collections:
- ansible.posix
roles:
- name: giovtorres.tuned
version: 2.0.2
+11
View File
@@ -0,0 +1,11 @@
---
- name: Install irqbalance
ansible.builtin.package:
name: irqbalance
state: present
- name: Ensure irqbalance service
ansible.builtin.service:
name: irqbalance
state: started
enabled: true
@@ -2,13 +2,13 @@
ansible.builtin.import_tasks: kube-vip.yaml ansible.builtin.import_tasks: kube-vip.yaml
- name: Initialise Kubernetes cluster - name: Initialise Kubernetes cluster
ansible.builtin.include_tasks: init-cluster.yaml ansible.builtin.import_tasks: init-cluster.yaml
- name: Join nodes as control planes - name: Join nodes as control planes
ansible.builtin.include_tasks: join-cluster.yaml ansible.builtin.import_tasks: join-cluster.yaml
- name: Copy Kubernetes admin configuration on all nodes - name: Copy Kubernetes admin configuration on all nodes
ansible.builtin.include_tasks: copy-config.yaml ansible.builtin.import_tasks: copy-config.yaml
- name: Remove control plane scheduling restrictions - name: Remove control plane scheduling restrictions
ansible.builtin.include_tasks: untaint.yaml ansible.builtin.import_tasks: untaint.yaml
@@ -4,7 +4,7 @@ kind: InitConfiguration
--- ---
apiVersion: kubeadm.k8s.io/v1beta4 apiVersion: kubeadm.k8s.io/v1beta4
kind: ClusterConfiguration kind: ClusterConfiguration
clusterName: aeon clusterName: "{{ cluster_name }}"
controlPlaneEndpoint: "{{ vip_address }}" controlPlaneEndpoint: "{{ vip_address }}"
networking: networking:
podSubnet: "{{ cluster_pod_subnet }}" podSubnet: "{{ cluster_pod_subnet }}"
+3 -4
View File
@@ -1,3 +1,6 @@
- name: Apply power and performance settings
ansible.builtin.import_playbook: playbooks/performance.yaml
- name: Baseline configuration - name: Baseline configuration
hosts: all hosts: all
become: true become: true
@@ -5,10 +8,6 @@
- common - common
- kubernetes_common - kubernetes_common
# ========================
# Setup Kubernetes Cluster
# ========================
- name: Initialise Kubernetes Cluster - name: Initialise Kubernetes Cluster
hosts: masters hosts: masters
become: true become: true
+4 -8
View File
@@ -3,14 +3,10 @@
# ------ # ------
locals { locals {
image = "ubuntu/26.04"
root_disk_size = "16GiB" root_disk_size = "16GiB"
ext_disk_size = "16GiB" ext_disk_size = "16GiB"
network_cidr = "10.150.0.1/24" network_cidr = "10.150.0.1/24"
master_count = 3
worker_count = 0
image = "ubuntu/26.04"
} }
# --------- # ---------
@@ -46,7 +42,7 @@ resource "incus_network" "this" {
module "master" { module "master" {
source = "./modules/incus_vm" source = "./modules/incus_vm"
count = local.master_count count = var.master_count
name = "master-${count.index}" name = "master-${count.index}"
project = incus_project.this.name project = incus_project.this.name
@@ -60,7 +56,7 @@ module "master" {
module "worker" { module "worker" {
source = "./modules/incus_vm" source = "./modules/incus_vm"
count = local.worker_count count = var.worker_count
name = "worker-${count.index}" name = "worker-${count.index}"
project = incus_project.this.name project = incus_project.this.name
@@ -77,7 +73,7 @@ module "worker" {
# --------- # ---------
terraform { terraform {
required_version = "~> 1.12" required_version = ">= 1.11.5"
required_providers { required_providers {
incus = { incus = {
+14
View File
@@ -1,3 +1,17 @@
variable "master_count" {
description = "The number of master nodes to provision."
type = number
default = 1
nullable = false
}
variable "worker_count" {
description = "The number of worker nodes to provision."
type = number
default = 0
nullable = false
}
variable "cpus" { variable "cpus" {
description = "The number of CPU cores allocated to each virtual machine." description = "The number of CPU cores allocated to each virtual machine."
type = number type = number