Defining K8s Execute Command Job Properties
This job allows you to execute commands in one or more pods. The command is executed in one pod after the other, if the pod is active.
-
Connection
Select the K8s Connection object containing the relevant information to connect to the K8s system.
To search for a Connection object, start typing its name to limit the list of the objects that match your input.
-
Namespace
Define the namespace in which you want to execute the commands. You can click the browse button to the right of the field to open a picker dialog where you can select the relevant name.
-
Command
Define the command to be executed in the pods.
Note:To be able to execute an application command, you must set the shell beforehand. For example, to run the command java -version, you must set the shell as follows: bash -c "java -version".
-
Label Selector
Define the labels you want to use to filter the pods, for example, environment=test.
-
Field Selector
Define the fields you want to use to filter the pods, for example, metadata.name=my-service.
You can also use a combination of Label and Field Selectors.
-
Execute In:
-
All Pods
When the scope is set to All Pods and a Label Selector and/or Field Selector is used to identify pods, the command will be executed in all the running pods from the identified list. For example, if a label selector identifies fouractive pods, the command will be executed in all four of those pods.
-
Any Pod
This field will pickup any active pod and execute the command there. Rest pods will be skipped.
-
-
Pod Name
(Optional) If you know the pod name, you can input it, and the command will execute in that specific pod.
-
Container Name
(Optional) If you know the container name inside the pod, you can provide both the pod name and the container name. In this case, the commands will be executed within that specific container.
If you specify the container name, the command will always be executed in the given container. If container does not exist in the pod, it will fail the job.
None of the fields support regular expressions.
The job will fail if any of the following occur:
-
No active pods are found.
-
The command execution fails.
-
The specified container name does not exist inside the pod.
The Pre-Process page allows you to define the settings of all K8s Jobs using script statements. These statements are processed before the Schedule Job is executed, see Setting Kubernetes Job Properties Through Scripts.
See also: