public interface FlinkKubeClient extends AutoCloseable
createTaskManagerPod(KubernetesPod)
, stopPod(String)
should be
implemented asynchronously.Modifier and Type | Interface and Description |
---|---|
static interface |
FlinkKubeClient.WatchCallbackHandler<T>
Callback handler for kubernetes resources.
|
Modifier and Type | Method and Description |
---|---|
CompletableFuture<Boolean> |
checkAndUpdateConfigMap(String configMapName,
Function<KubernetesConfigMap,Optional<KubernetesConfigMap>> updateFunction)
Update an existing ConfigMap with the data.
|
void |
close()
Close the Kubernetes client with no exception.
|
CompletableFuture<Void> |
createConfigMap(KubernetesConfigMap configMap)
Create the ConfigMap with specified content.
|
KubernetesConfigMapSharedWatcher |
createConfigMapSharedWatcher(String name)
Create a shared watcher for ConfigMaps with specified name.
|
void |
createJobManagerComponent(KubernetesJobManagerSpecification kubernetesJMSpec)
Create the Master components, this can include the Deployment, the ConfigMap(s), and the
Service(s).
|
KubernetesLeaderElector |
createLeaderElector(KubernetesLeaderElectionConfiguration leaderElectionConfiguration,
KubernetesLeaderElector.LeaderCallbackHandler leaderCallbackHandler)
Create a leader elector service based on Kubernetes api.
|
CompletableFuture<Void> |
createTaskManagerPod(KubernetesPod kubernetesPod)
Create task manager pod.
|
CompletableFuture<Void> |
deleteConfigMap(String configMapName)
Delete a Kubernetes ConfigMap by name.
|
Optional<KubernetesConfigMap> |
getConfigMap(String name)
Get the ConfigMap with specified name.
|
List<KubernetesPod> |
getPodsWithLabels(Map<String,String> labels)
List the pods with specified labels.
|
Optional<Endpoint> |
getRestEndpoint(String clusterId)
Get the rest endpoint for access outside cluster.
|
Optional<KubernetesService> |
getService(String serviceName)
Get the kubernetes service of the given flink clusterId.
|
KubernetesPod |
loadPodFromTemplateFile(File podTemplateFile)
Load pod from template file.
|
void |
stopAndCleanupCluster(String clusterId)
Stop cluster and clean up all resources, include services, auxiliary services and all running
pods.
|
CompletableFuture<Void> |
stopPod(String podName)
Stop a specified pod by name.
|
CompletableFuture<Void> |
updateServiceTargetPort(String serviceName,
String portName,
int targetPort)
Update the target ports of the given Kubernetes service.
|
CompletableFuture<KubernetesWatch> |
watchPodsAndDoCallback(Map<String,String> labels,
FlinkKubeClient.WatchCallbackHandler<KubernetesPod> podCallbackHandler)
Watch the pods selected by labels and do the
FlinkKubeClient.WatchCallbackHandler . |
void createJobManagerComponent(KubernetesJobManagerSpecification kubernetesJMSpec)
kubernetesJMSpec
- jobmanager specificationCompletableFuture<Void> createTaskManagerPod(KubernetesPod kubernetesPod)
kubernetesPod
- taskmanager podCompletableFuture<Void> stopPod(String podName)
podName
- pod namevoid stopAndCleanupCluster(String clusterId)
clusterId
- cluster idOptional<KubernetesService> getService(String serviceName)
serviceName
- the name of the serviceOptional<Endpoint> getRestEndpoint(String clusterId)
clusterId
- cluster idList<KubernetesPod> getPodsWithLabels(Map<String,String> labels)
labels
- labels to filter the podsCompletableFuture<KubernetesWatch> watchPodsAndDoCallback(Map<String,String> labels, FlinkKubeClient.WatchCallbackHandler<KubernetesPod> podCallbackHandler) throws Exception
FlinkKubeClient.WatchCallbackHandler
.labels
- labels to filter the pods to watchpodCallbackHandler
- podCallbackHandler which reacts to pod eventsException
KubernetesLeaderElector createLeaderElector(KubernetesLeaderElectionConfiguration leaderElectionConfiguration, KubernetesLeaderElector.LeaderCallbackHandler leaderCallbackHandler)
leaderElectionConfiguration
- election configurationleaderCallbackHandler
- Callback when the current instance is leader or not.KubernetesLeaderElector#run
.CompletableFuture<Void> createConfigMap(KubernetesConfigMap configMap)
KubernetesException
will be thrown.configMap
- ConfigMap to be created.Optional<KubernetesConfigMap> getConfigMap(String name)
name
- name of the ConfigMap to retrieve.CompletableFuture<Boolean> checkAndUpdateConfigMap(String configMapName, Function<KubernetesConfigMap,Optional<KubernetesConfigMap>> updateFunction)
getConfigMap(String)
, we could perform a
get-check-and-update transactional operation. Since concurrent modification could happen on a
same ConfigMap, the update operation may fail. We need to retry internally in the
implementation.configMapName
- configMapName specifies the name of the ConfigMap which shall be
updated.updateFunction
- Function to be applied to the obtained ConfigMap and get a new updated
one. If the returned optional is empty, we will not do the update.PossibleInconsistentStateException
indicating that no clear
decision can be made on whether the update was successful or not. The PossibleInconsistentStateException
not being present indicates that the failure happened
before writing the updated ConfigMap to Kubernetes. For the latter case, it can be
assumed that the ConfigMap was not updated.CompletableFuture<Void> deleteConfigMap(String configMapName)
configMapName
- ConfigMap nameKubernetesConfigMapSharedWatcher createConfigMapSharedWatcher(String name)
name
- name of the ConfigMap to watch.void close()
close
in interface AutoCloseable
KubernetesPod loadPodFromTemplateFile(File podTemplateFile)
podTemplateFile
- The pod template file.CompletableFuture<Void> updateServiceTargetPort(String serviceName, String portName, int targetPort)
serviceName
- The name of the service which needs to be updatedportName
- The port name which needs to be updatedtargetPort
- The updated target portCopyright © 2014–2024 The Apache Software Foundation. All rights reserved.