I try to access to my deployment but can't reach NodePort net.
curl 10.99.12.214:30991
curl: (7) Failed connect to 10.99.12.214:30991; Aucun chemin d'accès pour atteindre l'hôte cible
kubectl get ep
NAME ENDPOINTS AGE
dark-room-dep 172.17.0.10:8085,172.17.0.9:8085 19h
kubernetes 10.66.222.223:6443 8d
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
dark-room-dep NodePort 10.99.12.214 <none> 8085:30991/TCP 19h
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 8d
kubectl cluster-info
Kubernetes master is running at https://10.66.222.223:6443
Heapster is running at https://10.66.222.223:6443/api/v1/namespaces/kube-system/services/heapster/proxy
KubeDNS is running at https://10.66.222.223:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
monitoring-grafana is running at https://10.66.222.223:6443/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
monitoring-influxdb is running at https://10.66.222.223:6443/api/v1/namespaces/kube-system/services/monitoring-influxdb/proxy
kubectl get deployment
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
dark-room-dep 2 2 2 2 20h
kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default dark-room-dep-577bf64bb8-9n5p7 1/1 Running 0 20h
default dark-room-dep-577bf64bb8-jmppg 1/1 Running 0 20h
kube-system etcd-localhost.localdomain 1/1 Running 6 8d
kube-system heapster-69b5d4974d-qvtrj 1/1 Running 0 1d
kube-system kube-apiserver-localhost.localdomain 1/1 Running 5 8d
kube-system kube-controller-manager-localhost.localdomain 1/1 Running 4 8d
kube-system kube-dns-86f4d74b45-njzj9 3/3 Running 0 1d
kube-system kube-flannel-ds-h9c2m 1/1 Running 3 6d
kube-system kube-flannel-ds-tcbd7 1/1 Running 5 8d
kube-system kube-proxy-7v6mf 1/1 Running 3 6d
kube-system kube-proxy-hwbwl 1/1 Running 4 8d
kube-system kube-scheduler-localhost.localdomain 1/1 Running 6 8d
kube-system kubernetes-dashboard-7d5dcdb6d9-q42q5 1/1 Running 0 1d
kube-system monitoring-grafana-69df66f668-zf2kc 1/1 Running 0 1d
kube-system monitoring-influxdb-78d4c6f5b6-nhdbx 1/1 Running 0 1d
route -n
Table de routage IP du noyau
Destination Passerelle Genmask Indic Metric Ref Use Iface
0.0.0.0 10.66.222.1 0.0.0.0 UG 100 0 0 ens192
10.66.222.0 0.0.0.0 255.255.254.0 U 100 0 0 ens192
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
172.25.1.0 172.25.1.0 255.255.255.0 UG 0 0 0 flannel.1
kubectl get nodes --all-namespaces
NAME STATUS ROLES AGE VERSION
k8s-01 Ready <none> 6d v1.10.2
localhost.localdomain Ready master 8d v1.10.2
from k8s-master: curl 10.66.222.223:30991
curl: (7) Failed connect to 10.66.222.223:30991; Aucun chemin d'accès pour atteindre l'hôte cible
from a lambda pc: PS C:\Users\XXX> curl 10.66.222.223:30991
curl : can not connect to distant host
at char Ligne:1 : 1
+ curl 10.66.222.223:30991
kubectl describe svc dark-room
Name: dark-room-dep
Namespace: default
Labels: app=dark-room
Annotations: <none>
Selector: app=dark-room
Type: NodePort
IP: 10.99.12.214
Port: <unset> 8085/TCP
TargetPort: 8085/TCP
NodePort: <unset> 30991/TCP
Endpoints: 172.17.0.10:8085,172.17.0.9:8085
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
cat dark-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: dark-room
namespace: default
labels:
run: dark-room
app: dark-room-svc
spec:
externalIPs:
- 10.66.222.223
type: ClusterIP
ports:
- name: http
port: 8085
nodePort: 8086
targetPort: http
protocol: TCP
selector:
run: dark-room
app: dark-room
nodePort range is between 30000-32767. Try to replace targetPort: http to targetPort: 80 – gavinlin
Thx you.
It work when I force on port 80.
expose deployment dark-room-dep --type=NodePort --port=80 --name=dark-svc
But I don't understand why doesn't work on any orther port I try (I have no firewall end setenforce 0)
NodePort will bind the external port to node IP.
Try
curl <node external IP>:<external port>
curl 10.66.222.223:30991
or
curl <service internal IP>:<internal port>
curl 10.99.12.214:8085