use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class KubernetesUtilsTest method testLoadPodFromTemplateAndCheckVolumes.
@Test
public void testLoadPodFromTemplateAndCheckVolumes() {
final FlinkPod flinkPod = KubernetesUtils.loadPodFromTemplateFile(flinkKubeClient, KubernetesPodTemplateTestUtils.getPodTemplateFile(), KubernetesPodTemplateTestUtils.TESTING_MAIN_CONTAINER_NAME);
assertThat(flinkPod.getPodWithoutMainContainer().getSpec().getVolumes(), containsInAnyOrder(KubernetesPodTemplateTestUtils.createVolumes()));
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class KubernetesUtilsTest method testLoadPodFromTemplateAndCheckSideCarContainer.
@Test
public void testLoadPodFromTemplateAndCheckSideCarContainer() {
final FlinkPod flinkPod = KubernetesUtils.loadPodFromTemplateFile(flinkKubeClient, KubernetesPodTemplateTestUtils.getPodTemplateFile(), KubernetesPodTemplateTestUtils.TESTING_MAIN_CONTAINER_NAME);
assertThat(flinkPod.getPodWithoutMainContainer().getSpec().getContainers().size(), is(1));
assertThat(flinkPod.getPodWithoutMainContainer().getSpec().getContainers().get(0), is(KubernetesPodTemplateTestUtils.createSideCarContainer()));
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class KubernetesUtilsTest method testLoadPodFromTemplateAndCheckMainContainer.
@Test
public void testLoadPodFromTemplateAndCheckMainContainer() {
final FlinkPod flinkPod = KubernetesUtils.loadPodFromTemplateFile(flinkKubeClient, KubernetesPodTemplateTestUtils.getPodTemplateFile(), KubernetesPodTemplateTestUtils.TESTING_MAIN_CONTAINER_NAME);
assertThat(flinkPod.getMainContainer().getName(), is(KubernetesPodTemplateTestUtils.TESTING_MAIN_CONTAINER_NAME));
assertThat(flinkPod.getMainContainer().getVolumeMounts(), containsInAnyOrder(KubernetesPodTemplateTestUtils.createVolumeMount()));
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class FlinkConfMountDecorator method decorateFlinkPod.
@Override
public FlinkPod decorateFlinkPod(FlinkPod flinkPod) {
final Pod mountedPod = decoratePod(flinkPod.getPodWithoutMainContainer());
final Container mountedMainContainer = new ContainerBuilder(flinkPod.getMainContainer()).addNewVolumeMount().withName(FLINK_CONF_VOLUME).withMountPath(kubernetesComponentConf.getFlinkConfDirInPod()).endVolumeMount().build();
return new FlinkPod.Builder(flinkPod).withPod(mountedPod).withMainContainer(mountedMainContainer).build();
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class InitJobManagerDecorator method decorateFlinkPod.
@Override
public FlinkPod decorateFlinkPod(FlinkPod flinkPod) {
final PodBuilder basicPodBuilder = new PodBuilder(flinkPod.getPodWithoutMainContainer());
// Overwrite fields
final String serviceAccountName = KubernetesUtils.resolveUserDefinedValue(flinkConfig, KubernetesConfigOptions.JOB_MANAGER_SERVICE_ACCOUNT, kubernetesJobManagerParameters.getServiceAccount(), KubernetesUtils.getServiceAccount(flinkPod), "service account");
if (flinkPod.getPodWithoutMainContainer().getSpec().getRestartPolicy() != null) {
logger.info("The restart policy of JobManager pod will be overwritten to 'always' " + "since it is controlled by the Kubernetes deployment.");
}
basicPodBuilder.withApiVersion(API_VERSION).editOrNewSpec().withServiceAccount(serviceAccountName).withServiceAccountName(serviceAccountName).withHostNetwork(kubernetesJobManagerParameters.isHostNetworkEnabled()).withDnsPolicy(kubernetesJobManagerParameters.isHostNetworkEnabled() ? DNS_PLOICY_HOSTNETWORK : DNS_PLOICY_DEFAULT).endSpec();
// Merge fields
basicPodBuilder.editOrNewMetadata().addToLabels(kubernetesJobManagerParameters.getLabels()).addToAnnotations(kubernetesJobManagerParameters.getAnnotations()).endMetadata().editOrNewSpec().addToImagePullSecrets(kubernetesJobManagerParameters.getImagePullSecrets()).addToNodeSelector(kubernetesJobManagerParameters.getNodeSelector()).addAllToTolerations(kubernetesJobManagerParameters.getTolerations().stream().map(e -> KubernetesToleration.fromMap(e).getInternalResource()).collect(Collectors.toList())).endSpec();
final Container basicMainContainer = decorateMainContainer(flinkPod.getMainContainer());
return new FlinkPod.Builder(flinkPod).withPod(basicPodBuilder.build()).withMainContainer(basicMainContainer).build();
}
Aggregations