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:
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.
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:
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.
To detach the subnet, run the following command:
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:
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:
Now, when you run
ibmcloud ks subnets, the subnet will no longer appear in the output.
More information can be found in the IBM Cloud Kubernetes Service documentation.