use of io.fabric8.kubernetes.api.model.HasMetadata in project flink by apache.
the class FlinkConfMountDecorator method buildAccompanyingKubernetesResources.
@Override
public List<HasMetadata> buildAccompanyingKubernetesResources() throws IOException {
final String clusterId = kubernetesComponentConf.getClusterId();
final Map<String, String> data = new HashMap<>();
final List<File> localLogFiles = getLocalLogConfFiles();
for (File file : localLogFiles) {
data.put(file.getName(), Files.toString(file, StandardCharsets.UTF_8));
}
final Map<String, String> propertiesMap = getClusterSidePropertiesMap(kubernetesComponentConf.getFlinkConfiguration());
data.put(FLINK_CONF_FILENAME, getFlinkConfData(propertiesMap));
final ConfigMap flinkConfConfigMap = new ConfigMapBuilder().withApiVersion(Constants.API_VERSION).withNewMetadata().withName(getFlinkConfConfigMapName(clusterId)).withLabels(kubernetesComponentConf.getCommonLabels()).endMetadata().addToData(data).build();
return Collections.singletonList(flinkConfConfigMap);
}
use of io.fabric8.kubernetes.api.model.HasMetadata in project flink by apache.
the class PodTemplateMountDecorator method buildAccompanyingKubernetesResources.
@Override
public List<HasMetadata> buildAccompanyingKubernetesResources() throws IOException {
return getTaskManagerPodTemplateFile().map(FunctionUtils.uncheckedFunction(file -> {
final Map<String, String> data = new HashMap<>();
data.put(TASK_MANAGER_POD_TEMPLATE_FILE_NAME, Files.toString(file, StandardCharsets.UTF_8));
final HasMetadata flinkConfConfigMap = new ConfigMapBuilder().withApiVersion(Constants.API_VERSION).withNewMetadata().withName(podTemplateConfigMapName).withLabels(kubernetesComponentConf.getCommonLabels()).endMetadata().addToData(data).build();
return Collections.singletonList(flinkConfConfigMap);
})).orElse(Collections.emptyList());
}
use of io.fabric8.kubernetes.api.model.HasMetadata in project flink by apache.
the class ExternalServiceDecoratorTest method testBuildAccompanyingKubernetesResources.
@Test
public void testBuildAccompanyingKubernetesResources() throws IOException {
final List<HasMetadata> resources = this.externalServiceDecorator.buildAccompanyingKubernetesResources();
assertEquals(1, resources.size());
final Service restService = (Service) resources.get(0);
assertEquals(Constants.API_VERSION, restService.getApiVersion());
assertEquals(ExternalServiceDecorator.getExternalServiceName(CLUSTER_ID), restService.getMetadata().getName());
final Map<String, String> expectedLabels = getCommonLabels();
assertEquals(expectedLabels, restService.getMetadata().getLabels());
assertEquals(KubernetesConfigOptions.ServiceExposedType.ClusterIP.name(), restService.getSpec().getType());
final List<ServicePort> expectedServicePorts = Collections.singletonList(new ServicePortBuilder().withName(Constants.REST_PORT_NAME).withPort(REST_PORT).withNewTargetPort(Integer.valueOf(REST_BIND_PORT)).build());
assertEquals(expectedServicePorts, restService.getSpec().getPorts());
expectedLabels.put(Constants.LABEL_COMPONENT_KEY, Constants.LABEL_COMPONENT_JOB_MANAGER);
assertEquals(expectedLabels, restService.getSpec().getSelector());
final Map<String, String> resultAnnotations = restService.getMetadata().getAnnotations();
assertThat(resultAnnotations, is(equalTo(customizedAnnotations)));
}
use of io.fabric8.kubernetes.api.model.HasMetadata in project flink by apache.
the class HadoopConfMountDecoratorTest method testHadoopConfConfigMap.
@Test
public void testHadoopConfConfigMap() throws IOException {
setHadoopConfDirEnv();
generateHadoopConfFileItems();
final List<HasMetadata> additionalResources = hadoopConfMountDecorator.buildAccompanyingKubernetesResources();
assertEquals(1, additionalResources.size());
final ConfigMap resultConfigMap = (ConfigMap) additionalResources.get(0);
assertEquals(Constants.API_VERSION, resultConfigMap.getApiVersion());
assertEquals(HadoopConfMountDecorator.getHadoopConfConfigMapName(CLUSTER_ID), resultConfigMap.getMetadata().getName());
assertEquals(getCommonLabels(), resultConfigMap.getMetadata().getLabels());
Map<String, String> resultDatas = resultConfigMap.getData();
assertEquals("some data", resultDatas.get("core-site.xml"));
assertEquals("some data", resultDatas.get("hdfs-site.xml"));
}
use of io.fabric8.kubernetes.api.model.HasMetadata in project flink by apache.
the class Fabric8FlinkKubeClient method setOwnerReference.
private void setOwnerReference(Deployment deployment, List<HasMetadata> resources) {
final OwnerReference deploymentOwnerReference = new OwnerReferenceBuilder().withName(deployment.getMetadata().getName()).withApiVersion(deployment.getApiVersion()).withUid(deployment.getMetadata().getUid()).withKind(deployment.getKind()).withController(true).withBlockOwnerDeletion(true).build();
resources.forEach(resource -> resource.getMetadata().setOwnerReferences(Collections.singletonList(deploymentOwnerReference)));
}
Aggregations