public class Fabric8FlinkKubeClient extends Object implements FlinkKubeClient
FlinkKubeClient.FlinkKubeClient.WatchCallbackHandler<T>| Constructor and Description |
|---|
Fabric8FlinkKubeClient(org.apache.flink.configuration.Configuration flinkConfig,
io.fabric8.kubernetes.client.NamespacedKubernetesClient client,
ExecutorService executorService) |
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<Boolean> |
checkAndUpdateConfigMap(String configMapName,
java.util.function.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(Map<String,String> labels)
Create a shared watcher for ConfigMaps with specified labels.
|
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.
|
CompletableFuture<Void> |
deleteConfigMapsByLabels(Map<String,String> labels)
Delete the Kubernetes ConfigMaps by labels.
|
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> |
getRestService(String clusterId)
Get the kubernetes rest service of the given flink clusterId.
|
KubernetesPod |
loadPodFromTemplateFile(File file)
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.
|
KubernetesWatch |
watchPodsAndDoCallback(Map<String,String> labels,
FlinkKubeClient.WatchCallbackHandler<KubernetesPod> podCallbackHandler)
Watch the pods selected by labels and do the
FlinkKubeClient.WatchCallbackHandler. |
public Fabric8FlinkKubeClient(org.apache.flink.configuration.Configuration flinkConfig,
io.fabric8.kubernetes.client.NamespacedKubernetesClient client,
ExecutorService executorService)
public void createJobManagerComponent(KubernetesJobManagerSpecification kubernetesJMSpec)
FlinkKubeClientcreateJobManagerComponent in interface FlinkKubeClientkubernetesJMSpec - jobmanager specificationpublic CompletableFuture<Void> createTaskManagerPod(KubernetesPod kubernetesPod)
FlinkKubeClientcreateTaskManagerPod in interface FlinkKubeClientkubernetesPod - taskmanager podpublic CompletableFuture<Void> stopPod(String podName)
FlinkKubeClientstopPod in interface FlinkKubeClientpodName - pod namepublic Optional<Endpoint> getRestEndpoint(String clusterId)
FlinkKubeClientgetRestEndpoint in interface FlinkKubeClientclusterId - cluster idpublic List<KubernetesPod> getPodsWithLabels(Map<String,String> labels)
FlinkKubeClientgetPodsWithLabels in interface FlinkKubeClientlabels - labels to filter the podspublic void stopAndCleanupCluster(String clusterId)
FlinkKubeClientstopAndCleanupCluster in interface FlinkKubeClientclusterId - cluster idpublic Optional<KubernetesService> getRestService(String clusterId)
FlinkKubeClientgetRestService in interface FlinkKubeClientclusterId - cluster idpublic KubernetesWatch watchPodsAndDoCallback(Map<String,String> labels, FlinkKubeClient.WatchCallbackHandler<KubernetesPod> podCallbackHandler)
FlinkKubeClientFlinkKubeClient.WatchCallbackHandler.watchPodsAndDoCallback in interface FlinkKubeClientlabels - labels to filter the pods to watchpodCallbackHandler - podCallbackHandler which reacts to pod eventspublic KubernetesLeaderElector createLeaderElector(KubernetesLeaderElectionConfiguration leaderElectionConfiguration, KubernetesLeaderElector.LeaderCallbackHandler leaderCallbackHandler)
FlinkKubeClientcreateLeaderElector in interface FlinkKubeClientleaderElectionConfiguration - election configurationleaderCallbackHandler - Callback when the current instance is leader or not.KubernetesLeaderElector#run.public CompletableFuture<Void> createConfigMap(KubernetesConfigMap configMap)
FlinkKubeClientKubernetesException will be thrown.createConfigMap in interface FlinkKubeClientconfigMap - ConfigMap to be created.public Optional<KubernetesConfigMap> getConfigMap(String name)
FlinkKubeClientgetConfigMap in interface FlinkKubeClientname - name of the ConfigMap to retrieve.public CompletableFuture<Boolean> checkAndUpdateConfigMap(String configMapName, java.util.function.Function<KubernetesConfigMap,Optional<KubernetesConfigMap>> updateFunction)
FlinkKubeClientFlinkKubeClient.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.checkAndUpdateConfigMap in interface FlinkKubeClientconfigMapName - 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.public CompletableFuture<Void> deleteConfigMapsByLabels(Map<String,String> labels)
FlinkKubeClientKubernetesHaServices to clean up all data.deleteConfigMapsByLabels in interface FlinkKubeClientlabels - labels to filter the resources. e.g. type: high-availabilitypublic CompletableFuture<Void> deleteConfigMap(String configMapName)
FlinkKubeClientdeleteConfigMap in interface FlinkKubeClientconfigMapName - ConfigMap namepublic KubernetesConfigMapSharedWatcher createConfigMapSharedWatcher(Map<String,String> labels)
FlinkKubeClientcreateConfigMapSharedWatcher in interface FlinkKubeClientlabels - labels to filter ConfigMaps. If the labels is null or empty, all ConfigMaps
will be taken in account, or it will be rejected if the implementation does not allow it.public void close()
FlinkKubeClientclose in interface AutoCloseableclose in interface FlinkKubeClientpublic KubernetesPod loadPodFromTemplateFile(File file)
FlinkKubeClientloadPodFromTemplateFile in interface FlinkKubeClientfile - The pod template file.Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.