Search in sources :

Example 6 with KubernetesPod

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);
}
Also used : KubernetesStepDecorator(org.apache.flink.kubernetes.kubeclient.decorators.KubernetesStepDecorator) EnvSecretsDecorator(org.apache.flink.kubernetes.kubeclient.decorators.EnvSecretsDecorator) Pod(io.fabric8.kubernetes.api.model.Pod) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) KubernetesPod(org.apache.flink.kubernetes.kubeclient.resources.KubernetesPod) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) InitTaskManagerDecorator(org.apache.flink.kubernetes.kubeclient.decorators.InitTaskManagerDecorator) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) CmdTaskManagerDecorator(org.apache.flink.kubernetes.kubeclient.decorators.CmdTaskManagerDecorator) FlinkConfMountDecorator(org.apache.flink.kubernetes.kubeclient.decorators.FlinkConfMountDecorator) HadoopConfMountDecorator(org.apache.flink.kubernetes.kubeclient.decorators.HadoopConfMountDecorator) KerberosMountDecorator(org.apache.flink.kubernetes.kubeclient.decorators.KerberosMountDecorator) MountSecretsDecorator(org.apache.flink.kubernetes.kubeclient.decorators.MountSecretsDecorator) KubernetesPod(org.apache.flink.kubernetes.kubeclient.resources.KubernetesPod)

Example 7 with KubernetesPod

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);
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) ArrayList(java.util.ArrayList) KubernetesPod(org.apache.flink.kubernetes.kubeclient.resources.KubernetesPod)

Example 8 with KubernetesPod

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());
}
Also used : KubernetesPod(org.apache.flink.kubernetes.kubeclient.resources.KubernetesPod) Pod(io.fabric8.kubernetes.api.model.Pod) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) KubernetesPod(org.apache.flink.kubernetes.kubeclient.resources.KubernetesPod) Test(org.junit.Test)

Aggregations

KubernetesPod (org.apache.flink.kubernetes.kubeclient.resources.KubernetesPod)8 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 FlinkPod (org.apache.flink.kubernetes.kubeclient.FlinkPod)3 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)3 Pod (io.fabric8.kubernetes.api.model.Pod)2 List (java.util.List)2 TaskManagerOptions (org.apache.flink.configuration.TaskManagerOptions)2 KubernetesConfigOptions (org.apache.flink.kubernetes.configuration.KubernetesConfigOptions)2 KubernetesResourceManagerDriverConfiguration (org.apache.flink.kubernetes.configuration.KubernetesResourceManagerDriverConfiguration)2 FlinkKubeClient (org.apache.flink.kubernetes.kubeclient.FlinkKubeClient)2 KubernetesTooOldResourceVersionException (org.apache.flink.kubernetes.kubeclient.resources.KubernetesTooOldResourceVersionException)2 TestingKubernetesPod (org.apache.flink.kubernetes.kubeclient.resources.TestingKubernetesPod)2 Constants (org.apache.flink.kubernetes.utils.Constants)2 TaskExecutorProcessSpec (org.apache.flink.runtime.clusterframework.TaskExecutorProcessSpec)2 ResourceManagerDriver (org.apache.flink.runtime.resourcemanager.active.ResourceManagerDriver)2 Container (io.fabric8.kubernetes.api.model.Container)1 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)1