I am learning K8s and the NodePort service is returning me timeout error while accessing it from outside the cluster. Inside the cluster it works alright. I have Minikube using docker driver.
I created the following deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: sample-python-app
labels:
app: sample-python-app
spec:
replicas: 2
selector:
matchLabels:
app: sample-python-app
template:
metadata:
labels:
app: sample-python-app
spec:
containers:
- name: python-app
image: abhishekf5/python-sample-app-demo:v1
ports:
- containerPort: 8000
and the service.yml is as follows:
apiVersion: v1
kind: Service
metadata:
name: python-django-app-service
spec:
type: NodePort
selector:
app: sample-python-app
ports:
- port: 80
targetPort: 8000
nodePort: 30007
Now when I try to access it inside the cluster, it works just fine:
minikube ssh
curl -L http://<cluster ip>:80/demo
But as soon as I hit the following outside the cluster, it times out:
curl -L http://<minikube ip>:30007/demo //Using -L because the app requires a redirect to work//
This is the python django app that I'm trying to access (Docker file is in the github repo only):
This post didn't help me either.
What am I doing wrong here?