将Google Cloud单区域传统网络迁移至自定义VPC遇IP错误求助
Google Cloud传统网络转VPC时提示“前两个IP必须被使用”的问题
我尝试将Google Cloud单区域传统网络迁移至VPC网络,使用单区域转换工具和GKE网络转换脚本后,均碰到同一错误:
ERROR: (gcloud.beta.compute.networks.update) The first 2 IPs in this network's range 10.240.0.0/16 must be in used.
错误提及的前两个IP为网络IP10.240.0.0和默认网关10.240.0.1,这两个是传统网络默认分配的,无法手动修改。官方迁移指南仅要求确保网络最后两个IP10.240.0.254和10.240.0.255处于空闲状态,我环境中这两个IP确实未被占用,且指南的故障排查章节未提及该错误。有没有人遇到过此问题并找到解决办法?
EDIT-1:已使用的IP及关联资源
10.240.0.1 default gateway 10.240.0.3 compute#instance 10.240.0.4 compute#instance 10.240.0.7 compute#instance 10.240.0.18 compute#instance 10.240.0.22 compute#instance 10.240.0.23 compute#instance 10.240.0.28 compute#instance 10.240.0.31 compute#instance 10.240.0.34 compute#instance 10.240.0.37 compute#instance 10.240.0.39 compute#instance 10.240.0.43 compute#instance 10.240.0.44 compute#instance 10.240.0.56 compute#instance 10.240.0.58 compute#instance 10.240.0.60 compute#instance 10.240.0.68 compute#instance 10.240.0.75 compute#instance 10.240.0.81 compute#instance 10.240.0.84 compute#instance 10.240.0.101 compute#instance 10.240.0.105 compute#instance 10.240.0.106 compute#instance 10.240.0.109 compute#instance 10.240.0.111 compute#instance 10.240.0.117 compute#instance 10.240.0.123 compute#instance 10.240.0.124 compute#instance 10.240.0.133 compute#instance 10.240.0.137 compute#instance 10.240.0.175 compute#instance 10.240.92.185 compute#instance 10.240.117.221 compute#instance
EDIT-2:使用的命令及输出
GKE网络转换脚本命令
gkeconvert \ --project=<project-name> \ --network=<legacy-network-name> \ --control-plane-version=1.23.14-gke.1800 \ --node-version="-" \ --validate-only=false
输出:
INFO[0000] Fetching network <legacy-network-name> for project "<project-name>" INFO[0001] Initialize objects for conversion. INFO[0002] Initialize NodePool objects for Cluster projects/<project-name>/locations/<gcloud-zone>/clusters/<gke-cluster-name> INFO[0005] Validate resources for conversion. INFO[0005] Upgrade for Cluster projects/<project-name>/locations/<gcloud-zone>/clusters/<gke-cluster-name> is valid INFO[0005] Validate NodePool upgrade(s) for Cluster projects/<project-name>/locations/<gcloud-zone>/clusters/<gke-cluster-name> INFO[0005] Upgrade for NodePool projects/<project-name>/locations/<gcloud-zone>/clusters/<gke-cluster-name>/nodePools/<pool-1-name> is valid INFO[0005] Upgrade for NodePool projects/<project-name>/locations/<gcloud-zone>/clusters/<gke-cluster-name>/nodePools/<pool-2-name> is valid INFO[0005] Upgrade for NodePool projects/<project-name>/locations/<gcloud-zone>/clusters/<gke-cluster-name>/nodePools/<pool-3-name> is valid INFO[0005] Upgrade for NodePool projects/<project-name>/locations/<gcloud-zone>/clusters/<gke-cluster-name>/nodePools/<pool-4-name> is valid INFO[0005] Upgrade for NodePool projects/<project-name>/locations/<gcloud-zone>/clusters/<gke-cluster-name>/nodePools/<pool-5-name> is valid INFO[0005] Initiate resource conversion. INFO[0005] Switching legacy network projects/<project-name>/global/networks/<legacy-network-name> to custom mode VPC network Error: error waiting on Operation projects/<project-name>/global/operations/operation-xxxxxxxx-xxxxxxxx-xxxxxxxx-xxxxxx: The first 2 IPs in this network's range 10.240.0.0/16 must be in used.
单区域转换工具命令
gcloud beta compute networks update <legacy-network-name> --switch-to-custom-subnet-mode
输出:
Network [<legacy-network-name>] will be switched to custom mode. This operation cannot be undone. Do you want to continue (Y/n)? Y X Migrating Network from Legacy to Custom Mode . Validating Network . Creating Subnetwork . Updating Instances . Updating Instance Groups . Updating Forwarding Rules . Converting Network to Subnet Mode Failed. ERROR: (gcloud.beta.compute.networks.update) The first 2 IPs in this network's range 10.240.0.0/16 must be in used.
解决方法
手动预创建匹配子网
转换前先手动创建和传统网络CIDR一致的子网,明确绑定网关IP为10.240.0.1,让系统识别到该IP已被使用:gcloud compute networks subnets create <subnet-name> \ --network=<legacy-network-name> \ --range=10.240.0.0/16 \ --region=<your-region> \ --gateway-address=10.240.0.1重新执行转换命令
子网创建完成后,再运行之前的转换工具或脚本,此时系统会跳过自动创建子网的步骤,直接使用已创建的子网,避免校验错误。验证转换结果
转换完成后,检查子网配置及实例的网络关联状态,确认所有资源正常接入VPC网络。
内容的提问来源于stack exchange,提问作者vahiiid
相关产品推荐
相关产品推荐

