I have an EKS cluster with only private subnets, i tried to expose a simple nginx service on nodePort and then check this url private-node-ip:nodePort on the browser but its showing this site can't be reached
here is my code :
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
type: NodePort
ports:
- port: 80
name: http
targetPort: 80
selector:
app: nginx
Your port: 80
value for the NodePort is outside the default allowable range (30000 to 32767) on kubernetes. This range can be changed, see for example here but I don't think you can expose the low port numbers with NodePort, though I'm open to correction. Hope this helps.
Edit - I misread the question above, and my original answer is incorrect. If your service had said NodePort: 80
, then the range would have been an issue.
But, reading your question again, NodePort is usually exposed for a public IP. If your cluster doesn't have a public IP, then the machine where you're browsing from will need to be on the same private network as your cluster. It won't be exposed to the public Internet. See here for some discussion on the issue.