Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to access kubernetes NodePort service from browser

I am doing my practice on Kubernetes through Minikube on my AWS EC2. As part of that, I have created deployment and exposed that through NodePort service, then checked with:

curl http://<node-ip>:<service-port>

in EC2 Machine that worked fine. But when I hit the same URL on browser gave me:

This site can't be reached

Can anyone help me what is the problem and how can I access this?

Thank you.

This is my Deployment YAML file:


apiVersion: apps/v1
kind: Deployment
metadata:
  name: myfirstdeployment
  labels:
    app: web
spec:
  replicas: 1
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      name: myfirstpod
      labels:
        app: web
    spec:
      containers:
      - name: myfirstpod-1
        image: nginx
        command: ["sleep","3600"]
        ports:
        - containerPort: 80

This is my Service YAML file


apiVersion: v1
kind: Service
metadata:
  name: myfirstservice
spec:
  selector:
    app: web
  ports:
  - targetPort: 80 #target container's port
    port: 80 #service port
    nodePort: 30030 #node port that we access to
  type: NodePort

like image 565
Aravind Avatar asked Feb 02 '26 09:02

Aravind


1 Answers

I strongly recommend going through the official tutorial showing the Accessing apps options in Minikube:

How to access applications running within minikube There are two major categories of services in Kubernetes:

  • NodePort
  • LoadBalancer

minikube supports either. Read on!

There you will find how to use both, the NodePort access:

A NodePort service is the most basic way to get external traffic directly to your service. NodePort, as the name implies, opens a specific port, and any traffic that is sent to this port is forwarded to the service.

Notice that you have to use minikube ip here.

And also the LoadBalancer access:

A LoadBalancer service is the standard way to expose a service to the internet. With this method, each service gets its own IP address.

This method uses the minikube tunnel command.

You can also use these docs as a supplement.

like image 171
Wytrzymały Wiktor Avatar answered Feb 04 '26 01:02

Wytrzymały Wiktor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!