use of org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerSpecification in project flink by apache.
the class KubernetesJobManagerFactory method buildKubernetesJobManagerSpecification.
public static KubernetesJobManagerSpecification buildKubernetesJobManagerSpecification(FlinkPod podTemplate, KubernetesJobManagerParameters kubernetesJobManagerParameters) throws IOException {
FlinkPod flinkPod = Preconditions.checkNotNull(podTemplate).copy();
List<HasMetadata> accompanyingResources = new ArrayList<>();
final KubernetesStepDecorator[] stepDecorators = new KubernetesStepDecorator[] { new InitJobManagerDecorator(kubernetesJobManagerParameters), new EnvSecretsDecorator(kubernetesJobManagerParameters), new MountSecretsDecorator(kubernetesJobManagerParameters), new CmdJobManagerDecorator(kubernetesJobManagerParameters), new InternalServiceDecorator(kubernetesJobManagerParameters), new ExternalServiceDecorator(kubernetesJobManagerParameters), new HadoopConfMountDecorator(kubernetesJobManagerParameters), new KerberosMountDecorator(kubernetesJobManagerParameters), new FlinkConfMountDecorator(kubernetesJobManagerParameters), new PodTemplateMountDecorator(kubernetesJobManagerParameters) };
for (KubernetesStepDecorator stepDecorator : stepDecorators) {
flinkPod = stepDecorator.decorateFlinkPod(flinkPod);
accompanyingResources.addAll(stepDecorator.buildAccompanyingKubernetesResources());
}
final Deployment deployment = createJobManagerDeployment(flinkPod, kubernetesJobManagerParameters);
return new KubernetesJobManagerSpecification(deployment, accompanyingResources);
}
use of org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerSpecification 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.KubernetesJobManagerSpecification 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));
}
use of org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerSpecification in project flink by apache.
the class KubernetesJobManagerFactoryWithPodTemplateTest method getResultPod.
@Override
protected Pod getResultPod(FlinkPod podTemplate) throws Exception {
final KubernetesJobManagerParameters kubernetesJobManagerParameters = new KubernetesJobManagerParameters(flinkConfig, new KubernetesClusterClientFactory().getClusterSpecification(flinkConfig));
final KubernetesJobManagerSpecification kubernetesJobManagerSpecification = KubernetesJobManagerFactory.buildKubernetesJobManagerSpecification(podTemplate, kubernetesJobManagerParameters);
final PodTemplateSpec podTemplateSpec = kubernetesJobManagerSpecification.getDeployment().getSpec().getTemplate();
return new PodBuilder().withMetadata(podTemplateSpec.getMetadata()).withSpec(podTemplateSpec.getSpec()).build();
}
use of org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerSpecification in project flink by apache.
the class KubernetesJobManagerFactoryTest method testFlinkConfConfigMap.
@Test
public void testFlinkConfConfigMap() throws IOException {
kubernetesJobManagerSpecification = KubernetesJobManagerFactory.buildKubernetesJobManagerSpecification(flinkPod, kubernetesJobManagerParameters);
final ConfigMap resultConfigMap = (ConfigMap) this.kubernetesJobManagerSpecification.getAccompanyingResources().stream().filter(x -> x instanceof ConfigMap && x.getMetadata().getName().equals(FlinkConfMountDecorator.getFlinkConfConfigMapName(CLUSTER_ID))).collect(Collectors.toList()).get(0);
assertEquals(2, resultConfigMap.getMetadata().getLabels().size());
final Map<String, String> resultDatas = resultConfigMap.getData();
assertEquals(3, resultDatas.size());
assertEquals("some data", resultDatas.get(CONFIG_FILE_LOG4J_NAME));
assertEquals("some data", resultDatas.get(CONFIG_FILE_LOGBACK_NAME));
assertTrue(resultDatas.get(FLINK_CONF_FILENAME).contains(KubernetesConfigOptionsInternal.ENTRY_POINT_CLASS.key() + ": " + ENTRY_POINT_CLASS));
}
Aggregations