Creating a cluster network subnet
A cluster network subnet is a subnet within a cluster network. While it resembles a VPC subnet, it offers fewer features. However, it does let you define the subnet CIDR and configure reserved IPs for the cluster network subnet. These reserved IPs include addresses you specify and come with an auto-delete function similar to that of VPC subnet reserved IPs.
Before you begin
Review Planning considerations and Known issues and limitations.
You can create a cluster network subnet with the UI, CLI, API, or Terraform.
Creating a cluster network subnet in the UI
To create a subnet within a network cluster in the UI, follow these steps:
-
From your browser, open the IBM Cloud console and log in to your account.
-
Select the Navigation Menu , then click Infrastructure > Network > Cluster networks.
-
On the Cluster networks for VPC page, click the link of the cluster network name where you want to create a subnet. The Overview page displays.
-
Click the Subnets tab to show the Cluster network subnets table, then click Create +.
-
Complete the information in the Create subnet side panel, then click Create.
- Enter a subnet name.
- Review the address prefix. Change as needed.
- Select the number of total IP addresses (default is
256
). - Review the IP range stated. Change as needed.
- Review the specified address space. Adjust the IP range as needed.
The cluster network subnet is requested for use.
Creating a cluster network subnet in the CLI
To create a cluster network subnet in the CLI, follow these steps:
-
Log in to your account with the CLI. After you enter the password, the system prompts for the account and region that you want to use:
ibmcloud login --sso
-
To create a cluster network subnet, enter the following command:
ibmcloud is cluster-network-subnet-create CLUSTER_NETWORK (--total-ipv4-address-count TOTAL_IPV4_ADDRESS_COUNT | --ipv4-cidr-block IPV4_CIDR_BLOCK) [--name NAME] [--ip-version IP_VERSION] [--output JSON] [-q, --quiet]
Where:
CLUSTER_NETWORK
- ID or name for the cluster network.
--total-ipv4-address-count
- The total number of IPv4 addresses required. Must be a power of 2.
--ipv4-cidr-block
- The IPv4 range of the cluster network subnet, expressed in CIDR format.
--name
- The name for this cluster network subnet.
--output
- Specify output format, only JSON is supported. One of:
JSON
. -q
,--quiet
- Suppress verbose output.
Command example
To create a cluster network subnet with name cli-cn-sub-1
for cluster network cli-cn-1
:
ibmcloud is cluster-network-subnet-create cli-cn-1 --name cli-cn-sub-1 --total-ipv4-address-count 32
Creating a cluster network subnet with the API
To create a cluster network subnet with the API, follow these steps:
-
Set up your API environment with the right variables.
-
Store any additional variables to be used in the API commands; for example:
version
(string): The API version, in formatYYYY-MM-DD
. -
When all variables are initiated, run the following command to create the cluster network subnet:
curl -X POST "$vpc_api_endpoint/v1/cluster_networks/$cluster_network_id/subnets?version=$today&generation=2" -H "Authorization: Bearer $iam_token" -d '{ "name": "my-cluster-network-subnet", "total_ipv4_address_count": 2048 }'
To view the complete set of cluster network APIs, see the VPC API reference.
Creating a cluster network subnet with Terraform
The following example provisions a cluster network subnet by using Terraform:
resource "ibm_is_cluster_network_subnet" "is_cluster_network_subnet_instance" {
cluster_network_id = var.is_cluster_network_subnet_cluster_network_id
ip_version = var.is_cluster_network_subnet_ip_version
name = var.is_cluster_network_subnet_name
total_ipv4_address_count = var.is_cluster_network_subnet_total_ipv4_address_count
// ipv4_cidr_block = var.is_cluster_network_subnet_ipv4_cidr_block #conflicts with total_ipv4_address_count
}