Skip to content

Commit faa14a9

Browse files
authored
ci: fix talos cluster initialization (#6093)
Signed-off-by: zhangzujian <zhangzujian.7@gmail.com>
1 parent 5151eb9 commit faa14a9

File tree

3 files changed

+58
-34
lines changed

3 files changed

+58
-34
lines changed

.github/workflows/build-x86-image.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ env:
2929
HELM_VERSION: v4.0.4
3030
# renovate: datasource=github-releases depName=submariner packageName=submariner-io/submariner
3131
SUBMARINER_VERSION: 0.21.2
32+
# renovate: datasource=github-releases depName=talos packageName=siderolabs/talos
33+
TALOS_VERSION: v1.12.0
3234

3335
jobs:
3436
build-kube-ovn-base:
@@ -2293,7 +2295,11 @@ jobs:
22932295
- uses: actions/checkout@v6
22942296

22952297
- name: Install talosctl
2296-
run: curl -sL https://talos.dev/install | sh
2298+
run: |
2299+
curl -sLo install-talosctl.sh https://talos.dev/install
2300+
sed -i "s|/latest/download/|/download/${{ env.TALOS_VERSION }}/|g" install-talosctl.sh
2301+
sed -i "s|/latest/|/${{ env.TALOS_VERSION }}/|g" install-talosctl.sh
2302+
sh install-talosctl.sh
22972303
22982304
- name: Install KVM and libvirt
22992305
run: |

makefiles/talos.mk

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# Makefile for managing Talos environment
22

33
TALOS_ARCH = $(shell go env GOHOSTARCH)
4-
TALOS_VERSION = $(shell talosctl version --client --short | awk '{print $$NF}' | tail -n 1)
4+
TALOS_VERSION ?= $(shell talosctl version --client --short | awk '{print $$NF}' | tail -n 1)
55
TALOS_IMAGE_DIR ?= /var/lib/talos
6-
TALOS_IMAGE_URL = https://github.com/siderolabs/talos/releases/download/$(TALOS_VERSION)/metal-$(TALOS_ARCH).iso
6+
7+
# generated image download link by Talos Linux Image Factory https://factory.talos.dev/
8+
# customization:
9+
# extraKernelArgs:
10+
# - talos.network.interface.ignore=enp0s5f1
11+
TALOS_IMAGE_URL = https://factory.talos.dev/image/9ecea35ddd146528c1d742aab47e680a1f1137a93fc7bab55edc1afee125a658/$(TALOS_VERSION)/metal-$(TALOS_ARCH).iso
712
TALOS_IMAGE_ISO = $(TALOS_VERSION)-metal-$(TALOS_ARCH).iso
813
TALOS_IMAGE_PATH = $(TALOS_IMAGE_DIR)/$(TALOS_IMAGE_ISO)
914

@@ -65,7 +70,7 @@ talos-registry-mirror:
6570
.PHONY: talos-prepare-images
6671
talos-prepare-images: talos-registry-mirror
6772
@echo ">>> Preparing Talos images..."
68-
@for image in $$(talosctl image default | grep -v flannel); do \
73+
@for image in ghcr.io/siderolabs/installer:$(TALOS_VERSION) $$(talosctl image default | grep -v flannel); do \
6974
if echo "$$image" | grep -q kube; then \
7075
image=$$(echo $$image | sed -e 's/:v\([[:digit:]]\+\.\)\{2\}[[:digit:]]\+$$/:v$(TALOS_K8S_VERSION)/'); \
7176
fi; \
@@ -87,7 +92,7 @@ talos-libvirt-init: talos-libvirt-clean
8792
@if [ ! -f "$(TALOS_IMAGE_PATH)" ]; then \
8893
sudo mkdir -p "$(TALOS_IMAGE_DIR)" && \
8994
sudo chmod 777 "$(TALOS_IMAGE_DIR)" && \
90-
echo ">>> Downloading Talos image $(TALOS_IMAGE_ISO) into $(TALOS_IMAGE_DIR)..." && \
95+
echo ">>> Downloading Talos image $(TALOS_IMAGE_URL) into $(TALOS_IMAGE_DIR)..." && \
9196
wget "$(TALOS_IMAGE_URL)" --quiet -O "$(TALOS_IMAGE_PATH)" && \
9297
echo ">>> Talos image downloaded."; \
9398
fi
@@ -172,14 +177,14 @@ talos-apply-config-%:
172177
echo ">>>>>> Applying Talos control plane configuration to $${node}..."; \
173178
ip=$$(sudo virsh domifaddr --full "$${node}" | grep -w vnet0 | grep -iw ipv4 | awk '{print $$NF}' | awk -F/ '{print $$1}'); \
174179
ip_family=$* cluster=$(TALOS_CLUSTER_NAME) node=$${node} jinjanate talos/machine-config.yaml.j2 -o talos/machine-config.yaml && \
175-
talosctl apply-config --insecure --nodes $${ip} --file talos/controlplane.yaml --config-patch "@talos/machine-config.yaml"; \
180+
talosctl apply-config --insecure --nodes $${ip} --file talos/controlplane.yaml --config-patch "@talos/machine-config.yaml" || exit 1; \
176181
echo ">>>>>> Talos control plane configuration applied to $${node}."; \
177182
done
178183
@sudo virsh list --name | grep '^$(TALOS_WORKER_NODE)' | while read node; do \
179184
echo ">>>>>> Applying Talos worker configuration to $${node}..."; \
180185
ip=$$(sudo virsh domifaddr --full "$${node}" | grep -w vnet0 | grep -iw ipv4 | awk '{print $$NF}' | awk -F/ '{print $$1}'); \
181186
ip_family=$* cluster=$(TALOS_CLUSTER_NAME) node=$${node} jinjanate talos/machine-config.yaml.j2 -o talos/machine-config.yaml && \
182-
talosctl apply-config --insecure --nodes $${ip} --file talos/worker.yaml --config-patch "@talos/machine-config.yaml"; \
187+
talosctl apply-config --insecure --nodes $${ip} --file talos/worker.yaml --config-patch "@talos/machine-config.yaml" || exit 1; \
183188
echo ">>>>>> Talos worker configuration applied to $${node}."; \
184189
done
185190
@$(MAKE) talos-libvirt-wait-address-$(TALOS_ENDPOINT_IP_FAMILY)
@@ -257,6 +262,10 @@ talos-init-%: talos-libvirt-init talos-prepare-images talos-apply-config-%
257262
.PHONY: talos-init
258263
talos-init: talos-init-ipv4
259264

265+
.PHONY: talos-init-single
266+
talos-init-single:
267+
@TALOS_WORKER_COUNT=0 $(MAKE) talos-init
268+
260269
.PHONY: talos-clean
261270
talos-clean: talos-libvirt-clean
262271
@echo ">>> Deleting Talos registry mirror..."

talos/machine-config.yaml.j2

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{%- endmacro -%}
77
{%- set duidv6 = random_duid_uuid() -%}
88
{%- if 'control-plane' in node -%}
9-
{%- set duidv6 = '00030001aabbccddeeff' -%}
9+
{%- set duidv6 = '00030001aabbccddeeff' -%}
1010
{%- endif -%}
1111
{%- if ip_family is not defined -%}
1212
{%- set ip_family = "ipv4" -%}
@@ -15,38 +15,12 @@ machine:
1515
install:
1616
disk: /dev/vda
1717
wipe: true
18-
time:
19-
disabled: true
2018
kernel:
2119
modules:
2220
# the following kernel modules configuration may be unnecessary
2321
- name: openvswitch
2422
- name: geneve
2523
- name: vxlan
26-
network:
27-
hostname: {{ node }}
28-
disableSearchDomain: true
29-
interfaces:
30-
- deviceSelector:
31-
busPath: 0000:00:05.0
32-
mtu: 1500
33-
dhcp: true
34-
dhcpOptions:
35-
{%- if ip_family is equalto "ipv4" or ip_family is equalto "dual" %}
36-
ipv4: true
37-
{%- else %}
38-
ipv4: false
39-
{%- endif %}
40-
{%- if ip_family is equalto "ipv6" or ip_family is equalto "dual" %}
41-
ipv6: true
42-
duidv6: {{ duidv6 }}
43-
{%- else %}
44-
ipv6: false
45-
{%- endif %}
46-
- deviceSelector:
47-
busPath: 0000:00:05.1
48-
mtu: 1500
49-
ignore: true
5024
kubelet:
5125
nodeIP:
5226
validSubnets:
@@ -59,3 +33,38 @@ machine:
5933
{%- endif %}
6034
extraArgs:
6135
provider-id: talos://libvirt/{{ cluster }}/{{ node }}
36+
---
37+
apiVersion: v1alpha1
38+
kind: TimeSyncConfig
39+
enabled: false
40+
---
41+
apiVersion: v1alpha1
42+
kind: HostnameConfig
43+
hostname: {{ node }}
44+
auto: off
45+
---
46+
apiVersion: v1alpha1
47+
kind: ResolverConfig
48+
searchDomains:
49+
disableDefault: true
50+
---
51+
apiVersion: v1alpha1
52+
kind: LinkConfig
53+
name: enp0s5f0
54+
up: true
55+
{%- if ip_family is equalto "ipv4" or ip_family is equalto "dual" %}
56+
---
57+
apiVersion: v1alpha1
58+
kind: DHCPv4Config
59+
name: enp0s5f0
60+
ignoreHostname: true
61+
{%- endif %}
62+
{%- if ip_family is equalto "ipv6" or ip_family is equalto "dual" %}
63+
---
64+
apiVersion: v1alpha1
65+
kind: DHCPv6Config
66+
name: enp0s5f0
67+
ignoreHostname: true
68+
clientIdentifier: duid
69+
duidRaw: "{{ duidv6 }}"
70+
{%- endif %}

0 commit comments

Comments
 (0)