use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class KubernetesJobManagerFactory method createJobManagerDeployment.
private static Deployment createJobManagerDeployment(FlinkPod flinkPod, KubernetesJobManagerParameters kubernetesJobManagerParameters) {
final Container resolvedMainContainer = flinkPod.getMainContainer();
final Pod resolvedPod = new PodBuilder(flinkPod.getPodWithoutMainContainer()).editOrNewSpec().addToContainers(resolvedMainContainer).endSpec().build();
return new DeploymentBuilder().withApiVersion(Constants.APPS_API_VERSION).editOrNewMetadata().withName(KubernetesUtils.getDeploymentName(kubernetesJobManagerParameters.getClusterId())).withAnnotations(kubernetesJobManagerParameters.getAnnotations()).withLabels(kubernetesJobManagerParameters.getLabels()).withOwnerReferences(kubernetesJobManagerParameters.getOwnerReference().stream().map(e -> KubernetesOwnerReference.fromMap(e).getInternalResource()).collect(Collectors.toList())).endMetadata().editOrNewSpec().withReplicas(kubernetesJobManagerParameters.getReplicas()).editOrNewTemplate().withMetadata(resolvedPod.getMetadata()).withSpec(resolvedPod.getSpec()).endTemplate().editOrNewSelector().addToMatchLabels(kubernetesJobManagerParameters.getSelectors()).endSelector().endSpec().build();
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class InitTaskManagerDecoratorAccountTest method onSetup.
@Override
protected void onSetup() throws Exception {
super.onSetup();
final InitTaskManagerDecorator initTaskManagerDecorator = new InitTaskManagerDecorator(kubernetesTaskManagerParameters);
final FlinkPod resultFlinkPod = initTaskManagerDecorator.decorateFlinkPod(this.baseFlinkPod);
this.resultPod = resultFlinkPod.getPodWithoutMainContainer();
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class PodTemplateMountDecoratorTest method testDecoratedFlinkPodWithTaskManagerPodTemplate.
@Test
public void testDecoratedFlinkPodWithTaskManagerPodTemplate() throws Exception {
KubernetesTestUtils.createTemporyFile(POD_TEMPLATE_DATA, flinkConfDir, POD_TEMPLATE_FILE_NAME);
final FlinkPod resultFlinkPod = podTemplateMountDecorator.decorateFlinkPod(baseFlinkPod);
final List<KeyToPath> expectedKeyToPaths = Collections.singletonList(new KeyToPathBuilder().withKey(TASK_MANAGER_POD_TEMPLATE_FILE_NAME).withPath(TASK_MANAGER_POD_TEMPLATE_FILE_NAME).build());
final List<Volume> expectedVolumes = getExpectedVolumes(expectedKeyToPaths);
assertThat(resultFlinkPod.getPodWithoutMainContainer().getSpec().getVolumes(), containsInAnyOrder(expectedVolumes.toArray()));
final List<VolumeMount> expectedVolumeMounts = Collections.singletonList(new VolumeMountBuilder().withName(Constants.POD_TEMPLATE_VOLUME).withMountPath(Constants.POD_TEMPLATE_DIR_IN_POD).build());
assertThat(resultFlinkPod.getMainContainer().getVolumeMounts(), containsInAnyOrder(expectedVolumeMounts.toArray()));
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class KubernetesJobManagerFactoryTest method testKerberosKeytabSecret.
@Test
public void testKerberosKeytabSecret() throws IOException {
kubernetesJobManagerSpecification = KubernetesJobManagerFactory.buildKubernetesJobManagerSpecification(flinkPod, kubernetesJobManagerParameters);
final Secret resultSecret = (Secret) this.kubernetesJobManagerSpecification.getAccompanyingResources().stream().filter(x -> x instanceof Secret && x.getMetadata().getName().equals(KerberosMountDecorator.getKerberosKeytabSecretName(CLUSTER_ID))).collect(Collectors.toList()).get(0);
final Map<String, String> resultDatas = resultSecret.getData();
assertEquals(1, resultDatas.size());
assertEquals(Base64.getEncoder().encodeToString("some keytab".getBytes()), resultDatas.get(KEYTAB_FILE));
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class KubernetesJobManagerFactoryTest method testKerberosConfConfigMap.
@Test
public void testKerberosConfConfigMap() throws IOException {
kubernetesJobManagerSpecification = KubernetesJobManagerFactory.buildKubernetesJobManagerSpecification(flinkPod, kubernetesJobManagerParameters);
final ConfigMap resultConfigMap = (ConfigMap) this.kubernetesJobManagerSpecification.getAccompanyingResources().stream().filter(x -> x instanceof ConfigMap && x.getMetadata().getName().equals(KerberosMountDecorator.getKerberosKrb5confConfigMapName(CLUSTER_ID))).collect(Collectors.toList()).get(0);
assertEquals(Constants.API_VERSION, resultConfigMap.getApiVersion());
assertEquals(KerberosMountDecorator.getKerberosKrb5confConfigMapName(CLUSTER_ID), resultConfigMap.getMetadata().getName());
final Map<String, String> resultDatas = resultConfigMap.getData();
assertEquals(1, resultDatas.size());
assertEquals("some conf", resultDatas.get(KRB5_CONF_FILE));
}
Aggregations