Automate multiple subnet creation using SubnetPool¶
Deprecated since 2.27.0 (17.2.0 and 16.2.0)
Warning
The SubnetPool
object may not work as expected due to its
deprecation. If you still require this feature, contact Mirantis support
for further information.
Existing configurations that use the SubnetPool
object in L2Template
will be automatically migrated during cluster update to the Cluster release
17.2.0 or 16.2.0. As a result of migration, existing Subnet
objects will
be referenced in L2Template
objects instead of SubnetPool
.
Operators of Mirantis Container Cloud for on-demand self-service Kubernetes deployments will want their users to create networks without extensive knowledge about network topology or IP addresses. For that purpose, the Operator can prepare L2 network templates in advance for users to assign these templates to machines in their clusters.
The Operator can ensure that the users’ clusters have separate
IP address spaces using the SubnetPool
resource.
SubnetPool
allows for automatic creation of Subnet
objects
that will consume blocks from the parent SubnetPool
CIDR IP address
range. The SubnetPool
blockSize
setting defines the IP address
block size to allocate to each child Subnet
. SubnetPool
has a global
scope, so any SubnetPool
can be used to create the Subnet
objects
for any namespace and for any cluster.
You can use the SubnetPool
resource in the L2Template
resources to
automatically allocate IP addresses from an appropriate IP range that
corresponds to a specific cluster, or create a Subnet
resource
if it does not exist yet. This way, every cluster will use subnets
that do not overlap with other clusters.
To automate multiple subnet creation using SubnetPool:
Log in to a local machine where your management cluster
kubeconfig
is located and wherekubectl
is installed.Note
The management cluster
kubeconfig
is created during the last stage of the management cluster bootstrap.Create the
subnetpool.yaml
file with a number of subnet pools:Note
You can define either or both subnets and subnet pools, depending on the use case. A single L2 template can use either or both subnets and subnet pools.
kubectl --kubeconfig <pathToManagementClusterKubeconfig> apply -f <SubnetFileName.yaml>
Note
In the command above and in the steps below, substitute the parameters enclosed in angle brackets with the corresponding values.
Example of a
subnetpool.yaml
file:apiVersion: ipam.mirantis.com/v1alpha1 kind: SubnetPool metadata: name: kaas-mgmt namespace: default labels: kaas.mirantis.com/provider: baremetal kaas.mirantis.com/region: region-one spec: cidr: 10.10.0.0/16 blockSize: /25 nameservers: - 172.18.176.6 gatewayPolicy: first
For the specification fields description of the
SubnetPool
object, see SubnetPool spec.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.Verify that the subnet pool is successfully created:
kubectl get subnetpool kaas-mgmt -oyaml
In the system output, verify the
status
fields of thesubnetpool.yaml
file. For the status fields description of theSunbetPool
object, see SubnetPool status.Proceed to creating an L2 template for one or multiple managed clusters as described in Create L2 templates. In this procedure, select the exemplary L2 template for multiple subnets.
Caution
Using the
l3Layout
section, define all subnets that are used in thenpTemplate
section. Defining only part of subnets is not allowed.If
labelSelector
is used inl3Layout
, use any custom label name that differs from system names. This allows for easier cluster scaling in case of adding new subnets as described in Expand IP addresses capacity in an existing cluster.Mirantis recommends using a unique label prefix such as
user-defined/
.