Interface KubeCmdClient<K extends KubeCmdClient<K>>

Type Parameters:
K - The subtype of KubeClient, for fluency.
All Known Implementing Classes:
BaseCmdKubeClient, Kubectl, Oc

public interface KubeCmdClient<K extends KubeCmdClient<K>>
Abstraction for a Kubernetes client.
  • Method Details

    • defaultOlmNamespace

      String defaultOlmNamespace()
      Retrieves the default OLM (Operator Lifecycle Manager) namespace for the Kubernetes client.
      Returns:
      The default OLM namespace.
    • deleteByName

      K deleteByName(String resourceType, String resourceName)
      Deletes resources by resource name.
      Parameters:
      resourceType - The type of the resource to delete.
      resourceName - The name of the resource to delete.
      Returns:
      This kube client.
    • inNamespace

      KubeCmdClient<K> inNamespace(String namespace)
      Sets the namespace for subsequent operations.
      Parameters:
      namespace - The namespace to set.
      Returns:
      This kube client.
    • getCurrentNamespace

      String getCurrentNamespace()
      Retrieves the currently set namespace for the Kubernetes client.
      Returns:
      The currently set namespace.
    • create

      K create(File... files)
      Creates resources from the provided files.
      Parameters:
      files - The files containing resource definitions.
      Returns:
      This kube client.
    • apply

      K apply(File... files)
      Applies resource changes from the provided files.
      Parameters:
      files - The files containing resource changes.
      Returns:
      This kube client.
    • delete

      K delete(File... files)
      Deletes resources specified in the provided files.
      Parameters:
      files - The files containing resources to delete.
      Returns:
      This kube client.
    • create

      default K create(String... files)
      Creates resources from YAML files specified by file paths.
      Parameters:
      files - The paths to YAML files containing resource definitions.
      Returns:
      This kube client.
    • apply

      default K apply(String... files)
      Applies resource changes from YAML files specified by file paths.
      Parameters:
      files - The paths to YAML files containing resource changes.
      Returns:
      This kube client.
    • delete

      default K delete(String... files)
      Deletes resources specified in YAML files specified by file paths.
      Parameters:
      files - The paths to YAML files containing resources to delete.
      Returns:
      This kube client.
    • replace

      K replace(File... files)
      Replaces resources with the contents of the provided files.
      Parameters:
      files - The files containing resources to replace.
      Returns:
      This kube client.
    • applyContent

      K applyContent(String yamlContent)
      Applies resource content.
      Parameters:
      yamlContent - The YAML content representing the resources.
      Returns:
      This kube client.
    • deleteContent

      K deleteContent(String yamlContent)
      Deletes resource content.
      Parameters:
      yamlContent - The YAML content representing the resources to delete.
      Returns:
      This kube client.
    • createNamespace

      K createNamespace(String name)
      Creates a namespace with the given name.
      Parameters:
      name - The name of the namespace to create.
      Returns:
      This kube client.
    • deleteNamespace

      K deleteNamespace(String name)
      Deletes the namespace with the given name.
      Parameters:
      name - The name of the namespace to delete.
      Returns:
      This kube client.
    • scaleByName

      K scaleByName(String kind, String name, int replicas)
      Scales a resource by its kind and name.
      Parameters:
      kind - The kind of the resource.
      name - The name of the resource.
      replicas - The number of replicas.
      Returns:
      This kube client.
    • execInPod

      ExecResult execInPod(String pod, String... command)
      Executes a command within a pod.
      Parameters:
      pod - The name of the pod.
      command - The command to execute.
      Returns:
      The execution result.
    • execInPodContainer

      ExecResult execInPodContainer(String pod, String container, String... command)
      Executes a command within a pod container.
      Parameters:
      pod - The name of the pod.
      container - The name of the container.
      command - The command to execute.
      Returns:
      The execution result.
    • execInPodContainer

      ExecResult execInPodContainer(boolean logToOutput, String pod, String container, String... command)
      Executes a command within a pod container with logging to output control.
      Parameters:
      logToOutput - Determines if the output should be logged.
      pod - The name of the pod.
      container - The name of the container.
      command - The command to execute.
      Returns:
      The execution result.
    • exec

      ExecResult exec(String... command)
      Executes a command.
      Parameters:
      command - The command to execute.
      Returns:
      The execution result.
    • exec

      ExecResult exec(boolean throwError, String... command)
      Executes a command with control over throwing exceptions on failure.
      Parameters:
      throwError - Determines if an exception should be thrown on failure.
      command - The command to execute.
      Returns:
      The execution result.
    • exec

      ExecResult exec(boolean throwError, boolean logToOutput, String... command)
      Executes a command with control over throwing exceptions on failure and logging to output control.
      Parameters:
      throwError - Determines if an exception should be thrown on failure.
      logToOutput - Determines if the output should be logged.
      command - The command to execute.
      Returns:
      The execution result.
    • exec

      ExecResult exec(boolean throwError, boolean logToOutput, int timeout, String... command)
      Execute the given command. You can specify if potential failure will thrown the exception or not.
      Parameters:
      throwError - parameter which control thrown exception in case of failure
      command - The command
      timeout - tiemout in ms
      logToOutput - determines if we want to print whole output of command
      Returns:
      The process result.
    • get

      String get(String resource, String resourceName)
      Retrieves the YAML content of a resource.
      Parameters:
      resource - The type of the resource.
      resourceName - The name of the resource.
      Returns:
      The YAML content of the resource.
    • getEvents

      String getEvents()
      Retrieves a list of events within the current namespace.
      Returns:
      The list of events.
    • list

      List<String> list(String resourceType)
      Retrieves a list of resources by type.
      Parameters:
      resourceType - The type of the resources.
      Returns:
      The list of resources.
    • getResourceAsYaml

      String getResourceAsYaml(String resourceType, String resourceName)
      Retrieves the YAML content of a resource by type and name.
      Parameters:
      resourceType - The type of the resource.
      resourceName - The name of the resource.
      Returns:
      The YAML content of the resource.
    • getResourcesAsYaml

      String getResourcesAsYaml(String resourceType)
      Retrieves the YAML content of resources by type.
      Parameters:
      resourceType - The type of the resources.
      Returns:
      The YAML content of the resources.
    • createResourceAndApply

      void createResourceAndApply(String template, Map<String,String> params)
      Creates a resource from a template and applies it.
      Parameters:
      template - The template for the resource.
      params - The parameters for the template.
    • describe

      String describe(String resourceType, String resourceName)
      Retrieves a description of a resource.
      Parameters:
      resourceType - The type of the resource.
      resourceName - The name of the resource.
      Returns:
      The description of the resource.
    • logs

      default String logs(String pod)
      Retrieves logs for a pod.
      Parameters:
      pod - The name of the pod.
      Returns:
      The logs for the pod.
    • logs

      String logs(String pod, String container)
      Retrieves logs for a pod container.
      Parameters:
      pod - The name of the pod.
      container - The name of the container.
      Returns:
      The logs for the pod container.
    • searchInLog

      String searchInLog(String resourceType, String resourceName, long sinceSeconds, String... grepPattern)
      Searches for patterns in the logs of a resource.
      Parameters:
      resourceType - The type of the resource.
      resourceName - The name of the resource.
      sinceSeconds - The duration for the logs (e.g., "5s" for 5 seconds).
      grepPattern - The patterns to search for.
      Returns:
      The search result.
    • searchInLog

      String searchInLog(String resourceType, String resourceName, String resourceContainer, long sinceSeconds, String... grepPattern)
      Searches for patterns in the logs of a resource container.
      Parameters:
      resourceType - The type of the resource.
      resourceName - The name of the resource.
      resourceContainer - The name of the resource container.
      sinceSeconds - The duration for the logs (e.g., "5s" for 5 seconds).
      grepPattern - The patterns to search for.
      Returns:
      The search result.
    • getResourceAsJson

      String getResourceAsJson(String resourceType, String resourceName)
      Retrieves the JSON content of a resource.
      Parameters:
      resourceType - The type of the resource.
      resourceName - The name of the resource.
      Returns:
      The JSON content of the resource.
    • listResourcesByLabel

      List<String> listResourcesByLabel(String resourceType, String label)
      Retrieves a list of resources by label.
      Parameters:
      resourceType - The type of the resources.
      label - The label to filter by.
      Returns:
      The list of resources.
    • cmd

      String cmd()
      Retrieves the command associated with the Kubernetes client.
      Returns:
      The command string.
    • process

      K process(Map<String,String> domain, String file, Consumer<String> c)
      Processes a file with specific domain logic.
      Parameters:
      domain - The domain specific parameters.
      file - The file to process.
      c - The consumer to handle processing.
      Returns:
      This kube client.
    • getUsername

      String getUsername()
      Retrieves the username associated with the Kubernetes client.
      Returns:
      The username.