Invalid value for field 'resource.subnetwork. Network interface must specify a subnet if the network resource is in custom subnet mode

1/27/2021

As part of GCE configuration, Using CCM(Cloud Controller Manager) Kubernetes API to launch this loadbalancer. I have configured a custom VPC network and custom subnet and tried launching a Internal loadbalancer to publish my services within the project.

Problem is creation of Internal LB got failed.

system 50s Normal EnsuringLoadBalancer service/ABC Ensuring load balancer

system 59s Warning SyncLoadBalancerFailed service/ABC Error syncing load balancer: failed to ensure load balancer: googleapi: Error 400: Invalid value for field 'resource.subnetwork': ''. Network interface must specify a subnet if the network resource is in custom subnet mode., invalid

Manifest files as following annotation

cloud.google.com/load-balancer-type: "Internal"

Any suggestions to solve this error are most welcome?

-- aroraman
google-cloud-platform
google-compute-engine
kubernetes

1 Answer

1/28/2021

As you mentioned the annotation "cloud.google.com/load-balancer-type: "Internal"" should allow you to create an Internal TCP/UDP Load balancer as states this documentation: "GKE creates an internal TCP/UDP load balancer when you add the cloud.google.com/load-balancer-type: "Internal" annotation; otherwise, GKE creates an external network load balancer."

On the other hand, have you tried to create a service using the annotation as the information states

"apiVersion: v1
kind: Service
metadata:
  name: ilb-service
  annotations:
    networking.gke.io/load-balancer-type: "Internal"
......."

As a complement to the aforementioned information seems like the load balancer subnet can be selected according to "Load balancer subnet" section by using the annotation "networking.gke.io/internal-load-balancer-subnet" as a side note. The subnet must exist before it is referenced by the Service. The example provided is as follows:

"apiVersion: v1
kind: Service
metadata:
  name: ilb-service
  annotations:
    networking.gke.io/load-balancer-type: "Internal"
    networking.gke.io/internal-load-balancer-subnet: "gke-vip-subnet"
......
"

Hope this information helps you with this behavior.

-- cochitoo
Source: StackOverflow