use of org.apache.flink.kubernetes.kubeclient.resources.KubernetesPod in project flink by apache.
the class KubernetesTaskManagerFactory method buildTaskManagerKubernetesPod.
public static KubernetesPod buildTaskManagerKubernetesPod(FlinkPod podTemplate, KubernetesTaskManagerParameters kubernetesTaskManagerParameters) {
FlinkPod flinkPod = Preconditions.checkNotNull(podTemplate).copy();
final KubernetesStepDecorator[] stepDecorators = new KubernetesStepDecorator[] { new InitTaskManagerDecorator(kubernetesTaskManagerParameters), new EnvSecretsDecorator(kubernetesTaskManagerParameters), new MountSecretsDecorator(kubernetesTaskManagerParameters), new CmdTaskManagerDecorator(kubernetesTaskManagerParameters), new HadoopConfMountDecorator(kubernetesTaskManagerParameters), new KerberosMountDecorator(kubernetesTaskManagerParameters), new FlinkConfMountDecorator(kubernetesTaskManagerParameters) };
for (KubernetesStepDecorator stepDecorator : stepDecorators) {
flinkPod = stepDecorator.decorateFlinkPod(flinkPod);
}
final Pod resolvedPod = new PodBuilder(flinkPod.getPodWithoutMainContainer()).editOrNewSpec().addToContainers(flinkPod.getMainContainer()).endSpec().build();
return new KubernetesPod(resolvedPod);
}
use of org.apache.flink.kubernetes.kubeclient.resources.KubernetesPod in project flink by apache.
the class KubernetesUtils method loadPodFromTemplateFile.
public static FlinkPod loadPodFromTemplateFile(FlinkKubeClient kubeClient, File podTemplateFile, String mainContainerName) {
final KubernetesPod pod = kubeClient.loadPodFromTemplateFile(podTemplateFile);
final List<Container> otherContainers = new ArrayList<>();
Container mainContainer = null;
for (Container container : pod.getInternalResource().getSpec().getContainers()) {
if (mainContainerName.equals(container.getName())) {
mainContainer = container;
} else {
otherContainers.add(container);
}
}
if (mainContainer == null) {
LOG.info("Could not find main container {} in pod template, using empty one to initialize.", mainContainerName);
mainContainer = new ContainerBuilder().build();
}
pod.getInternalResource().getSpec().setContainers(otherContainers);
return new FlinkPod(pod.getInternalResource(), mainContainer);
}
use of org.apache.flink.kubernetes.kubeclient.resources.KubernetesPod in project flink by apache.
the class Fabric8FlinkKubeClientTest method testCreateFlinkTaskManagerPod.
@Test
public void testCreateFlinkTaskManagerPod() throws Exception {
this.flinkKubeClient.createJobManagerComponent(this.kubernetesJobManagerSpecification);
final KubernetesPod kubernetesPod = new KubernetesPod(new PodBuilder().editOrNewMetadata().withName("mock-task-manager-pod").endMetadata().editOrNewSpec().endSpec().build());
this.flinkKubeClient.createTaskManagerPod(kubernetesPod).get();
final Pod resultTaskManagerPod = this.kubeClient.pods().inNamespace(NAMESPACE).withName(TASKMANAGER_POD_NAME).get();
assertEquals(this.kubeClient.apps().deployments().inNamespace(NAMESPACE).list().getItems().get(0).getMetadata().getUid(), resultTaskManagerPod.getMetadata().getOwnerReferences().get(0).getUid());
}
Aggregations