Detaching Public and Private Portable Subnet Ranges with IBM Cloud Kubernetes Service

1 min read

There is a new command to help manage public and private portable subnet resources.

In version 0.3.95 of the IBM Cloud Kubernetes Service CLI plug-in, a new command is introduced to help you manage the public and private portable subnet resources attached your clusters in the IBM Cloud Kubernetes Service:

ibmcloud ks cluster-subnet-detach

If you no longer need subnets from your IBM Cloud classic infrastructure account that you added to a cluster, you can now use this command to easily detach those subnets from your cluster. When you remove a subnet, it is no longer available to your cluster, but it still exists in your IBM Cloud classic infrastructure account.

Listing subnets

After logging in through the IBM Cloud CLI, you can list all existing portable subnets that are available in your IBM Cloud classic infrastructure account by running:

ibmcloud ks subnets

Example output:

ID        Network             Gateway          VLAN ID   Type      Bound Cluster

...

1602829   169.1.1.1/29        169.1.1.2        2234945   public    df253b6025d64944ab99ed63bb4567b6

In the output, note the ID of the subnet and the cluster ID in the Bound Cluster field to use in the detach command. (Note: If you need to find the ID of a cluster, you can run ibmcloud ks clusters.) 

You can further determine which subnets are attached to a cluster by running ibmcloud ks cluster-get --cluster CLUSTER_NAME_OR_ID --showResources and looking for the Subnet CIDRs in the Subnets VLANs section in the output.

Detaching subnets

To detach the subnet, run the following command:


ibmcloud ks cluster-subnet-detach --cluster CLUSTER --subnet-id SUBNET_ID [-f] [-s]

Subnets can only be detached from a cluster if none of the IPs derived from that subnet range are in use in your cluster.

After the subnet is detached, it still remains available in your IBM Cloud account for use with other clusters. If you want to attach it to another cluster, you can run the following command:

ibmcloud ks cluster-subnet-add --cluster CLUSTER_NAME_OR_ID --subnet-id SUBNET_ID

Safely deleting subnets

Now that your subnets are safely detached, you can delete the subnets without causing issues in your Kubernetes cluster. To delete a subnet from your IBM Cloud classic infrastructure account, use the following command:

ibmcloud sl subnet cancel SUBNET_ID

Now, when you run ibmcloud ks subnets, the subnet will no longer appear in the output.

More details

More information can be found in the IBM Cloud Kubernetes Service documentation.

Contact us

If you have questions, engage our team via Slack by registering here and join the discussion in the #general channel on our public IBM Cloud Kubernetes Service Slack.

Be the first to hear about news, product updates, and innovation from IBM Cloud