I have a Kubernetes cluster (Vagrant & CoreOS) running with 2 workers 
locally. 


I can deploy a Docker Image on this Kubernetes cluster with:

*$ kubectl run api4docker --image=myhost:5000/api4docker:latest 
--replicas=2 --port=8080 —env="SPRING_PROFILES_ACTIVE=production"*


When I get the pods, I see them running fine

*$ kubectl get pods* NAME                          READY     STATUS    
RESTARTS   AGE
api4docker-2839975483-9muv5   1/1       Running   0          8s

api4docker-2839975483-lbiny   1/1       Running   0          8s


I expose this deployment as service with:

*$ kubectl expose deployment **api4docker* *--port=8080 --type=LoadBalancer*
  


Here is more information about exposed service.
*$ kubectl get svc api4docker*
NAME         CLUSTER-IP   EXTERNAL-IP   PORT(S)    AGE
api4docker   10.3.0.95                                 8090/TCP   20m

*$ kubectl describe services api4docker*
Name:          api4docker
Namespace: default
Labels:         run=api4docker
Selector:       run=api4docker
Type:            LoadBalancer
IP:               10.3.0.95
Port:             <unset> 8090/TCP
NodePort:     <unset> 30959/TCP
Endpoints:    10.2.46.2:8080,10.2.97.3:8080
Session Affinity: None

No events.

After that, I can access this service only from the worker nodes. How can I 
make my service accessible from outside?

What is the suggested practice for exposing service to the public?

Thank you,

Turgos

Reply via email to