I have a service running on localhost:8888 and trying to bind that to cluster's public IP so that I can open it up from my web browser. I created another service using the following yaml file:
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "example-service"
},
"spec": {
"ports": [{
"port": 8888,
"targetPort": 8888
}],
"selector": {
"app": "example"
},
"type": "LoadBalancer"
}
}
Then I do kubectl describe services example-service
:
Name: example-service
Namespace: spark-cluster
Labels: <none>
Selector: app=example
Type: LoadBalancer
IP: 10.3.0.66
LoadBalancer Ingress: a123b456c789.us-west-1.elb.amazonaws.com
Port: <unset> 8888/TCP
NodePort: <unset> 32767/TCP
Endpoints: <none>
Session Affinity: None
Events:
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
14s 14s 1 {service-controller } Normal CreatingLoadBalancer Creating load balancer
11s 11s 1 {service-controller } Normal CreatedLoadBalancer Created load balancer
When I open up a123b456c789.us-west-1.elb.amazonaws.com:8888
in my web browser, it doesn't load. What are the correct steps to access my pod externally?
With your setup the application is available on ip adress of one of your node on port 32767 ( NodePort parameter ) if you want to give a NodePort yourself you need to change the code like this :
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "example-service"
},
"spec": {
"ports": [{
"port": 8888,
"targetPort": 8888
"nodePort": 8888
}],
"selector": {
"app": "example"
},
"type": "LoadBalancer"
}
}
http://kubernetes.io/docs/user-guide/services/#type-nodeport