Compare commits

...

22 Commits

Author SHA1 Message Date
jaydee 05d7f3316b build
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
2026-02-23 19:52:20 +01:00
jaydee d47a02d5f2 build 2026-02-23 19:46:12 +01:00
jaydee ab1b7af118 build 2026-02-23 19:41:14 +01:00
jaydee 8914854c68 build 2026-02-23 16:27:27 +01:00
jaydee 81740547f0 build 2026-02-23 16:10:26 +01:00
jaydee d41b8e5153 build 2026-02-23 16:01:03 +01:00
jaydee 97af01e123 build 2026-02-23 15:51:06 +01:00
jaydee c01949f79c build 2026-02-23 15:36:42 +01:00
jaydee 561bc7e9b9 build 2026-02-23 14:19:57 +01:00
jaydee 7719cd394a build 2026-02-23 13:49:33 +01:00
jaydee 3f73c15742 build 2026-02-23 13:20:46 +01:00
jaydee bfa82de297 build 2026-02-23 13:15:18 +01:00
jaydee 59cd001894 build 2026-02-23 13:13:15 +01:00
jaydee 85060a922c build 2026-02-23 13:09:56 +01:00
jaydee 34637b4d80 build 2026-02-23 13:08:04 +01:00
jaydee ba308542ce build 2026-02-23 13:04:05 +01:00
jaydee 2feff74a08 build 2026-02-23 12:58:57 +01:00
jaydee b7caa2cea5 build 2026-02-23 12:55:59 +01:00
jaydee 59e9608d58 build 2026-02-23 12:55:10 +01:00
jaydee 7e29f9ef0a build 2026-02-23 12:47:17 +01:00
jaydee 1c4f663552 build 2026-02-23 12:21:50 +01:00
jaydee c6eda4873b build 2026-02-23 12:16:48 +01:00
5 changed files with 222 additions and 5 deletions
-1
View File
@@ -88,7 +88,6 @@ datacenter:
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_user: jd
ansible_ssh_password: q
ansible_become_method: su
ansible_become_password: q
ansible_ssh_pass: q
ansible_become_user: root
+7
View File
@@ -203,6 +203,13 @@ datacenter:
hosts:
alma10-vm0[1:9].home.lan:
# debian13-vm[10:27].home.lan:
vars:
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_user: jd
ansible_ssh_private_key_file: ssh_key.pem
ubuntu24:
hosts:
ubuntu24-vm0[1:5].home.lan:
vars:
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_user: jd
+4 -4
View File
@@ -1,6 +1,5 @@
- name: Init
become: "{{ 'no' if inventory_hostname in ['sectorq.cloud', 'nas.home.lan'] else 'yes' }}"
become_method: su
block:
- name: Include vault
@@ -25,10 +24,10 @@
append: true
when: group_check is succeeded
- name: Give deploy sudo access
ansible.builtin.copy:
- name: Give jd passwordless sudo
copy:
dest: /etc/sudoers.d/jd
content: "jd ALL=(ALL:ALL) ALL\n"
content: "jd ALL=(ALL) NOPASSWD:ALL\n"
owner: root
group: root
mode: '0440'
@@ -37,6 +36,7 @@
ansible.builtin.user:
name: root
password: "{{ jd_password | password_hash('sha512') }}"
- name: Update become password for subsequent tasks
ansible.builtin.set_fact:
ansible_become_password: "{{ jd_password }}"
+5
View File
@@ -0,0 +1,5 @@
- name: restart containerd
systemd:
name: containerd
state: restarted
enabled: yes
+206
View File
@@ -0,0 +1,206 @@
- name: Install Kubernetes on Ubuntu 24
become: "{{ 'no' if inventory_hostname == 'nas.home.lan' else 'yes' }}"
block:
- name: Update apt cache
apt:
update_cache: yes
- name: Disable swap
command: swapoff -a
when: ansible_swaptotal_mb > 0
- name: Remove swap from fstab
replace:
path: /etc/fstab
regexp: '.*swap.*'
replace: ''
- name: Enable kernel modules
copy:
dest: /etc/modules-load.d/k8s.conf
content: |
overlay
br_netfilter
- name: Load kernel modules
modprobe:
name: "{{ item }}"
state: present
loop:
- overlay
- br_netfilter
- name: Set sysctl params
copy:
dest: /etc/sysctl.d/k8s.conf
content: |
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
- name: Apply sysctl
command: sysctl --system
- name: Install required packages
apt:
name:
- apt-transport-https
- ca-certificates
- curl
- gpg
state: present
- name: Add Kubernetes apt key
shell: |
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key | \
gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
args:
creates: /etc/apt/keyrings/kubernetes-apt-keyring.gpg
- name: Add Kubernetes repository
copy:
dest: /etc/apt/sources.list.d/kubernetes.list
content: |
deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /
- name: Install containerd
apt:
name: containerd
state: present
- name: Configure containerd
shell: |
mkdir -p /etc/containerd
containerd config default > /etc/containerd/config.toml
sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml
args:
creates: /etc/containerd/config.toml
- name: Enable and start containerd
systemd:
name: containerd
enabled: yes
state: started
- name: Install Kubernetes packages
apt:
name:
- kubelet
- kubeadm
- kubectl
state: present
update_cache: yes
register: k8s_install
retries: 5
delay: 10
until: k8s_install is succeeded
- name: Hold Kubernetes packages
command: apt-mark hold kubelet kubeadm kubectl
- name: Enable kubelet
systemd:
name: kubelet
enabled: yes
state: started
# Optional UFW configuration
- name: Ensure UFW is installed
apt:
name: ufw
state: present
when: inventory_hostname == 'ubuntu24-vm01.home.lan'
- name: Allow Kubernetes ports
ufw:
rule: allow
port: "{{ item }}"
proto: tcp
loop:
- 6443
- 2379:2380
- 10250
when: inventory_hostname == 'ubuntu24-vm01.home.lan'
- name: Configure containerd for kubeadm
copy:
dest: /etc/containerd/config.toml
content: |
[plugins."io.containerd.grpc.v1.cri".containerd]
snapshotter = "overlayfs"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
runtime_type = "io.containerd.runc.v2"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
- name: Enable and start containerd
systemd:
name: containerd
state: restarted
- name: Pause for 5 minutes to build app cache
ansible.builtin.pause:
minutes: 2
- name: Create .kube directory
file:
path: /home/{{ ansible_user }}/.kube
state: directory
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: '0755'
when: inventory_hostname == 'ubuntu24-vm01.home.lan'
- name: Initialize Kubernetes
command: sudo kubeadm init --pod-network-cidr=10.244.0.0/16
args:
creates: /etc/kubernetes/admin.conf
when: inventory_hostname == 'ubuntu24-vm01.home.lan'
- name: Copy kubeconfig to user
copy:
remote_src: yes
src: /etc/kubernetes/admin.conf
dest: /home/{{ ansible_user }}/.kube/config
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: '0644'
when: inventory_hostname == 'ubuntu24-vm01.home.lan'
- name: Pause for 5 minutes to build app cache
ansible.builtin.pause:
minutes: 2
- name: Install Flannel CNI
ansible.builtin.command:
cmd: kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml
environment:
KUBECONFIG: /etc/kubernetes/admin.conf
when: inventory_hostname == "ubuntu24-vm01.home.lan"
register: flannel_result
changed_when: "'created' in flannel_result.stdout or 'configured' in flannel_result.stdout"
- name: Get join command
command: sudo kubeadm token create --print-join-command
register: join_command
when: inventory_hostname == 'ubuntu24-vm01.home.lan'
- name: Save join command
set_fact:
worker_join_cmd: "{{ join_command.stdout }}"
when: inventory_hostname == 'ubuntu24-vm01.home.lan'
- name: Join cluster
command: "{{ hostvars['ubuntu24-vm01.home.lan'].worker_join_cmd }}"
args:
creates: /etc/kubernetes/kubelet.conf
when: inventory_hostname != 'ubuntu24-vm01.home.lan'