diff --git a/nodes/hellas/_defaults.yaml b/nodes/hellas/_defaults.yaml index 70e0181..73e3cdc 100644 --- a/nodes/hellas/_defaults.yaml +++ b/nodes/hellas/_defaults.yaml @@ -1,5 +1,6 @@ netmask: 255.255.252.0 gateway: 10.0.0.1 -clusterName: hellas -controlPlaneIp: 10.0.2.1 installDisk: /dev/sda +cluster: + name: hellas + controlPlaneIp: 10.0.2.1 diff --git a/nodes/testing/_defaults.yaml b/nodes/testing/_defaults.yaml index 4ebe1f6..1a4c0e2 100644 --- a/nodes/testing/_defaults.yaml +++ b/nodes/testing/_defaults.yaml @@ -1,5 +1,6 @@ netmask: 255.255.255.0 gateway: 192.168.1.1 -clusterName: testing -controlPlaneIp: 192.168.1.100 installDisk: /dev/vda +cluster: + name: testing + controlPlaneIp: 192.168.1.100 diff --git a/patches/vip.yaml b/patches/vip.yaml index 619e304..e84c4a1 100644 --- a/patches/vip.yaml +++ b/patches/vip.yaml @@ -3,4 +3,4 @@ machine: interfaces: - interface: {{interface}} vip: - ip: {{controlPlaneIp}} + ip: {{cluster.controlPlaneIp}} diff --git a/templates/generate_configs.sh b/templates/generate_configs.sh index 9a99ebe..8fa9106 100644 --- a/templates/generate_configs.sh +++ b/templates/generate_configs.sh @@ -5,7 +5,7 @@ CONFIGS=${ROOT}/configs # Generate the configuration for each node {% for node in nodes -%} -talosctl gen config {{ node.clusterName }} https://{{ node.controlPlaneIp }}:6443 -f \ +talosctl gen config {{ node.cluster.name }} https://{{ node.cluster.controlPlaneIp }}:6443 -f \ --with-secrets ${ROOT}/secrets.yaml \ --talos-version {{ node.talosVersion }} \ --kubernetes-version {{ node.kubernesVersion }} \ @@ -24,7 +24,6 @@ talosctl gen config {{ node.clusterName }} https://{{ node.controlPlaneIp }}:644 {% endfor %} # Generate the talosconfig file for each cluster -{# NOTE: This assumes that each node in a cluster specifies the same control plane IP -#} {% for cluster in clusters -%} talosctl gen config {{ cluster.name }} https://{{ cluster.controlPlaneIp }}:6443 -f \ --with-secrets ${ROOT}/secrets.yaml \ diff --git a/templates/source.sh b/templates/source.sh index f30f322..19faf02 100644 --- a/templates/source.sh +++ b/templates/source.sh @@ -1,6 +1,6 @@ export TALOSCONFIG={{ root }}/configs/talosconfig {% set paths = [] %} -{%- for cluster_name in nodes|map(attribute="clusterName")|unique -%} - {%- do paths.append(root ~ "/configs/" ~ cluster_name ~ "/kubeconfig") -%} +{%- for cluster in clusters -%} + {%- do paths.append(root ~ "/configs/" ~ cluster.name ~ "/kubeconfig") -%} {% endfor -%} export KUBECONFIG={{ paths|join(":") }} diff --git a/tools/render b/tools/render index 224d911..da54cf3 100755 --- a/tools/render +++ b/tools/render @@ -135,15 +135,11 @@ def main(): ) ) - # Get all clusterName & controlPlaneIp pairs - clusters = map( - lambda node: { - "name": node["clusterName"], - "controlPlaneIp": node["controlPlaneIp"], - }, - nodes, - ) - clusters = [dict(s) for s in set(frozenset(d.items()) for d in clusters)] + # Get all clusters + # NOTE: This assumes that all nodes in the cluster use the same definition for the cluster + clusters = [ + dict(s) for s in set(frozenset(node["cluster"].items()) for node in nodes) + ] with open(ROOT.joinpath("config.yaml")) as fyaml: config = yaml.safe_load(fyaml)