1

I am using minikube to test my application locally before deploying it to GKE.

However, I still can not access my application through the nodeport despite specifying the appropriate ports and aligning all the labels between the service and deployment.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: fastapi-deployment
  labels:
    app: fastapi
spec:
  replicas: 1
  selector:
    matchLabels:
      app: fastapi
  template:
    metadata:
      labels:
        app: fastapi
    spec:
      containers:
      - name: fastapi
        image: jrpespinas/ml-engine-sample:1.1.3
        ports:
        - containerPort: 8080

---

apiVersion: v1
kind: Service
metadata:
  name: fastapi-service
spec:
  type: NodePort
  selector:
    app: fastapi
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080
    nodePort: 30700

Using the following command, this was the output.

$ minikube service fastapi-service    
|-----------|-----------------|-------------|---------------------------|
| NAMESPACE |      NAME       | TARGET PORT |            URL            |
|-----------|-----------------|-------------|---------------------------|
| default   | fastapi-service |        8080 | http://192.*.*.*:30700 |
|-----------|-----------------|-------------|---------------------------|

I used asterisk to mask the actual url.

I have been trying out the previous stackoverflow answers but unfortunately nothing works.

David Maze
  • 130,717
  • 29
  • 175
  • 215
bogs__e
  • 11
  • 1
  • [Expose port in minikube](https://stackoverflow.com/questions/40767164/expose-port-in-minikube) has quite a bit of discussion of this; is this question different from what's asked there? – David Maze Apr 06 '23 at 10:24
  • Gave it a look. I can access it through the local IP given, but I need to access it through the : – bogs__e Apr 06 '23 at 10:36
  • Did you have time to check my answer? It helped you to solve your issue? If not, I am happy to assist further. – Sai Chandra Gadde Apr 13 '23 at 06:23

2 Answers2

0

You can follow the below troubleshooting steps in order to overcome the issue:

  1. Check your firewall rules if the port is blocked, you can check it by using telnet command with minikube ip and port number 30700.

  2. Try port forwarding using below command:

    kubectl port-forward service {serviceName} -n {namespaceName} {portNumberToAccess}:{portNumberOfService}.

  3. Try the resolution steps mentioned by harlesbayu in this git issue.

a) Install virtualbox

b) Start minikube => minikube start --driver=virtualbox

c) Check ip minikube: minikube ip

For more information refer to this document.

Sai Chandra Gadde
  • 2,242
  • 1
  • 3
  • 15
0

try to run minikube tunnel

tunnel

edit:
minikube simulates a cluster on your host
so you have a port in the container, a port in the cluster, and a port for your host system to talk to the cluster.
on Windows 10 using docker as driver for minikube
I needed to use a tunnel for crate tunnel between minikube VM and my host.
so my new address was something like: http://127.0.0.1:59759
and all the traffic forwarded to the Kubernetes cluster via that tunnel

yoad
  • 65
  • 6