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.
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
cluster.sigs.k8s.io/cluster-name: my-cluster
l2template-ExampleNetConfig: "true"
Note
The kaas.mirantis.com/region
label is removed from all
Container Cloud objects in 2.26.0 (Cluster releases 17.1.0 and 16.1.0).
Therefore, do not add the label starting these releases. On existing
clusters updated to these releases, or if manually added, this label will
be ignored by Container Cloud.
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
...