Unable to access node app from K8s cluster
Just like @Hackerman described, if you using the LoadBalancer type of service you need to use minikube tunnel
. You can follow the example. This type of service is usually meant to provision a provider Load Balancer, for example, an AWS ELB. But in the case of minikube there is no external provider and you need to trick it into thinking there is one.
Basically, you need to run it before you create your Deployment.
On a separate terminal:
minikube tunnel
Then apply your manifest YAML file that includes your definition in your question:
kubectl apply -f <your-deployment>.yaml
✌️
In addition to @Rico answer: there are two ways to access applications deployed on minikube.
First- using NodePort. When exposing application using NodePort
service type you are able to access it by executing minikube service list
and accessing URL shown by the output- it is result of minikube ip
and nodeport. Output will be similar to this:
|-------------|------------|----------------------------|-----|| NAMESPACE | NAME | TARGET PORT | URL ||-------------|------------|----------------------------|-----|| || default | nginx | http://192.168.39.22:30345 || ||-------------|------------|----------------------------|-----|
Second option is by using minikube tunnel
command. It assigns externalIP to application exposed byLoadBalancer
service type. When trying to access it minikube tunnel
has to be running and in separate terminal you can access it using externalIP:port
. Example output of minikube tunnel
:
$minikube tunnelStatus: machine: minikube pid: 9284 route: 10.96.0.0/12 -> 192.168.39.22 minikube: Running services: [backend-load]
Then you can check external IP assigned to this service by running kubectl get service
:
kubectl get svcNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEbackend-load LoadBalancer 10.100.120.115 10.100.120.115 3000:31676/TCP 110s
so in this example application will be accessible under 10.100.120.115:3000
.