Kubernetes. How to avoid kubernetes to retry a request against other replicas?

6/18/2017

I have an image runing a node.js application. Inside this application I have the method /kill that kill the process ("process.exit();").

I have a deployment with three replicas running the above image. I expose the deployment through a service of type NodePort.

When I call the /kill against one replica it exists and the request fails then kubernetes retry the request against the other replicas and all of them exit.

This is my service:

apiVersion: v1
kind: Service
metadata:
  name: hellokube-service
  labels:
    app: hellokube
spec:
  type: NodePort
  ports:
  - port: 8080
    targetPort: 8080
    nodePort: 31111
  selector:
    app: hellokube

Is it possible to avoid this retry?

-- Jxadro
kubernetes

1 Answer

6/19/2017

It was not kubernetes who was retrying. It was the browser.

My node.js method implementation is:

app.get("/kill", function(req, res, next){
    logger.info("Somebody kill me.");
    process.exit();
});

It is a get and it returns nothing. The browser detect an unexpected loose of connection with an idempotent operation and retry the operation. https://mnot.github.io/I-D/httpbis-retry/

If I return something or I change the operation to a POST operation it does not happen.

I didn't know about this browser behavior.

If you make the invoke to the original operation using curl instead of a browser it does not retry. SOAPUI does retry.

-- Jxadro
Source: StackOverflow