Reputation: 201
I am getting this error, when I am trying to access the Public IP's http exposure.
RajRajen:lb4btest rajrajen$ curl http://104.154.84.143:8000
curl: (56) Recv failure: Connection reset by peer
RajRajen:lb4btest rajrajen$ telnet 104.154.84.143 8000
Trying 104.154.84.143...
Connected to 143.84.154.104.bc.googleusercontent.com.
Escape character is '^]'.
Connection closed by foreign host.
RajRajen:lb4btest rajrajen$
< Pls note the above IP is just representation , Once I redeploy, the IP may change. But the problem is not >
Controller URL as it in in my json file .
RajRajen:lb4btest rajrajen$ kubectl create -f middleware-service.json
services/lb4b-api-v9
And the rc - replication controller json file.
{
"kind": "ReplicationController",
"apiVersion": "v1",
"metadata": {
"name": "lb4b-api-v9",
"labels": {
"app": "lb4bapi",
"tier": "middleware"
}
},
"spec": {
"replicas": 1,
"selector": {
"app": "lb4bapi",
"tier": "middleware"
},
"template": {
"metadata": {
"labels": {
"app": "lb4bapi",
"tier": "middleware"
}
},
"spec": {
"containers": [
{
"name": "lb4bapicontainer",
"image": "gcr.io/helloworldnodejs-1119/myproject",
"resources": {
"requests": {
"cpu": "500m",
"memory": "128Mi"
}
},
"env": [
{
"name": "GET_HOSTS_FROM",
"value": "dns"
},
{
"name": "PORT",
"value": "8000"
}
],
"ports": [
{
"name": "middleware",
"containerPort": 8000,
"hostPort": 8000
}
]
}
]
}
}
}
}
And here is the service json file
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "lb4b-api-v9",
"labels": {
"name": "lb4b-api-v9",
"app": "lb4bmiddleware",
"tier": "middleware"
}
},
"spec": {
"type": "LoadBalancer",
"selector": {
"name": "lb4b-api-v9",
"app": "lb4bmiddleware",
"tier": "middleware"
},
"ports": [
{
"protocol": "TCP",
"port": 8000
}
]
}
}
Docker container is running a node application as non-root user as per the pm2 requirement .
ENTRYPOINT ["pm2"]
CMD ["start", "app.js", "--no-daemon"]
I am perfectly able to do curl on this POD Local IP curl http://podIP:podPort inside the POD docker as well as inside the NODE. But unable to do curl on http://serviceLocalIP:8000 inside the NODE.
Can you please give some suggestions to make this work?
Thanks in advance.
Upvotes: 0
Views: 313
Reputation: 201
This issue is resolved.. After following the troubleshooting comment about the Service Endpoint, especially keeping the SERVICE selector value same as in POD selector value.
https://cloud.google.com/container-engine/docs/debugging/
Search for My service is missing endpoints
Solution in Controller.json
{
"kind": "ReplicationController",
"apiVersion": "v1",
"metadata": {
"name": "lb4b-api-v9",
"labels": {
"name": "lb4b-api-v9",
"app": "lb4bmiddleware",
"tier": "middleware"
}
},
"spec": {
"replicas": 1,
"selector": {
**"name": "lb4b-api-v9",
"app": "lb4bmiddleware",
"tier": "middleware"**
},
"template": {
"metadata": {
"labels": {
"name": "lb4b-api-v9",
"app": "lb4bmiddleware",
"tier": "middleware"
}
},
"spec": {
"containers": [
{
"name": "lb4b-api-v9",
"image": "gcr.io/myprojectid/myproect",
"resources": {
"requests": {
"cpu": "500m",
"memory": "128Mi"
}
},
"env": [
{
"name": "GET_HOSTS_FROM",
"value": "dns"
},
{
"name": "PORT",
"value": "8000"
}
],
"ports": [
{
"name": "middleware",
"containerPort": 8000,
"hostPort": 8000
}
]
}
]
}
}
}
}
And in Service.json
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "lb4b-api-v9",
"labels": {
"name": "lb4b-api-v9",
"app": "lb4bmiddleware",
"tier": "middleware"
}
},
"spec": {
"type": "LoadBalancer",
"selector": {
**"name": "lb4b-api-v9",
"app": "lb4bmiddleware",
"tier": "middleware"**
},
"ports": [
{
"protocol": "TCP",
"port": 8000
}
]
}
}
Thats all..
Upvotes: 1