Package io.github.pod4dev.java.service
Class KubePlayer
java.lang.Object
io.github.pod4dev.java.service.KubePlayer
- All Implemented Interfaces:
GenericContainer,AutoCloseable
Work with /kube/play API.
-
Constructor Summary
ConstructorsConstructorDescriptionKubePlayer(String yamlPath) Creates player with specified path for k8s YAML specification. -
Method Summary
Modifier and TypeMethodDescriptionGet API client.getMappedPort(String serviceName, Integer exposedPort) Getting mapped port for the given service's name and exposed port.booleanCheck if service is running.voidstart()Creates the pod or container and immediately starts it.voidstop()Stops the pod or container with clearing created volumes.withCleanup(boolean doCleanup) Do resources cleanup after stopping.withExposedService(String serviceName, Integer exposedPort) Specify service and its port for expose.withRemoveVolumes(boolean doRemoveVolumes) Do volumes cleanup after stopping.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.pod4dev.java.core.GenericContainer
close, getMappedHost
-
Constructor Details
-
KubePlayer
Creates player with specified path for k8s YAML specification. The socket path is autodetected viaPODMAN_HOSTenvironment variable.- Parameters:
yamlPath- path to k8s YAML specification.- Throws:
PodmanException- ifyamlPathis empty or error during initialization is happened.
-
-
Method Details
-
getClient
Description copied from interface:GenericContainerGet API client.- Specified by:
getClientin interfaceGenericContainer- Returns:
- API client.
-
isRunning
public boolean isRunning()Description copied from interface:GenericContainerCheck if service is running.- Specified by:
isRunningin interfaceGenericContainer- Returns:
- check result.
-
withExposedService
public KubePlayer withExposedService(String serviceName, Integer exposedPort) throws PodmanException Description copied from interface:GenericContainerSpecify service and its port for expose.- Specified by:
withExposedServicein interfaceGenericContainer- Parameters:
serviceName- name of service to expose.exposedPort- port to expose.- Returns:
- container with exposed services.
- Throws:
PodmanException
-
withCleanup
Description copied from interface:GenericContainerDo resources cleanup after stopping.- Specified by:
withCleanupin interfaceGenericContainer- Parameters:
doCleanup- default is true.- Returns:
- customised container.
-
withRemoveVolumes
Description copied from interface:GenericContainerDo volumes cleanup after stopping.- Specified by:
withRemoveVolumesin interfaceGenericContainer- Parameters:
doRemoveVolumes- default is true.- Returns:
- customised container.
-
start
Description copied from interface:GenericContainerCreates the pod or container and immediately starts it. All created resources will be cleared out when a SIGTERM is received or pods exit.- Specified by:
startin interfaceGenericContainer- Throws:
PodmanException
-
stop
Description copied from interface:GenericContainerStops the pod or container with clearing created volumes.- Specified by:
stopin interfaceGenericContainer- Throws:
PodmanException
-
getMappedPort
Description copied from interface:GenericContainerGetting mapped port for the given service's name and exposed port.- Specified by:
getMappedPortin interfaceGenericContainer- Parameters:
serviceName- the service name.exposedPort- the exposed port.- Returns:
- mapped host.
- Throws:
PodmanException
-