by Anish
Posted on Friday January 18, 2019
This sample chapter extracted from the book, Kubernetes for DevOps .
Get this book on Just $9 or Ask Author for Discount
Well if you stuck in solving the problem of "kubernetes service external ip pending", let's visit the k8 concept once more time.
# kubectl run hello-world --replicas=2 --labels="run=LoadBalancer" --image=gcr.io/google-samples/node-hello:1.0 --port=8080
deployment.apps/hello-world created
# kubectl expose deployment hello-world --type=LoadBalancer --name=lb-service
service/lb-service exposed
# kubectl get services lb-service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
lb-service LoadBalancer 10.102.78.66 <pending> 8080:31031/TCP 1m
After you create the service, it takes time for the cloud infrastructure to create the load balancer and write its IP address into the Service object
Well All the time passes still kubernetes service external ip pending ?
If Kubernetes is running in an environment that doesn't support LoadBalancer services, the load balancer will not be provisioned, but the service will still behave like a NodePort service, your cloud/K8 engine should support LoadBalancer Service
In that case if you manage to add or EIP or VIP to your node then you can attach to the EXTERNAL-IP of your TYPE=LoadBalancer in k8 cluster, for example attaching the EIP/VIP address to the node 172.16.2.13
root@kube-master:/home/ansible# kubectl patch svc lb-service -p '{"spec": {"type": "LoadBalancer", "externalIPs":["172.16.2.13"]}}'
service/lb-service patched
root@kube-master:/home/ansible# kubectl get services lb-service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
lb-service LoadBalancer 10.102.78.66 172.16.2.13 8080:31031/TCP 10m
root@kube-master:/home/ansible# curl 172.16.2.13:8080
Hello Kubernetes!
since it's kubernetes you may encounter some issues, feel free to poke me
Thanku for reading !!! Give a Share for Support
Asking for donation sound bad to me, so i'm raising fund from by offering all my Nine book for just $9