When I create a Kubernetes Load Balancer Service using the following specification:
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"name": "a1"
},
"spec": {
"selector": {
"app": "a1"
},
"ports": [
{
"port": 80,
"targetPort": 80,
"name": "http"
},
{
"port": 443,
"targetPort": 443,
"name": "https"
}
],
"type": "LoadBalancer"
}
}
I have to wait between 1 and 2 minutes until I get an EXTERNAL_IP
.
I thought of reserving static IPs before and assigning them on Service creation:
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"name": "a1"
},
"spec": {
"selector": {
"app": "a1"
},
"ports": [
{
"port": 80,
"targetPort": 80,
"name": "http"
},
{
"port": 443,
"targetPort": 443,
"name": "https"
}
],
"type": "LoadBalancer",
"loadBalancerIP": "130.211.64.237"
}
}
But I have the same delay 1 - 1.5 minutes:
$ kubectl get svc
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
a1 10.127.248.248 130.211.64.237 80/TCP,443/TCP app=a1 1m
Does anyone know why this delay happens and if there is a way to shorten it?
The delay is unfortunately just caused by latency in the Compute Engine APIs for creating the components of a load balanced service, and there's no real way to avoid it.
The Kubernetes master, when instructed to create a load balancer, has to create a static IP address, a target pool, a forwarding rule, and a firewall rule. These resources can take some time to fully initialize and be ready for use, so a wait of a minute or two is to be expected for now.