This section describes the L2Template
resource used in Mirantis
Container Cloud API.
By default, Container Cloud configures a single interface on cluster nodes,
leaving all other physical interfaces intact.
With L2Template
, you can create advanced host networking configurations
for your clusters. For example, you can create bond interfaces on top of
physical interfaces on the host.
For demonstration purposes, the Container Cloud L2Template
custom resource (CR) is split into the following major sections:
The Container Cloud L2Template
CR contains the following fields:
apiVersion
API version of the object that is ipam.mirantis.com/v1alpha1
.
kind
Object type that is L2Template
.
metadata
The metadata
field contains the following subfields:
name
Name of the L2Template
object.
namespace
Project in which the L2Template
object was created.
labels
Key-value pairs that are attached to the object:
Caution
All ipam/*
labels, except ipam/DefaultForCluster
,
are set automatically and must not be configured manually.
ipam/Cluster
References the Cluster
object name that this template is
applied to. The process of selecting the L2Template
object for
a specific cluster is as follows:
The kaas-ipam
controller monitors the L2Template
objects
with the ipam/Cluster:<clusterName>
label.
The L2Template
object with the ipam/Cluster: <clusterName>
label is assigned to a cluster with Name: <clusterName>
,
if available. Otherwise, the default L2Template
object
with the ipam/Cluster: default
label is assigned to a cluster.
ipam/PreInstalledL2Template: "1"
Is automatically added during a management or regional cluster
deployment.
Indicates that the current L2Template
object was preinstalled.
Represents L2 templates that are automatically copied to a project
once it is created. Once the L2 templates are copied,
the ipam/PreInstalledL2Template
label is removed.
ipam/DefaultForCluster
This label is unique per cluster. When you use several L2 templates
per cluster, only the first template is automatically labeled
as the default one. All consequent templates must be referenced
in the machines configuration files using L2templateSelector
.
You can manually configure this label if required.
ipam/UID
Unique ID of an object.
kaas.mirantis.com/provider
Provider type.
kaas.mirantis.com/region
Region type.
Configuration example:
apiVersion: ipam.mirantis.com/v1alpha1
kind: L2Template
metadata:
name: l2template-test
namespace: default
labels:
ipam/Cluster: test
ipam/DefaultForCluster: "1"
kaas.mirantis.com/provider: baremetal
kaas.mirantis.com/region: region-one
The spec
field of the L2Template
resource describes the desired
state of the object. It contains the following fields:
clusterRef
The Cluster
object that this template is applied to.
The default
value is used to apply the given template to all clusters
within a particular project, unless an L2 template that references
a specific cluster name exists.
Caution
A cluster can be associated with only one template.
An L2 template must have the same namespace as the referenced cluster.
A project can have only one default L2 template.
ifMapping
The list of interface names for the template. The interface mapping is
defined globally for all bare metal hosts in the cluster but can be
overridden at the host level, if required, by editing the IpamHost
object for a particular host. The ifMapping
parameter
is mutually exclusive with autoIfMappingPrio
.
autoIfMappingPrio
The list of prefixes, such as eno
, ens
, and so on, to match the
interfaces to automatically create a list for the template. The result
of generation may be overridden at the host level using
ifMappingOverride
in the corresponded IpamHost
spec
.
The autoIfMappingPrio
parameter is mutually exclusive
with ifMapping
.
npTemplate
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 nic
, mac
, ip
, and so on, return
host-specific network information when the template is rendered for
a particular host.
Caution
All rules and restrictions of the netplan configuration also apply to L2 templates. For details, see the official netplan documentation.
Configuration example:
spec:
autoIfMappingPrio:
- provision
- eno
- ens
- enp
l3Layout: null
npTemplate: |
version: 2
ethernets:
{{nic 0}}:
dhcp4: false
dhcp6: false
addresses:
- {{ip "0:kaas-mgmt"}}
gateway4: {{gateway_from_subnet "kaas-mgmt"}}
nameservers:
addresses: {{nameservers_from_subnet "kaas-mgmt"}}
match:
macaddress: {{mac 0}}
set-name: {{nic 0}}
The status
field of the L2Template
resource reflects the actual state
of the L2Template
object and contains the following fields:
phase
Current phase of the L2Template
object.
Possible values: Ready
, Failed
, or Terminating
.
reason
Detailed error message in case L2Template
has the Failed
status.
lastUpdate
Date and time of the last L2Template
status update.
versionIpam
IPAM version used during the last update of the object.
Configuration example:
status:
lastUpdate: "2020-09-15T08:30:08Z"
phase: Failed
reason: The kaas-mgmt subnet in the terminating state.
versionIpam: v3.0.999-20200807-130909-44151f8