0

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
zonko
  • 31
  • 3
  • 9

2 Answers2

1

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
gavinlin
  • 13
  • 6
  • 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 – zonko May 25 '18 at 11:25
  • curl 10.99.12.214:8085 curl: (7) Failed connect to 10.99.12.214:8085; Aucun chemin d'accès pour atteindre l'hôte cible – zonko May 25 '18 at 11:26
  • I supposed i have an error in rooting table or cidr configuration but i was enable to find what or where. – zonko May 25 '18 at 11:30
  • Can you ping the ip address 10.66.222.223 ? – gavinlin May 25 '18 at 11:31
  • What is the result of "ping 10.66.222.223", "route -n", – gavinlin May 25 '18 at 11:34
  • PS C:\Users\XXX> ping 10.66.222.223 Envoi d’une requête 'Ping' 10.66.222.223 avec 32 octets de données : Réponse de 10.66.222.223 : octets=32 temps=11 ms TTL=63 Réponse de 10.66.222.223 : octets=32 temps=1 ms TTL=63 Réponse de 10.66.222.223 : octets=32 temps=1 ms TTL=63 Réponse de 10.66.222.223 : octets=32 temps=1 ms TTL=63 – zonko May 25 '18 at 11:34
  • 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 – zonko May 25 '18 at 11:36
  • What is the content of service yaml? – gavinlin May 25 '18 at 11:57
  • I have add the answer in the question. – zonko May 25 '18 at 11:59
  • Is your program inside the pod receiving tcp/udp socket from port 8085 ? – gavinlin May 25 '18 at 12:07
  • don't know it's docker image of dahuss/a-dark-room. i have allready test it with pure docker and it work fine. how can a check ? – zonko May 25 '18 at 12:10
  • I try dahuss/a-dark-room, there is no process running at the container if you don't execute them manually. – gavinlin May 25 '18 at 12:21
  • ?? i run for me – zonko May 25 '18 at 12:42
  • docker run -p 80:80 --name dark -d -it dahuss/a-dark-room – zonko May 25 '18 at 12:42
  • curl 127.0.0.1 – zonko May 25 '18 at 12:42
  • nodePort range is between 30000-32767. Try to replace targetPort: http to targetPort: 80 – gavinlin May 28 '18 at 04:24
0

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)

zonko
  • 31
  • 3
  • 9