In GCP, I have a GKE with a workload configured. My service definition has the following annotation which automatically creates the network endpoint groups for me:
cloud.google.com/neg: '{"exposed_ports": {"80":{"name": "app2-service-80-neg"}}}'
I can then attach this to a backend load balancer service and all works well. However, shouldn't these network endpoint groups disappear if I delete the underlying service/deployment/pods? They seem to stick around after I delete everything at the kubernetes level which causes issues for my terraform because I run a terraform destroy regularly and it can't delete everything since these objects are still kicking around preventing me from deleting my VPC.
As @Vishal Bulbule mentioned NEG has to be deleted separately.
As per this official doc
Note that the NEG cannot be deleted if there are backend services referencing it.
So,
You can also use below to delete a network endpoint group named my-neg:
gcloud compute network-endpoint-groups delete my-neg --zone=us central1-a