Class KubernetesAssistant
java.lang.Object
org.arquillian.cube.kubernetes.impl.KubernetesAssistant
Class that allows you to deploy undeploy and wait for resources programmatically in a test.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionKubernetesAssistant(io.fabric8.kubernetes.client.KubernetesClient client, String namespace) -
Method Summary
Modifier and TypeMethodDescriptionvoidAwaits at most 5 minutes until all pods of the last deployed application are running.voidawaitApplicationReadinessOrFail(String applicationName) Awaits at most 5 minutes until all pods of the application are running.voidawaitPodReadinessOrFail(Predicate<io.fabric8.kubernetes.api.model.Pod> filter) Awaits at most 5 minutes until all pods meets the given predicate.voidcleanup()Removes all resources deployed using this class.voiddeploy(InputStream inputStream) Deploys application reading resources from specified InputStreamprotected List<? extends io.fabric8.kubernetes.api.model.HasMetadata>deploy(String name, InputStream element) Deploys application reading resources from classpath, matching the given regular expression.voidDeploys application reading resources from classpath, matching the given regular expression.voidDeploys all y(a)ml and json files located at given directory.Deploys all y(a)ml and json files located at given directory.Deploys application finding resources in default location in classpath.voiddeployApplication(String applicationName) Deploys application finding resources in default location in classpath.voiddeployApplication(String applicationName, String... classpathLocations) Deploys application reading resources from specified classpath locationvoiddeployApplication(String applicationName, URL... urls) Deploys application reading resources from specified URLsdeployApplication(URL... urls) Deploys application reading resources from specified URLsprotected List<io.fabric8.kubernetes.api.model.Pod>Gets the URL of the first service that have been created during the current session.getServiceUrl(String name) Gets the URL of the service with the given name that has been created during the current session.project()io.fabric8.kubernetes.api.model.ReplicationControllerMethod that returns the current replication controller objectvoidscale(int replicas) Scaling the last deployed application to given replicasvoidScaling the application to given replicas
-
Field Details
-
client
protected io.fabric8.kubernetes.client.KubernetesClient client -
namespace
-
applicationName
-
-
Constructor Details
-
KubernetesAssistant
-
-
Method Details
-
deployApplication
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
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 clusterclasspathLocations- where resources are read- Throws:
IOException
-
deployApplication
Deploys application reading resources from specified URLs- Parameters:
urls- where resources are read- Returns:
- the name of the application
- Throws:
IOException
-
deployApplication
Deploys application reading resources from specified URLs- Parameters:
applicationName- to configure in clusterurls- where resources are read- Throws:
IOException
-
deployAll
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 clusterpattern- to match the resources.
-
deployAll
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
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
Deploys all y(a)ml and json files located at given directory.- Parameters:
applicationName- to configure in clusterdirectory- where resources files are stored- Throws:
IOException
-
deploy
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
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
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
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
-
awaitPodReadinessOrFail
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
Scaling the application to given replicas- Parameters:
applicationName- name of the application to scalereplicas- to scale the application
-
getPods
-
replicationController
public io.fabric8.kubernetes.api.model.ReplicationController replicationController()Method that returns the current replication controller object- Returns:
- Current replication controller object.
-