Assign L2 templates to machines

You can create multiple L2 templates with different configurations and apply them to different machines in the same cluster.

To assign a specific L2 template to machines in a cluster:

  1. Create the default L2 template for the cluster. It will be used for machines that do not have an L2 template explicitly assigned.

    To designate an L2 template as default, assign the ipam/DefaultForCluster label to it. Only one L2 template in a cluster can have this label.

  2. Create other required L2 templates for the cluster. Use the clusterRef parameter in the L2 template spec to assign the templates to the cluster.

  3. Add the l2template-<NAME> label to every L2 template. Replace the <NAME> parameter with the unique name of the L2 template.

  4. Assign an L2 template to a machine. Set the l2TemplateSelector field in the machine spec to the name of the label added in the previous step. IPAM controller uses this field to use a specific L2 template for the corresponding machine.

    Alternatively, you may set the l2TemplateSelector field to the name of the L2 template. This makes the template exclusively used by the corresponding machine.

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
...
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
...