--wip-- [skip ci]
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
{% set httpUrl = "http://192.168.1.1:8000" -%}
|
||||
#!ipxe
|
||||
dhcp
|
||||
|
||||
@@ -7,18 +8,16 @@ echo Starting ${serial}
|
||||
goto node_${serial} || exit
|
||||
# Default behavior (non install mode) is to exit iPXE script
|
||||
|
||||
{% for node in nodes %}
|
||||
{%- if node.install -%}
|
||||
# {{ node.filename }}
|
||||
:node_{{ node.serial }}
|
||||
{% set ipArg = "ip=" ~ [node.ip, "" , node.gateway, node.netmask, node.hostname, node.interface, "", node.dns[0], node.dns[1], node.ntp]|join(":") -%}
|
||||
{% set kernelArgs = [ipArg, node.kernelArgs|join(" "), node.extraKernelArgs|join(" ")] -%}
|
||||
{% if node.autoInstall %}
|
||||
{% do kernelArgs.append("talos.config=" ~ config.server.httpUrl ~ "/configs/" ~ node.filename ~ ".yaml") %}
|
||||
{% endif %}
|
||||
{% for cluster in clusters%}
|
||||
{% for node in cluster.nodes %}
|
||||
{%- if node.install.serial -%}
|
||||
# {{ cluster.name }}/{{ node.hostname }}
|
||||
:node_{{ node.install.serial }}
|
||||
{% set ipArg = "ip=" ~ [node.network.ip, "" , node.network.gateway, node.network.netmask, node.hostname, node.network.interface, "", node.network.dns[0], node.network.dns[1], node.ntp]|join(":") -%}
|
||||
imgfree
|
||||
kernel https://pxe.factory.talos.dev/image/{{ node.schematicId }}/v{{ node.talosVersion }}/kernel-{{ node.arch }} {{ kernelArgs|join(" ") }}
|
||||
initrd https://pxe.factory.talos.dev/image/{{ node.schematicId }}/v{{ node.talosVersion }}/initramfs-{{ node.arch }}.xz
|
||||
kernel https://pxe.factory.talos.dev/image/{{ node.schematic }}/v{{ cluster.version.talos }}/kernel-{{ node.arch }} {{ ipArg }} {{ node.kernelArgs|join(" ") }} {% if node.install.auto %}talos.config={{httpUrl}}/configs/{{cluster.name}}/{{node.hostname}}.yaml{% endif +%}
|
||||
initrd https://pxe.factory.talos.dev/image/{{ node.schematic }}/v{{ cluster.version.talos }}/initramfs-{{ node.arch }}.xz
|
||||
boot
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% set tftpIp = config.server.tftpIp -%}
|
||||
{% set tftpIp = "192.168.1.1" -%}
|
||||
|
||||
enable-tftp
|
||||
tftp-root=/tftproot
|
||||
|
||||
@@ -2,38 +2,37 @@
|
||||
set -euo pipefail
|
||||
CONFIGS={{ root }}/configs
|
||||
|
||||
TALOSCONFIG=${CONFIGS}/talosconfig
|
||||
rm -f ${CONFIGS}
|
||||
|
||||
# Generate the configuration for each node
|
||||
{% for node in nodes -%}
|
||||
talosctl gen config {{ node.cluster.name }} https://{{ node.cluster.controlPlaneIp }}:6443 -f \
|
||||
--with-secrets {{ node.cluster.secretsFile }} \
|
||||
--talos-version v{{ node.talosVersion }} \
|
||||
--kubernetes-version v{{ node.kubernetesVersion }} \
|
||||
{% for cluster in clusters %}
|
||||
{% for node in cluster.nodes -%}
|
||||
talosctl gen config {{ cluster.name }} https://{{ cluster.controlPlaneIp }}:6443 -f \
|
||||
--with-secrets {{ cluster.secretsFile }} \
|
||||
--talos-version v{{ cluster.version.talos }} \
|
||||
--kubernetes-version v{{ cluster.version.kubernetes }} \
|
||||
--output-types {{ node.type }} \
|
||||
--install-image factory.talos.dev/metal-installer/{{ node.schematicId }}:v{{ node.talosVersion }} \
|
||||
{% for patch in node.patches -%}
|
||||
--install-image factory.talos.dev/metal-installer/{{ node.schematic }}:v{{ cluster.version.talos }} \
|
||||
{% for patch in node.patches.all -%}
|
||||
{# The double call to tojson is needed to properly escape the patch (object -> json -> string) -#}
|
||||
--config-patch {{ helper.model_dump_json(patch)|tojson }} \
|
||||
--config-patch {{ patch|tojson|tojson }} \
|
||||
{% endfor -%}
|
||||
{% for patch in node.patchesControlPlane -%}
|
||||
--config-patch-control-plane {{ helper.model_dump_json(patch)|tojson }} \
|
||||
{% for patch in node.patches.controlPlane -%}
|
||||
--config-patch-control-plane {{ patch|tojson|tojson }} \
|
||||
{% endfor -%}
|
||||
--with-docs=false \
|
||||
--with-examples=false \
|
||||
-o ${CONFIGS}/{{ node.filename }}.yaml
|
||||
-o ${CONFIGS}/{{ cluster.name }}/{{ node.hostname }}.yaml
|
||||
{% endfor %}
|
||||
|
||||
# Generate the talosconfig file for each cluster
|
||||
{% for cluster in clusters -%}
|
||||
talosctl gen config {{ cluster.name }} https://{{ cluster.controlPlaneIp }}:6443 -f \
|
||||
--with-secrets {{ cluster.secretsFile }} \
|
||||
--output-types talosconfig \
|
||||
-o ${CONFIGS}/{{ cluster.name }}/talosconfig
|
||||
{% endfor %}
|
||||
|
||||
# Create merged talosconfig
|
||||
TALOSCONFIG=${CONFIGS}/talosconfig
|
||||
rm -f ${TALOSCONFIG}
|
||||
{% for cluster in clusters -%}
|
||||
talosctl config --talosconfig=${CONFIGS}/{{ cluster.name }}/talosconfig endpoint {{ cluster.controlPlaneIp }}
|
||||
talosctl config --talosconfig=${TALOSCONFIG} merge ${CONFIGS}/{{ cluster.name }}/talosconfig
|
||||
{% endfor %}
|
||||
|
||||
@@ -1,6 +1,2 @@
|
||||
export TALOSCONFIG={{ root }}/configs/talosconfig
|
||||
{% set paths = [] %}
|
||||
{%- for cluster in clusters -%}
|
||||
{%- do paths.append(root ~ "/configs/" ~ cluster.name ~ "/kubeconfig") -%}
|
||||
{% endfor -%}
|
||||
export KUBECONFIG={{ paths|join(":") }}
|
||||
export KUBECONFIG={{ clusters|map(attribute='name')|kubeconfig|join(":") }}
|
||||
|
||||
Reference in New Issue
Block a user