Class KubernetesAssistant

java.lang.Object
org.arquillian.cube.kubernetes.impl.KubernetesAssistant

public class KubernetesAssistant extends Object
Class that allows you to deploy undeploy and wait for resources programmatically in a test.
  • Field Details

    • client

      protected io.fabric8.kubernetes.client.KubernetesClient client
    • namespace

      protected String namespace
    • applicationName

      protected String applicationName
  • Constructor Details

    • KubernetesAssistant

      public KubernetesAssistant(io.fabric8.kubernetes.client.KubernetesClient client, String namespace)
  • Method Details

    • deployApplication

      public String deployApplication() throws IOException
      Deploys application finding resources in default location in classpath. That is: kubernetes.(y[a]ml|json), META-INF/fabric8/kubernetes.(y[a]ml|json)
      Returns:
      the name of the application defined in the Deployment.
      Throws:
      IOException
    • deployApplication

      public void deployApplication(String applicationName) throws IOException
      Deploys application finding resources in default location in classpath. That is: kubernetes.(y[a]ml|json), META-INF/fabric8/kubernetes.(y[a]ml|json)

      In this method you specify the application name.

      Parameters:
      applicationName - to configure in cluster
      Throws:
      IOException
    • deployApplication

      public void deployApplication(String applicationName, String... classpathLocations) throws IOException
      Deploys application reading resources from specified classpath location
      Parameters:
      applicationName - to configure in cluster
      classpathLocations - where resources are read
      Throws:
      IOException
    • deployApplication

      public String deployApplication(URL... urls) throws IOException
      Deploys application reading resources from specified URLs
      Parameters:
      urls - where resources are read
      Returns:
      the name of the application
      Throws:
      IOException
    • deployApplication

      public void deployApplication(String applicationName, URL... urls) throws IOException
      Deploys application reading resources from specified URLs
      Parameters:
      applicationName - to configure in cluster
      urls - where resources are read
      Throws:
      IOException
    • deployAll

      public void deployAll(String applicationName, String pattern)
      Deploys application reading resources from classpath, matching the given regular expression. For example kubernetes/.*\\.json will deploy all resources ending with json placed at kubernetes classpath directory.
      Parameters:
      applicationName - to configure the cluster
      pattern - to match the resources.
    • deployAll

      public String deployAll(String pattern)
      Deploys application reading resources from classpath, matching the given regular expression. For example kubernetes/.*\\.json will deploy all resources ending with json placed at kubernetes classpath directory.
      Parameters:
      pattern - to match the resources.
    • deployAll

      public String deployAll(Path directory) throws IOException
      Deploys all y(a)ml and json files located at given directory.
      Parameters:
      directory - where resource files are stored
      Returns:
      the name of the application
      Throws:
      IOException
    • deployAll

      public void deployAll(String applicationName, Path directory) throws IOException
      Deploys all y(a)ml and json files located at given directory.
      Parameters:
      applicationName - to configure in cluster
      directory - where resources files are stored
      Throws:
      IOException
    • deploy

      public void deploy(InputStream inputStream) throws IOException
      Deploys application reading resources from specified InputStream
      Parameters:
      inputStream - where resources are read
      Throws:
      IOException
    • deploy

      protected List<? extends io.fabric8.kubernetes.api.model.HasMetadata> deploy(String name, InputStream element)
    • getServiceUrl

      public Optional<URL> getServiceUrl(String name)
      Gets the URL of the service with the given name that has been created during the current session.
      Parameters:
      name - to return its URL
      Returns:
      URL of the service.
    • getServiceUrl

      public Optional<URL> getServiceUrl()
      Gets the URL of the first service that have been created during the current session.
      Returns:
      URL of the first service.
    • cleanup

      public void cleanup()
      Removes all resources deployed using this class.
    • awaitApplicationReadinessOrFail

      public void awaitApplicationReadinessOrFail()
      Awaits at most 5 minutes until all pods of the last deployed application are running.
    • awaitApplicationReadinessOrFail

      public void awaitApplicationReadinessOrFail(String applicationName)
      Awaits at most 5 minutes until all pods of the application are running.
      Parameters:
      applicationName - name of the application to wait for pods readiness
    • project

      public String project()
    • awaitPodReadinessOrFail

      public void awaitPodReadinessOrFail(Predicate<io.fabric8.kubernetes.api.model.Pod> filter)
      Awaits at most 5 minutes until all pods meets the given predicate.
      Parameters:
      filter - used to wait to detect that a pod is up and running.
    • scale

      public void scale(int replicas)
      Scaling the last deployed application to given replicas
      Parameters:
      replicas - to scale the application
    • scale

      public void scale(String applicationName, int replicas)
      Scaling the application to given replicas
      Parameters:
      applicationName - name of the application to scale
      replicas - to scale the application
    • getPods

      protected List<io.fabric8.kubernetes.api.model.Pod> getPods(String label)
    • replicationController

      public io.fabric8.kubernetes.api.model.ReplicationController replicationController()
      Method that returns the current replication controller object
      Returns:
      Current replication controller object.