I am trying to expose a kubernetes "deployment" via the kubectl expose
command, wih a static IP address, on Google Container Engine.
With an ephemeral IP, everything works fine:
kubectl expose deployment my-application \
--type="LoadBalancer" --port=80 --target-port=8080
I use kubectl get services
and wait a few minutes to see the ephemeral IP having been assigned. I enter the IP in my browser and I see the applicaiton, i.e. everything works.
However, when I do the following:
Create a static IP address using the gcloud web interface (Networking -> External IP addresses -> Reserve Static IP address)
Re-create the service with the same command as above but with the extra
--load-balancer-ip
optionkubectl expose deployment my-application \ --type="LoadBalancer" --port=80 --target-port=8080 \ --load-balancer-ip='1.2.3.4' # IP as assigned by web interface above
The command is successful, but the application is not reachable under that IP address, and when I use the following command:
$ kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
endpoints 10.119.247.39 <pending> 80/TCP 23m
kubernetes 10.119.240.1 <none> 443/TCP 1d
I see that the EXTERNAL-IP
is still <pending>
although I've waited 23 minutes so far.
What am I doing wrong?
The command you provided worked for me. In a first attempt to exposed the service I used a static IP address defined in a different region from where the Load Balancer was being created. As a result the Load Balancer was not created and the service kept in a "Pending" state.
Then I used an IP defined in us-central where my nodes lives.
Then:
I would suggest making sure the IP exists in the same region the cluster lives. If that fails, to obtain more information on the state by using
kubectl get events
. That might shed some light.