Skip to content

Commit 5ab2e9a

Browse files
committed
feat: establish wireguard
1 parent bcc3305 commit 5ab2e9a

6 files changed

Lines changed: 43 additions & 2 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.private

‎.mise/conf.d/bootstrap.toml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,12 @@
22
description = "Apply Talos configuration to the cluster"
33
secrets = ["WG_LON1_PRIVATE_KEY"]
44
run = '''
5-
topf --topfconfig "{{ config_root }}/talos/topf.yaml" apply --auto-bootstrap
5+
topf --topfconfig "{{ config_root }}/talos/topf.yaml" apply --auto-bootstrap --confirm=false
6+
'''
7+
8+
[tasks."bootstrap:credentials"]
9+
description = "Fetch credentials for the cluster"
10+
secrets = ["WG_LON1_PRIVATE_KEY"]
11+
run = '''
12+
topf --topfconfig "{{ config_root }}/talos/topf.yaml" apply --auto-bootstrap --confirm=false
613
'''

‎.mise/conf.d/talos.toml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[tasks."talos:credentials"]
2+
run = '''
3+
mkdir -p "{{ vars.creds_dir }}"
4+
{{ vars.topf }} talosconfig > "{{ vars.creds_dir }}/talosconfig"
5+
{{ vars.topf }} kubeconfig --validity 2160h > "{{ vars.creds_dir }}/kubeconfig"
6+
chmod 600 "{{ vars.creds_dir }}/talosconfig"
7+
chmod 600 "{{ vars.creds_dir }}/kubeconfig"
8+
cp="$(yq -e '.nodes[] | select(.role == "control-plane") | (.ip // .host)' "{{ vars.topf_config }}" | head -1)"
9+
cluster_name="$(kubectl --kubeconfig "{{ vars.creds_dir }}/kubeconfig" config view -o jsonpath='{.clusters[0].name}')"
10+
kubectl --kubeconfig "{{ vars.creds_dir }}/kubeconfig" config set-cluster "$cluster_name" --server="https://$cp:6443"
11+
'''
12+
13+
[tasks."talos:apply-node"]
14+
secrets = ["WG_LON1_PRIVATE_KEY"]
15+
usage = '''
16+
arg "<node>" help="The node to apply the configuration to"
17+
'''
18+
run = '''
19+
{{ vars.topf }} apply --nodes-filter "{{ usage.node }}" --allow-not-ready
20+
'''

‎.mise/config.toml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@ fnox = { version = "1.50.0", workflow = "release.yml" }
44
jactionlint = { version = "2.6.0", workflow = "release.yaml" }
55
shellcheck = "0.11.0"
66
talosctl = "1.14.6"
7+
yq = "4.54.3"
8+
9+
[vars]
10+
creds_dir = "{{ config_root }}/.private/talos"
11+
topf_config = '{{ config_root }}/talos/topf.yaml'
12+
topf = 'topf --topfconfig "{{ vars.topf_config }}" --confirm=false'
713

814
[env]
915
_.path = ["{{ config_root }}/scripts"]
16+
TALOSCONFIG = "{{ vars.creds_dir }}/talosconfig"
17+
KUBECONFIG = "{{ vars.creds_dir }}/kubeconfig"
1018

1119
[secrets.fnox]
1220

‎talos/all/06-wireguard.yaml.tpl‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ up: true
1111
addresses:
1212
- address: {{ .Node.Data.ipv4.wgAddr }}/24
1313
- address: {{ .Node.Data.ipv6.wgAddr }}/64
14+
peers:
15+
- publicKey: vKz+v75M8FHF781BPOvUHTZbeTQmLpURwNMJPadYyl0=
16+
allowedIPs:
17+
- 10.42.43.2/32
18+
- fd42:43::2/128

‎talos/topf.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ secretsProvider: topf-secrets
1010

1111
nodes:
1212
- host: lon1
13-
ip: 57.129.192.57
13+
ip: 10.42.43.1
1414
role: control-plane
1515
data:
1616
gatewayIngress: true

0 commit comments

Comments
 (0)