Everytime I try to access a NodePort on my machine, it says "Error Connection Refused." I don't understand since the examples I read online imply that I can run Docker Desktop on my laptop, connect to the cluster, and access services via their nodeport.
My machine:
- Windows 10
- Docker Desktop (tested additionally with
k3sandminikubewith similar results) - Kubernetes 1.19+
Kubernetes Configuration:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: ngnix-service
spec:
selector:
app: nginx
type: NodePort
ports:
- protocol: TCP
port: 80
targetPort: 80
nodePort: 30007
Output and cURL test:
PS C:\Users\ME\nginx> kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 169m
ngnix-service NodePort 10.108.214.243 <none> 80:30007/TCP 7m19s
PS C:\Users\ME\nginx> curl.exe http://localhost:30007
curl: (7) Failed to connect to localhost port 30007: Connection refused
I've also tried with the node ip:
PS C:\Users\ME\nginx> kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
docker-desktop Ready master 6d v1.19.7 192.168.65.4 <none> Docker Desktop 5.10.25-linuxkit docker://20.10.5
PS C:\Users\ME\nginx> curl.exe http://192.168.65.4:30007
curl: (7) Failed to connect to 192.168.65.4 port 30007: Timed out
I get the same response when trying to access a NodePort from my browser (Chrome). ERR_CONNECTION_REFUSED
Is there something I'm missing? Why are all NodePorts inaccessible?
所有评论(0)