I have two kubernetes environments. One is v1.10.4 and the other is v1.13.5. When I deploy a exactly same service yaml file into these two environments and using curl command to check the nodeport, I cannot get response from 1.13.5 version environment. The service yaml file exposes nodeport:31218 on both environment
Under 1.10 version, I can use curl command to check the service nodeport and get response.
root@k8s-v110:~# curl -XGET localhost:31218/consumers/admin/api_key
{"total":1,"data":[{"created_at":1557977118000,"main_key":true,"enabled":true,"ref_role":1,"id":"6ec7c50e02ce","expired_time":1573529118000,"key":"5c9e9b3c5066","consumer_id":"b9eb389a3c59"}]}
Under 1.13 version, If I use localhost for curl command, I did not get any response until I press ctrl+c
k8s-v113 [~] [root] # curl -XGET localhost:31218/consumers/admin/api_key
k8s-v113 [~] [root] # curl -XGET 10.111.33.10:31218/consumers/admin/api_key
{"total":1,"data":[{"created_at":1557906877000,"main_key":true,"enabled":true,"ref_role":1,"id":"68b629a3faeb","expired_time":1573458877000,"key":"60eee61045bc","consumer_id":"e0f2d6bf66ce"}]}
I just wondering is there any enhancement on k8s. Thus, I cannot use localhost directly?
There isn't any change on the NodePort. However, those 2 clusters might be configured differently, specifically the one with version 1.13 such that kube-proxy
doesn't bind to the localhost (127.0.0.1) but only specific network interfaces. Since it is the component responsible of NodePort
. You can check --nodeport-addresses
parameter on the kube-proxy to see which ips it binds to. If it is not specified or 0.0.0.0
, it binds to all interfaces, and problem would be at somewhere else.
Also check if localhost
is resolved correctly to 127.0.0.1
via nslookup localhost
, and also try curl'ing 127.0.0.1 instead:
curl -XGET 127.0.0.1:31218/consumers/admin/api_key