After you create subnets for one or more managed clusters or projects as described in Create subnets or Automate multiple subnet creation using SubnetPool, follow the procedure below to create L2 templates for a managed cluster. This procedure contains exemplary L2 templates for the following use cases:
To create an L2 template for a new managed cluster:
Log in to a local machine where your management cluster kubeconfig
is located and where kubectl
is installed.
Note
The management cluster kubeconfig
is created
during the last stage of the management cluster bootstrap.
Inspect the existing L2 templates to select the one that fits your deployment:
kubectl --kubeconfig <pathToManagementClusterKubeconfig> \
get l2template -n <ProjectNameForNewManagedCluster>
Create an L2 YAML template specific to your deployment using one of the exemplary templates:
Note
You can create several L2 templates with different configurations to be applied to different nodes of the same cluster. In this case:
First create the default L2 template for a cluster.
It will be used for machines that do not have
L2templateSelector
.
Verify that the unique ipam/DefaultForCluster
label
is added to the first L2 template of the cluster.
Set a unique name
and add a unique label
to the
metadata
section of each L2 template of the cluster.
To select a particular L2 template for a machine,
use either the L2 template name or label in the
L2templateSelector
section of the corresponding machine
configuration file.
If you use an L2 template for only one machine, set name
.
For a group of machines, set label
.
For details about configuration of machines, see Deploy a machine to a specific bare metal host.
Add or edit the mandatory parameters in the new L2 template.
The following tables provide the description of the mandatory
and the l3Layout
section parameters in the example templates
mentioned in the previous step.
Parameter |
Description |
---|---|
|
References the Cluster object that this template is applied to.
The Caution
|
|
|
|
A netplan-compatible configuration with special lookup functions
that defines the networking settings for the cluster hosts,
where physical NIC names and details are parameterized.
This configuration will be processed using Go templates.
Instead of specifying IP and MAC addresses, interface names,
and other network details specific to a particular host,
the template supports use of special lookup functions.
These lookup functions, such as Caution All rules and restrictions of the netplan configuration also apply to L2 templates. For details, see the official netplan documentation. |
For more details about the L2Template
custom resource (CR), see
the L2Template API section.
Parameter |
Description |
---|---|
|
Name of the |
|
Optional. Default: none. Name of the parent |
|
Logical scope of the
|
The following table describes the main lookup functions for an L2 template.
Lookup function |
Description |
---|---|
|
Name of a NIC number N. NIC numbers correspond to the interface mapping list. |
|
MAC address of a NIC number N registered during a host hardware inspection. |
|
IP address and mask for a NIC number N. The address will be auto-allocated from the given subnet if the address does not exist yet. |
|
IP address and mask for a virtual interface, |
|
IPv4 default gateway address from the given subnet. |
|
List of the IP addresses of name servers from the given subnet. |
Note
Every subnet referenced in an L2 template can have either a global or namespaced scope. In the latter case, the subnet must exist in the same project where the corresponding cluster and L2 template are located.
Add the L2 template to your management cluster:
kubectl --kubeconfig <pathToManagementClusterKubeconfig> apply -f <pathToL2TemplateYamlFile>
Optional. Further modify the template:
kubectl --kubeconfig <pathToManagementClusterKubeconfig> \
-n <ProjectNameForNewManagedCluster> edit l2template <L2templateName>
Proceed with creating a managed cluster as described in Create a managed cluster. The resulting L2 template will be used to render the netplan configuration for the managed cluster machines.
The workflow of the netplan configuration using an L2 template is as follows:
The kaas-ipam
service uses the data from BareMetalHost
,
the L2 template, and subnets to generate the netplan configuration
for every cluster machine.
The generated netplan configuration is saved in the
status.netconfigV2
section of the IpamHost
resource.
If the status.l2RenderResult
field of the IpamHost
resource
is OK
, the configuration was rendered in the IpamHost
resource
successfully. Otherwise, the status contains an error message.
The baremetal-provider
service copies data
from the status.netconfigV2
of IpamHost
to the
Spec.StateItemsOverwrites[‘deploy’][‘bm_ipam_netconfigv2’]
parameter
of LCMMachine
.
The lcm-agent
service on every host synchronizes the LCMMachine
data to its host. The lcm-agent
service runs
a playbook to update the netplan configuration on the host
during the pre-download
and deploy
phases.