Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute a command after pod startup without overriding image entrypoint

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?

like image 633
mark dev Avatar asked Sep 15 '25 14:09

mark dev


1 Answers

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"]
like image 135
mario Avatar answered Sep 17 '25 12:09

mario