Compare commits
7 Commits
235ab5add7
...
b0e146241b
| Author | SHA1 | Date | |
|---|---|---|---|
|
b0e146241b
|
|||
|
18b5d8fd18
|
|||
|
21ae5bc2c4
|
|||
|
17b0b05410
|
|||
|
8832371b99
|
|||
|
a9fbf9aad8
|
|||
|
4f072d7cb7
|
@@ -1,6 +1,7 @@
|
|||||||
schematicID: !schematic default
|
schematicId: !schematic default
|
||||||
arch: amd64
|
arch: amd64
|
||||||
talosVersion: v1.11.3
|
talosVersion: v1.11.3
|
||||||
|
kubernesVersion: v1.34.1
|
||||||
kernelArgs:
|
kernelArgs:
|
||||||
- talos.platform=metal
|
- talos.platform=metal
|
||||||
- console=tty0
|
- console=tty0
|
||||||
@@ -18,8 +19,7 @@ dns:
|
|||||||
- 1.1.1.1
|
- 1.1.1.1
|
||||||
- 8.8.8.8
|
- 8.8.8.8
|
||||||
ntp: nl.pool.ntp.org
|
ntp: nl.pool.ntp.org
|
||||||
installDisk: /dev/sda
|
install: true
|
||||||
install: false
|
|
||||||
patches:
|
patches:
|
||||||
- !patch hostname
|
- !patch hostname
|
||||||
- !patch install-disk
|
- !patch install-disk
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
netmask: 255.255.252.0
|
netmask: 255.255.252.0
|
||||||
gateway: 10.0.0.1
|
gateway: 10.0.0.1
|
||||||
install: true
|
clusterName: hellas
|
||||||
controlplaneIp: 10.0.2.1
|
controlplaneIp: 10.0.2.1
|
||||||
|
installDisk: /dev/sda
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
serial: 5CZ7NX2
|
serial: 5CZ7NX2
|
||||||
interface: enp2s0
|
interface: enp2s0
|
||||||
ip: 10.0.0.202
|
ip: 10.0.0.202
|
||||||
|
type: "controlplane"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
serial: F3PKRH2
|
serial: F3PKRH2
|
||||||
interface: enp3s0
|
interface: enp3s0
|
||||||
ip: 10.0.0.201
|
ip: 10.0.0.201
|
||||||
|
type: "controlplane"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
serial: J33CHY2
|
serial: J33CHY2
|
||||||
interface: enp2s0
|
interface: enp2s0
|
||||||
ip: 10.0.0.203
|
ip: 10.0.0.203
|
||||||
|
type: "controlplane"
|
||||||
|
|||||||
@@ -2,4 +2,4 @@ netmask: 255.255.255.0
|
|||||||
gateway: 192.168.1.1
|
gateway: 192.168.1.1
|
||||||
clusterName: testing
|
clusterName: testing
|
||||||
controlplaneIp: 192.168.1.100
|
controlplaneIp: 192.168.1.100
|
||||||
instalDisk: /dev/vda
|
installDisk: /dev/vda
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
serial: talos-vm
|
serial: talos-vm
|
||||||
interface: eth0
|
interface: eth0
|
||||||
ip: 192.168.1.2
|
ip: 192.168.1.2
|
||||||
install: true
|
type: "controlplane"
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ goto node_${serial} || exit
|
|||||||
{% set ipArg = "ip=" ~ node.ip ~ "::" ~ node.gateway ~ ":" ~ node.netmask ~ ":" ~ node.hostname ~ ":" ~ node.interface ~ "::" ~ node.dns[0] ~ ":" ~ node.dns[1] ~ ":" ~ node.ntp -%}
|
{% set ipArg = "ip=" ~ node.ip ~ "::" ~ node.gateway ~ ":" ~ node.netmask ~ ":" ~ node.hostname ~ ":" ~ node.interface ~ "::" ~ node.dns[0] ~ ":" ~ node.dns[1] ~ ":" ~ node.ntp -%}
|
||||||
{% set kernelArgs = ipArg ~ " " ~ node.kernelArgs ~ " " ~ node.extraKernelArgs -%}
|
{% set kernelArgs = ipArg ~ " " ~ node.kernelArgs ~ " " ~ node.extraKernelArgs -%}
|
||||||
imgfree
|
imgfree
|
||||||
kernel https://pxe.factory.talos.dev/image/{{ node.schematicID }}/{{ node.talosVersion }}/kernel-{{ node.arch }} {{ kernelArgs }}
|
kernel https://pxe.factory.talos.dev/image/{{ node.schematicId }}/{{ node.talosVersion }}/kernel-{{ node.arch }} {{ kernelArgs }}
|
||||||
initrd https://pxe.factory.talos.dev/image/{{ node.schematicID }}/{{ node.talosVersion }}/initramfs-{{ node.arch }}.xz
|
initrd https://pxe.factory.talos.dev/image/{{ node.schematicId }}/{{ node.talosVersion }}/initramfs-{{ node.arch }}.xz
|
||||||
boot
|
boot
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
42
templates/generate_configs.sh
Normal file
42
templates/generate_configs.sh
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
ROOT=$(git rev-parse --show-toplevel)
|
||||||
|
CONFIGS=${ROOT}/configs
|
||||||
|
TALOSCONFIG=${CONFIGS}/talosconfig
|
||||||
|
|
||||||
|
# Generate the configuration for each node
|
||||||
|
{% set clusters = [] %}
|
||||||
|
{%- for node in nodes -%}
|
||||||
|
talosctl gen config {{ node.clusterName }} https://{{ node.controlplaneIp }}:6443 -f \
|
||||||
|
--with-secrets ${ROOT}/secrets.yaml \
|
||||||
|
--talos-version {{ node.talosVersion }} \
|
||||||
|
--kubernetes-version {{ node.kubernesVersion }} \
|
||||||
|
--output-types {{ node.type }} \
|
||||||
|
--install-image factory.talos.dev/metal-installer/{{ node.schematicId }}:{{ node.talosVersion }} \
|
||||||
|
{% for patch in node.patches -%}
|
||||||
|
{# The double call to tojson is needed to properly escape the patch (object -> json -> string) -#}
|
||||||
|
--config-patch {{ patch|tojson|tojson }} \
|
||||||
|
{% endfor -%}
|
||||||
|
{% for patch in node.patchesControlplane -%}
|
||||||
|
--config-patch-control-plane {{ patch|tojson|tojson }} \
|
||||||
|
{% endfor -%}
|
||||||
|
--with-docs=false \
|
||||||
|
--with-examples=false \
|
||||||
|
-o ${CONFIGS}/{{ node.filename }}.yaml
|
||||||
|
|
||||||
|
{%- do clusters.append((node.clusterName, node.controlplaneIp)) %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
# Generate the talosconfig file for each cluster
|
||||||
|
{% for cluster in clusters|unique -%}
|
||||||
|
talosctl gen config {{ cluster[0] }} https://{{ cluster[1] }}:6443 -f \
|
||||||
|
--with-secrets ${ROOT}/secrets.yaml \
|
||||||
|
--output-types talosconfig \
|
||||||
|
-o ${CONFIGS}/{{ cluster[0] }}/talosconfig
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
# Create merged talosconfig
|
||||||
|
rm -f ${TALOSCONFIG}
|
||||||
|
{% for cluster in clusters|unique -%}
|
||||||
|
talosctl config merge ${CONFIGS}/{{ cluster[0] }}/talosconfig
|
||||||
|
{% endfor %}
|
||||||
15
tools/render
15
tools/render
@@ -19,11 +19,18 @@ ROOT = pathlib.Path(REPO.working_dir)
|
|||||||
NODES = ROOT.joinpath("nodes")
|
NODES = ROOT.joinpath("nodes")
|
||||||
SCHEMATICS = ROOT.joinpath("schematics")
|
SCHEMATICS = ROOT.joinpath("schematics")
|
||||||
RENDERED = ROOT.joinpath("rendered")
|
RENDERED = ROOT.joinpath("rendered")
|
||||||
|
|
||||||
|
EXTENSIONS = ["jinja2.ext.do"]
|
||||||
|
|
||||||
PATCHES = Environment(
|
PATCHES = Environment(
|
||||||
loader=FileSystemLoader(ROOT.joinpath("patches")), undefined=StrictUndefined
|
loader=FileSystemLoader(ROOT.joinpath("patches")),
|
||||||
|
undefined=StrictUndefined,
|
||||||
|
extensions=EXTENSIONS,
|
||||||
)
|
)
|
||||||
TEMPLATES = Environment(
|
TEMPLATES = Environment(
|
||||||
loader=FileSystemLoader(ROOT.joinpath("templates")), undefined=StrictUndefined
|
loader=FileSystemLoader(ROOT.joinpath("templates")),
|
||||||
|
undefined=StrictUndefined,
|
||||||
|
extensions=EXTENSIONS,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -36,8 +43,8 @@ def node_encoder(node: dict):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
e.add_note(f"While rendering for: {node['hostname']}")
|
e.add_note(f"While rendering for: {node['hostname']}")
|
||||||
raise e
|
raise e
|
||||||
# Parse the rendered yaml and convert it to a json patch
|
# Parse the rendered yaml
|
||||||
return json.dumps(yaml.safe_load(rendered))
|
return yaml.safe_load(rendered)
|
||||||
|
|
||||||
return super().default(o)
|
return super().default(o)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user