Assign L2 templates to machines

You can create multiple L2 templates with different configurations and apply them to different machines in the same cluster. This section describes how to assign an L2 template to new cluster machines.

To change L2 template assignment on existing machines, refer to Modify network configuration on an existing machine before 2.19.0.

To assign specific L2 templates to new machines in a cluster:

When you create a machine, set the l2TemplateSelector field in the machine spec to the unique label of the L2 template that you want to assign to the machine. Typically, you can use l2template-<NAME>. For details, see Create an L2 template for a new managed cluster.

Alternatively, set the l2TemplateSelector field in the machine spec to the name of the L2 template. This will work even if there is no unique label on the L2 template that you want to use.

Consider the following examples of an L2 template assignment to a machine.

Example of an L2Template resource:

apiVersion: ipam.mirantis.com/v1alpha1
kind: L2Template
metadata:
  name: ExampleNetConfig
  namespace: MyProject
  labels:
    kaas.mirantis.com/provider: baremetal
    kaas.mirantis.com/region: region-one
    l2template-ExampleNetConfig: "true"
...
spec:
  clusterRef: MyCluster
...

Example of a Machine resource with the label-based L2 template selector:

apiVersion: cluster.k8s.io/v1alpha1
kind: Machine
metadata:
  name: Machine1
  namespace: MyProject
...
spec:
  providerSpec:
    value:
      l2TemplateSelector:
        label: l2template-ExampleNetConfig
...

Example of a Machine resource with the name-based L2 template selector:

apiVersion: cluster.k8s.io/v1alpha1
kind: Machine
metadata:
  name: Machine1
  namespace: MyProject
...
spec:
  providerSpec:
    value:
      l2TemplateSelector:
        name: ExampleNetConfig
...