Reputation: 9733
I'm trying get the hello-node service running and accesssible from outside on an azure VM with minikube.
minikube start --driver=virtualbox
created deployment
kubectl create deployment hello-node --image=k8s.gcr.io/echoserver
exposed deployment
kubectl expose deployment hello-node --type=LoadBalancer --port=8080
suppose kubectl get services says:
hello-node LoadBalancer 1.1.1.1 8080:31382/TCP
The public IP of the azure VM is 2.2.2.2, the private IP is 10.10.10.10 and the virtualbox IP is 192.168.99.1/24
How can I access the service from a browser outside the cluster's network?
Upvotes: 0
Views: 393
Reputation: 91
In your case, you need you to use --type=NodePort for creating a service object that exposes the deployment. The type=LoadBalancer service is backed by external cloud providers.
kubectl expose deployment hello-node --type=NodePort --name=hello-node-service
Display information about the Service:
kubectl describe services hello-node-service
The output should be similar to this:
Name: example-service
Namespace: default
Labels: run=load-balancer-example
Annotations: <none>
Selector: run=load-balancer-example
Type: NodePort
IP: 10.32.0.16
Port: <unset> 8080/TCP
TargetPort: 8080/TCP
NodePort: <unset> 31496/TCP
Endpoints: 10.200.1.4:8080,10.200.2.5:8080
Session Affinity: None
Events: <none>
Make a note of the NodePort value for the service. For example, in the preceding output, the NodePort value is 31496.
Get the public IP address of your VM. And then you can use this URL:
http://<public-vm-ip>:<node-port>
Don't forget to open this port in firewall rules.
Upvotes: 2