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 Summary
Modifier and TypeMethodDescriptionApplies resource changes from the provided files.default KApplies resource changes from YAML files specified by file paths.applyContent(String yamlContent) Applies resource content.cmd()Retrieves the command associated with the Kubernetes client.Creates resources from the provided files.default KCreates resources from YAML files specified by file paths.createNamespace(String name) Creates a namespace with the given name.voidcreateResourceAndApply(String template, Map<String, String> params) Creates a resource from a template and applies it.Retrieves the default OLM (Operator Lifecycle Manager) namespace for the Kubernetes client.Deletes resources specified in the provided files.default KDeletes resources specified in YAML files specified by file paths.deleteByName(String resourceType, String resourceName) Deletes resources by resource name.deleteContent(String yamlContent) Deletes resource content.deleteNamespace(String name) Deletes the namespace with the given name.Retrieves a description of a resource.Execute the givencommand.Executes a command with control over throwing exceptions on failure and logging to output control.Executes a command with control over throwing exceptions on failure.Executes a command.Executes a command within a pod.execInPodContainer(boolean logToOutput, String pod, String container, String... command) Executes a command within a pod container with logging to output control.execInPodContainer(String pod, String container, String... command) Executes a command within a pod container.Retrieves the YAML content of a resource.Retrieves the currently set namespace for the Kubernetes client.Retrieves a list of events within the current namespace.getResourceAsJson(String resourceType, String resourceName) Retrieves the JSON content of a resource.getResourceAsYaml(String resourceType, String resourceName) Retrieves the YAML content of a resource by type and name.getResourcesAsYaml(String resourceType) Retrieves the YAML content of resources by type.Retrieves the username associated with the Kubernetes client.inNamespace(String namespace) Sets the namespace for subsequent operations.Retrieves a list of resources by type.listResourcesByLabel(String resourceType, String label) Retrieves a list of resources by label.default StringRetrieves logs for a pod.Retrieves logs for a pod container.Processes a file with specific domain logic.Replaces resources with the contents of the provided files.scaleByName(String kind, String name, int replicas) Scales a resource by its kind and name.searchInLog(String resourceType, String resourceName, long sinceSeconds, String... grepPattern) Searches for patterns in the logs of a resource.searchInLog(String resourceType, String resourceName, String resourceContainer, long sinceSeconds, String... grepPattern) Searches for patterns in the logs of a resource container.
-
Method Details
-
defaultOlmNamespace
String defaultOlmNamespace()Retrieves the default OLM (Operator Lifecycle Manager) namespace for the Kubernetes client.- Returns:
- The default OLM namespace.
-
deleteByName
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
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
Creates resources from the provided files.- Parameters:
files- The files containing resource definitions.- Returns:
- This kube client.
-
apply
Applies resource changes from the provided files.- Parameters:
files- The files containing resource changes.- Returns:
- This kube client.
-
delete
Deletes resources specified in the provided files.- Parameters:
files- The files containing resources to delete.- Returns:
- This kube client.
-
create
Creates resources from YAML files specified by file paths.- Parameters:
files- The paths to YAML files containing resource definitions.- Returns:
- This kube client.
-
apply
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
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
Replaces resources with the contents of the provided files.- Parameters:
files- The files containing resources to replace.- Returns:
- This kube client.
-
applyContent
Applies resource content.- Parameters:
yamlContent- The YAML content representing the resources.- Returns:
- This kube client.
-
deleteContent
Deletes resource content.- Parameters:
yamlContent- The YAML content representing the resources to delete.- Returns:
- This kube client.
-
createNamespace
Creates a namespace with the given name.- Parameters:
name- The name of the namespace to create.- Returns:
- This kube client.
-
deleteNamespace
Deletes the namespace with the given name.- Parameters:
name- The name of the namespace to delete.- Returns:
- This kube client.
-
scaleByName
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
Executes a command within a pod.- Parameters:
pod- The name of the pod.command- The command to execute.- Returns:
- The execution result.
-
execInPodContainer
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
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
Executes a command.- Parameters:
command- The command to execute.- Returns:
- The execution result.
-
exec
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
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
Execute the givencommand. You can specify if potential failure will thrown the exception or not.- Parameters:
throwError- parameter which control thrown exception in case of failurecommand- The commandtimeout- tiemout in mslogToOutput- determines if we want to print whole output of command- Returns:
- The process result.
-
get
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
Retrieves a list of resources by type.- Parameters:
resourceType- The type of the resources.- Returns:
- The list of resources.
-
getResourceAsYaml
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
Retrieves the YAML content of resources by type.- Parameters:
resourceType- The type of the resources.- Returns:
- The YAML content of the resources.
-
createResourceAndApply
Creates a resource from a template and applies it.- Parameters:
template- The template for the resource.params- The parameters for the template.
-
describe
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
Retrieves logs for a pod.- Parameters:
pod- The name of the pod.- Returns:
- The logs for the pod.
-
logs
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
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
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
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.
-