kubernetesistiokubernetes-cronjob

Terminate istio-proxy after cronjob completion


I have a k8s cronjob run my docker image transaction-service.

It starts and gets its job done successfully. When it's over, I expect the pod to terminate but... istio-proxy still lingers there:

containers

And that results in:

unready pod

Nothing too crazy, but I'd like to fix it.

I know I should call curl -X POST http://localhost:15000/quitquitquit

But I don't know where and how. I need to call that quitquitquit URL only when transaction-service is in a completed state. I read about preStop lifecycle hook, but I think I need more of a postStop one. Any suggestions?


Solution

  • In my Dockerfile I put

    ADD ./entrypoint.sh /entrypoint.sh
    RUN ["chmod", "+x", "/entrypoint.sh"]
    RUN apk --no-cache add curl
    ENTRYPOINT ["/entrypoint.sh"]
    

    My entrypoint.sh looks like this:

    #!/bin/sh
    /app/myapp && curl -X POST http://localhost:15000/quitquitquit
    

    It works.