blob: 93103b661b5983bbe2b03a67441dc19e57a3a951 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
---
- name: generate controlplane patch
copy:
content: |
cluster:
allowSchedulingOnControlPlanes: true
machine:
install:
disk: {{ talos_host.install_disk }}
network:
hostname: {{ inventory_hostname }}
nameservers:
- {{ hostvars[proxmox.host].network.self_internal_ip }}
interfaces:
- interface: eth0
addresses:
- {{ network.ip }}/24
routes:
- network: 0.0.0.0/0
gateway: {{ hostvars[proxmox.host].network.self_internal_ip }}
nodeLabels:
role: ingress-controller
dest: "{{ inventory_dir }}/talos/host-{{ inventory_hostname }}.patch"
delegate_to: 127.0.0.1
- name: generate controlplane config
shell:
cmd: talosctl gen config -t controlplane -o talos/host-{{ inventory_hostname }}.yaml --with-secrets <(ansible-vault view talos/{{ talos_host.talos_cluster }}-secrets.yaml) --config-patch-control-plane @talos/host-{{ inventory_hostname }}.patch {{ talos_host.talos_cluster }} {{ talos_clusters[talos_host.talos_cluster].endpoint }} --force
chdir: "{{ inventory_dir }}"
args:
executable: /bin/bash
delegate_to: 127.0.0.1
- name: generate talosconfig
shell:
cmd: talosctl gen config -t talosconfig -o talos/talosconfig-{{ talos_host.talos_cluster }} --with-secrets <(ansible-vault view talos/{{ talos_host.talos_cluster }}-secrets.yaml) {{ talos_host.talos_cluster }} {{ talos_clusters[talos_host.talos_cluster].endpoint }} --force
chdir: "{{ inventory_dir }}"
args:
executable: /bin/bash
delegate_to: 127.0.0.1
- name: set talosconfig endpoint
shell:
cmd: talosctl --talosconfig=talos/talosconfig-{{ talos_host.talos_cluster }} config endpoint {{ inventory_hostname }}
chdir: "{{ inventory_dir }}"
delegate_to: 127.0.0.1
- name: get kubeconfig
command:
cmd: talosctl kubeconfig --talosconfig talos/talosconfig-{{ talos_host.talos_cluster }} --nodes {{ inventory_hostname }} -f
chdir: "{{ inventory_dir }}"
delegate_to: 127.0.0.1
throttle: 1
- name: check node ready
k8s_info:
context: "admin@{{ talos_host.talos_cluster }}"
kind: Node
wait: true
wait_condition:
status: True
type: Ready
delegate_to: 127.0.0.1
register: nodes
ignore_errors: true
- name: setup proxmox hosts
import_tasks: proxmox.yml
when: "'k8s_proxmox' in group_names and not 'resources' in nodes or nodes.resources|length == 0"
- name: apply config
command:
cmd: talosctl apply-config --insecure --nodes {{ ip.stdout }} --file talos/host-{{ inventory_hostname }}.yaml
chdir: "{{ inventory_dir }}"
delegate_to: 127.0.0.1
when: "not 'resources' in nodes or nodes.resources|length == 0"
- name: bootstrap cluster
command:
cmd: talosctl bootstrap --nodes {{ inventory_hostname }} --talosconfig talos/talosconfig-{{ talos_host.talos_cluster }}
chdir: "{{ inventory_dir }}"
delegate_to: 127.0.0.1
register: bootstrap
until: bootstrap.rc == 0
retries: 12
delay: 1
when: "not 'resources' in nodes or nodes.resources|length == 0"
- name: get kubeconfig
command:
cmd: talosctl kubeconfig --talosconfig talos/talosconfig-{{ talos_host.talos_cluster }} --nodes {{ inventory_hostname }} -f
chdir: "{{ inventory_dir }}"
delegate_to: 127.0.0.1
when: "not 'resources' in nodes or nodes.resources|length == 0"
throttle: 1
- name: wait node ready
k8s_info:
context: "admin@{{ talos_host.talos_cluster }}"
kind: Node
wait: true
wait_condition:
status: True
type: Ready
delegate_to: 127.0.0.1
register: nodes
until: nodes.resources is defined and nodes.resources|length > 0
retries: 35
delay: 1
- name: deploy kustomizations
k8s:
context: "admin@{{ talos_host.talos_cluster }}"
definition: "{{ lookup('kubernetes.core.kustomize', dir='k8s/base') }}"
delegate_to: 127.0.0.1
|