Class KubeClient

java.lang.Object
io.skodjob.testframe.clients.KubeClient

public class KubeClient extends Object
Provides functionality to interact with Kubernetes and OpenShift clusters. This includes creating clients, reading resources from files, and managing kubeconfig for authentication.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initializes the Kubernetes client with configuration derived from environment variables or default context.
  • Method Summary

    Modifier and Type
    Method
    Description
    io.fabric8.kubernetes.client.KubernetesClient
    Returns the Kubernetes client.
    Returns the path to the kubeconfig file used for authentication.
    io.fabric8.openshift.client.OpenShiftClient
    Adapts the Kubernetes client to an OpenShift client.
    List<io.fabric8.kubernetes.api.model.HasMetadata>
    Reads Kubernetes resources from an InputStream.
    List<io.fabric8.kubernetes.api.model.HasMetadata>
    Reads Kubernetes resources from a file at the specified path.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • KubeClient

      public KubeClient()
      Initializes the Kubernetes client with configuration derived from environment variables or default context.
  • Method Details

    • getClient

      public io.fabric8.kubernetes.client.KubernetesClient getClient()
      Returns the Kubernetes client.
      Returns:
      The initialized Kubernetes client.
    • getOpenShiftClient

      public io.fabric8.openshift.client.OpenShiftClient getOpenShiftClient()
      Adapts the Kubernetes client to an OpenShift client.
      Returns:
      An instance of OpenShiftClient.
    • getKubeconfigPath

      public String getKubeconfigPath()
      Returns the path to the kubeconfig file used for authentication.
      Returns:
      The kubeconfig file path.
    • readResourcesFromFile

      public List<io.fabric8.kubernetes.api.model.HasMetadata> readResourcesFromFile(Path file) throws IOException
      Reads Kubernetes resources from a file at the specified path.
      Parameters:
      file - The path to the file containing Kubernetes resources.
      Returns:
      A list of HasMetadata resources defined in the file.
      Throws:
      IOException - If an I/O error occurs reading from the file.
    • readResourcesFromFile

      public List<io.fabric8.kubernetes.api.model.HasMetadata> readResourcesFromFile(InputStream is) throws IOException
      Reads Kubernetes resources from an InputStream.
      Parameters:
      is - The InputStream containing Kubernetes resources.
      Returns:
      A list of HasMetadata resources defined in the stream.
      Throws:
      IOException - If an I/O error occurs.