Class Exec

java.lang.Object
io.kubernetes.client.Exec
Direct Known Subclasses:
Copy

public class Exec extends Object
  • Constructor Details

    • Exec

      public Exec()
      Simple Exec API constructor, uses default configuration
    • Exec

      public Exec(io.kubernetes.client.openapi.ApiClient apiClient)
      Exec API Constructor
      Parameters:
      apiClient - The api client to use.
  • Method Details

    • getApiClient

      public io.kubernetes.client.openapi.ApiClient getApiClient()
      Get the API client for these exec operations.
      Returns:
      The API client that will be used.
    • setApiClient

      public void setApiClient(io.kubernetes.client.openapi.ApiClient apiClient)
      Set the API client for subsequent exec operations.
      Parameters:
      apiClient - The new API client to use.
    • getOnUnhandledError

      public Consumer<Throwable> getOnUnhandledError()
      Get a Consumer<Throwable> that will be accepted if there is any unhandled exception while the websocket communication is happening.
      Returns:
      The Consumer<Throwable> that will be used.
    • setOnUnhandledError

      public void setOnUnhandledError(Consumer<Throwable> onUnhandledError)
      Set the Consumer<Throwable> that will be accepted if there is any unhandled exception while the websocket communication is happening.
      Parameters:
      onUnhandledError - The new Consumer<Throwable> to use.
    • newExecutionBuilder

      public Exec.ExecutionBuilder newExecutionBuilder(String namespace, String name, String[] command)
      Setup a Builder for the given namespace, name and command
      Parameters:
      namespace - The namespace of the Pod
      name - The name of the Pod
      command - The command to run
    • exec

      public Process exec(String namespace, String name, String[] command, boolean stdin) throws io.kubernetes.client.openapi.ApiException, IOException
      Execute a command in a container. If there are multiple containers in the pod, uses the first container in the Pod.
      Parameters:
      namespace - The namespace of the Pod
      name - The name of the Pod
      command - The command to run
      stdin - If true, pass a stdin stream into the container
      Throws:
      io.kubernetes.client.openapi.ApiException
      IOException
    • exec

      public Process exec(io.kubernetes.client.openapi.models.V1Pod pod, String[] command, boolean stdin) throws io.kubernetes.client.openapi.ApiException, IOException
      Execute a command in a container. If there are multiple containers in the pod, uses the first container in the Pod.
      Parameters:
      pod - The pod where the command is run.
      command - The command to run
      stdin - If true, pass a stdin stream into the container
      Throws:
      io.kubernetes.client.openapi.ApiException
      IOException
    • exec

      public Process exec(String namespace, String name, String[] command, boolean stdin, boolean tty) throws io.kubernetes.client.openapi.ApiException, IOException
      Execute a command in a container. If there are multiple containers in the pod, uses the first container in the Pod.
      Parameters:
      namespace - The namespace of the Pod
      name - The name of the Pod
      command - The command to run
      stdin - If true, pass a stdin stream into the container
      tty - If true, stdin is a tty.
      Throws:
      io.kubernetes.client.openapi.ApiException
      IOException
    • exec

      public Process exec(io.kubernetes.client.openapi.models.V1Pod pod, String[] command, boolean stdin, boolean tty) throws io.kubernetes.client.openapi.ApiException, IOException
      Execute a command in a container. If there are multiple containers in the pod, uses the first container in the Pod.
      Parameters:
      pod - The pod where the command is run.
      command - The command to run
      stdin - If true, pass a stdin stream into the container
      tty - If true, stdin is a tty.
      Throws:
      io.kubernetes.client.openapi.ApiException
      IOException
    • exec

      public Process exec(io.kubernetes.client.openapi.models.V1Pod pod, String[] command, String container, boolean stdin, boolean tty) throws io.kubernetes.client.openapi.ApiException, IOException
      Execute a command in a container. If there are multiple containers in the pod, uses the first container in the Pod.
      Parameters:
      pod - The pod where the command is run.
      command - The command to run
      container - The container in the Pod where the command is run.
      stdin - If true, pass a stdin stream into the container.
      tty - If true, stdin is a TTY (only applies if stdin is true)
      Throws:
      io.kubernetes.client.openapi.ApiException
      IOException
    • exec

      public Process exec(String namespace, String name, String[] command, String container, boolean stdin, boolean tty) throws io.kubernetes.client.openapi.ApiException, IOException
      Execute a command in a container. If there are multiple containers in the pod, uses the first container in the Pod.
      Parameters:
      namespace - The namespace of the Pod
      name - The name of the Pod
      command - The command to run
      container - The container in the Pod where the command is run.
      stdin - If true, pass a stdin stream into the container.
      tty - If true, stdin is a TTY (only applies if stdin is true)
      Throws:
      io.kubernetes.client.openapi.ApiException
      IOException
    • exec

      public Future<Integer> exec(String namespace, String podName, Consumer<io.kubernetes.client.custom.IOTrio> onOpen, BiConsumer<Integer,io.kubernetes.client.custom.IOTrio> onClosed, BiConsumer<Throwable,io.kubernetes.client.custom.IOTrio> onError, Long timeoutMs, boolean tty, String... command) throws IOException
      A convenience method. Executes a command remotely on a pod and monitors for events in that execution. The monitored events are:
      - connection established (onOpen)
      - connection closed (onClosed)
      - execution error occurred (onError)
      This method also allows to specify a MAX timeout for the execution and returns a future in order to monitor the execution flow.
      onError and onClosed callbacks are invoked asynchronously, in a separate thread.
      Parameters:
      namespace - a namespace the target pod "lives" in
      podName - a name of the pod to exec the command on
      onOpen - a callback invoked upon the connection established event.
      onClosed - a callback invoked upon the process termination. Return code might not always be there. N.B. this callback is invoked before the returned Future is completed.
      onError - a callback to handle k8s errors (NOT the command errors/stderr!)
      timeoutMs - timeout in milliseconds for the execution. I.e. the execution will take this many ms or less. If the timeout command is running longer than the allowed timeout, the command will be "asked" to terminate gracefully. If the command is still running after the grace period, the sigkill will be issued. If null is passed, the timeout will not be used and will wait for process to exit itself.
      tty - whether you need tty to pipe the data. TTY mode will trim some binary data in order to make it possible to show on screen (tty)
      command - a tokenized command to run on the pod
      Returns:
      a Future promise representing this execution. Unless something goes south, the promise will contain the process return exit code. If the timeoutMs is non-null and the timeout expires before the process exits, promise will contain Integer.MAX_VALUE.
      Throws:
      IOException
    • runAsync

      protected void runAsync(String taskName, Runnable task)