Automate multiple subnet creation using 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 allows for automatic creation of
that will consume blocks from the parent
SubnetPool CIDR IP address
blockSize setting defines the IP address
block size to allocate to each child
SubnetPool has a global
scope, so any
SubnetPool can be used to create the
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
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
kubeconfigis located and where
The management cluster
kubeconfigis created during the last stage of the management cluster bootstrap.
subnetpool.yamlfile with a number of subnet pools:
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>
In the command above and in the steps below, substitute the parameters enclosed in angle brackets with the corresponding values.
Example of a
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
SubnetPoolobject, see SubnetPool spec.
Verify that the subnet pool is successfully created:
kubectl get subnetpool kaas-mgmt -oyaml
In the system output, verify the
statusfields of the
subnetpool.yamlfile. For the status fields description of the
SunbetPoolobject, 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 that contains the
l3Layoutsection, define all subnets that are used in the
npTemplatesection. Defining only part of subnets is not allowed.
labelSelectoris used in
l3Layout, 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