-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ansible): add k3s role and update with monitoring k3s cluster
- Loading branch information
Showing
10 changed files
with
90 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
files/* | ||
**secret** | ||
venv | ||
kubeconfig | ||
kubeconfigs/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
kubeconfig_path: "../kubeconfigs" | ||
k3s_version: v1.29.3+k3s1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
k3s_server_args: "--disable traefik --embedded-registry --node-name controlplane" | ||
k3s_taint_controlplane: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- name: Setup k3s | ||
hosts: controlplane | ||
roles: | ||
- k3s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
- name: Install k3s server | ||
ansible.builtin.import_tasks: | ||
file: server.yml | ||
vars: | ||
hostname: "{{ inventory_hostname }}" | ||
when: inventory_hostname in groups['controlplane'] | ||
- name: Install k3s worker | ||
ansible.builtin.import_tasks: | ||
file: worker.yml | ||
vars: | ||
hostname: "{{ inventory_hostname }}-k3s" | ||
when: inventory_hostname in groups['workers'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
- name: Fetch tailscale ip for {{ hostname }} | ||
delegate_to: localhost | ||
delegate_facts: true | ||
ansible.builtin.command: "tailscale ip -4 {{ hostname }}" | ||
register: tailscale_ip | ||
changed_when: false | ||
- name: Install k3s server | ||
delegate_to: localhost | ||
delegate_facts: true | ||
vandot.k3sup.k3sup: | ||
k3sup_bin: /opt/homebrew/bin/k3sup | ||
action: server | ||
user: "{{ ansible_ssh_user }}" | ||
ip: "{{ tailscale_ip.stdout | trim }}" | ||
ssh_key: "~/.ssh/terraform" | ||
local_path: "{{ kubeconfig_path }}/kubeconfig-{{ inventory_hostname }}" | ||
context: "{{ inventory_hostname }}" | ||
k3s_extra_args: "{{ k3s_server_args | quote }}" | ||
k3s_version: "{{ k3s_version }}" | ||
- name: Taint the controlplane node | ||
when: "k3s_taint_controlplane" | ||
ansible.builtin.shell: "kubectl taint nodes controlplane node-role.kubernetes.io/control-plane:NoSchedule" | ||
delegate_to: localhost | ||
delegate_facts: true | ||
environment: | ||
KUBECONFIG: "{{ kubeconfig_path }}" | ||
changed_when: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
- name: Fetch tailscale ip for "controlplane-k3s" | ||
ansible.builtin.command: "tailscale ip -4 controlplane-k3s" | ||
register: k3s_server_ip | ||
changed_when: false | ||
delegate_to: localhost | ||
delegate_facts: true | ||
|
||
- name: Fetch tailscale ip for {{ hostname }} | ||
ansible.builtin.command: "tailscale ip -4 {{ hostname }}" | ||
register: tailscale_ip | ||
changed_when: false | ||
delegate_to: localhost | ||
delegate_facts: true | ||
|
||
- name: Join k3s worker {{ hostname }} | ||
delegate_to: localhost | ||
delegate_facts: true | ||
vandot.k3sup.k3sup: | ||
k3sup_bin: /opt/homebrew/bin/k3sup | ||
action: agent | ||
ip: "{{ tailscale_ip.stdout | trim }}" | ||
server_ip: "{{ k3s_server_ip.stdout | trim }}" | ||
ssh_key: "~/.ssh/proxmox" | ||
k3s_version: "{{ k3s_version }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters