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.