Execute a command after pod startup without overriding image entrypoint

4/23/2021

I want to know if there is any solution in order to submit a flink job to a kubernetes cluster.

In the jobmanager deployment file after startup I tried to add a command option to my jobmanager pod but I realized that the command I passed override the image entrypoint.

So I want to know if there is a solution to do so?

-- mark dev
apache-flink
deployment
kubernetes

2 Answers

4/23/2021

Not specifically. Really it's up to your application. The only thing Kubernetes can control is what the initial command run inside the container is and there can only be one of those.

-- coderanger
Source: StackOverflow

4/26/2021

Yes, if you provide a command and/or its args, it overrides the original image's Entrypoint and/or Cmd. If you want to know how exactly it happens, please refer to this fragment of the official kubernetes docs.

If you want to run some additional command immediatelly after your Pod startup, you can do it with a postStart handler, which usage is presented in this example:

apiVersion: v1
kind: Pod
metadata:
  name: lifecycle-demo
spec:
  containers:
  - name: lifecycle-demo-container
    image: nginx
    lifecycle:
      postStart:
        exec:
          command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]
      preStop:
        exec:
          command: ["/bin/sh","-c","nginx -s quit; while killall -0 nginx; do sleep 1; done"]
-- mario
Source: StackOverflow