use of io.fabric8.kubernetes.api.model.OwnerReference in project flink by apache.
the class Fabric8FlinkKubeClient method createTaskManagerPod.
@Override
public CompletableFuture<Void> createTaskManagerPod(KubernetesPod kubernetesPod) {
return CompletableFuture.runAsync(() -> {
final Deployment masterDeployment = this.internalClient.apps().deployments().withName(KubernetesUtils.getDeploymentName(clusterId)).get();
if (masterDeployment == null) {
throw new RuntimeException("Failed to find Deployment named " + clusterId + " in namespace " + this.namespace);
}
// Note that we should use the uid of the master Deployment for the
// OwnerReference.
setOwnerReference(masterDeployment, Collections.singletonList(kubernetesPod.getInternalResource()));
LOG.debug("Start to create pod with spec {}{}", System.lineSeparator(), KubernetesUtils.tryToGetPrettyPrintYaml(kubernetesPod.getInternalResource()));
this.internalClient.pods().create(kubernetesPod.getInternalResource());
}, kubeClientExecutorService);
}
use of io.fabric8.kubernetes.api.model.OwnerReference in project flink by apache.
the class Fabric8FlinkKubeClient method setOwnerReference.
private void setOwnerReference(Deployment deployment, List<HasMetadata> resources) {
final OwnerReference deploymentOwnerReference = new OwnerReferenceBuilder().withName(deployment.getMetadata().getName()).withApiVersion(deployment.getApiVersion()).withUid(deployment.getMetadata().getUid()).withKind(deployment.getKind()).withController(true).withBlockOwnerDeletion(true).build();
resources.forEach(resource -> resource.getMetadata().setOwnerReferences(Collections.singletonList(deploymentOwnerReference)));
}
use of io.fabric8.kubernetes.api.model.OwnerReference in project flink by apache.
the class Fabric8FlinkKubeClient method createJobManagerComponent.
@Override
public void createJobManagerComponent(KubernetesJobManagerSpecification kubernetesJMSpec) {
final Deployment deployment = kubernetesJMSpec.getDeployment();
final List<HasMetadata> accompanyingResources = kubernetesJMSpec.getAccompanyingResources();
// create Deployment
LOG.debug("Start to create deployment with spec {}{}", System.lineSeparator(), KubernetesUtils.tryToGetPrettyPrintYaml(deployment));
final Deployment createdDeployment = this.internalClient.apps().deployments().create(deployment);
// Note that we should use the uid of the created Deployment for the OwnerReference.
setOwnerReference(createdDeployment, accompanyingResources);
this.internalClient.resourceList(accompanyingResources).createOrReplace();
}
Aggregations