use of io.fabric8.kubernetes.api.model.KeyToPath in project flink by apache.
the class FlinkConfMountDecorator method decoratePod.
private Pod decoratePod(Pod pod) {
final List<KeyToPath> keyToPaths = getLocalLogConfFiles().stream().map(file -> new KeyToPathBuilder().withKey(file.getName()).withPath(file.getName()).build()).collect(Collectors.toList());
keyToPaths.add(new KeyToPathBuilder().withKey(FLINK_CONF_FILENAME).withPath(FLINK_CONF_FILENAME).build());
final Volume flinkConfVolume = new VolumeBuilder().withName(FLINK_CONF_VOLUME).withNewConfigMap().withName(getFlinkConfConfigMapName(kubernetesComponentConf.getClusterId())).withItems(keyToPaths).endConfigMap().build();
return new PodBuilder(pod).editSpec().addNewVolumeLike(flinkConfVolume).endVolume().endSpec().build();
}
use of io.fabric8.kubernetes.api.model.KeyToPath in project flink by apache.
the class FlinkConfMountDecoratorTest method testDecoratedFlinkPodWithLog4jAndLogback.
@Test
public void testDecoratedFlinkPodWithLog4jAndLogback() throws IOException {
KubernetesTestUtils.createTemporyFile("some data", flinkConfDir, CONFIG_FILE_LOG4J_NAME);
KubernetesTestUtils.createTemporyFile("some data", flinkConfDir, CONFIG_FILE_LOGBACK_NAME);
final FlinkPod resultFlinkPod = flinkConfMountDecorator.decorateFlinkPod(baseFlinkPod);
final List<KeyToPath> expectedKeyToPaths = Arrays.asList(new KeyToPathBuilder().withKey(CONFIG_FILE_LOGBACK_NAME).withPath(CONFIG_FILE_LOGBACK_NAME).build(), new KeyToPathBuilder().withKey(CONFIG_FILE_LOG4J_NAME).withPath(CONFIG_FILE_LOG4J_NAME).build(), new KeyToPathBuilder().withKey(FLINK_CONF_FILENAME).withPath(FLINK_CONF_FILENAME).build());
final List<Volume> expectedVolumes = Collections.singletonList(new VolumeBuilder().withName(Constants.FLINK_CONF_VOLUME).withNewConfigMap().withName(getFlinkConfConfigMapName(CLUSTER_ID)).withItems(expectedKeyToPaths).endConfigMap().build());
assertEquals(expectedVolumes, resultFlinkPod.getPodWithoutMainContainer().getSpec().getVolumes());
}
use of io.fabric8.kubernetes.api.model.KeyToPath in project flink by apache.
the class FlinkConfMountDecoratorTest method testDecoratedFlinkPodWithLog4j.
@Test
public void testDecoratedFlinkPodWithLog4j() throws IOException {
KubernetesTestUtils.createTemporyFile("some data", flinkConfDir, CONFIG_FILE_LOG4J_NAME);
final FlinkPod resultFlinkPod = flinkConfMountDecorator.decorateFlinkPod(baseFlinkPod);
final List<KeyToPath> expectedKeyToPaths = Arrays.asList(new KeyToPathBuilder().withKey(CONFIG_FILE_LOG4J_NAME).withPath(CONFIG_FILE_LOG4J_NAME).build(), new KeyToPathBuilder().withKey(FLINK_CONF_FILENAME).withPath(FLINK_CONF_FILENAME).build());
final List<Volume> expectedVolumes = Collections.singletonList(new VolumeBuilder().withName(Constants.FLINK_CONF_VOLUME).withNewConfigMap().withName(getFlinkConfConfigMapName(CLUSTER_ID)).withItems(expectedKeyToPaths).endConfigMap().build());
assertEquals(expectedVolumes, resultFlinkPod.getPodWithoutMainContainer().getSpec().getVolumes());
}
use of io.fabric8.kubernetes.api.model.KeyToPath in project flink by apache.
the class FlinkConfMountDecoratorTest method testDecoratedFlinkPodWithLogback.
@Test
public void testDecoratedFlinkPodWithLogback() throws IOException {
KubernetesTestUtils.createTemporyFile("some data", flinkConfDir, CONFIG_FILE_LOGBACK_NAME);
final FlinkPod resultFlinkPod = flinkConfMountDecorator.decorateFlinkPod(baseFlinkPod);
final List<KeyToPath> expectedKeyToPaths = Arrays.asList(new KeyToPathBuilder().withKey(CONFIG_FILE_LOGBACK_NAME).withPath(CONFIG_FILE_LOGBACK_NAME).build(), new KeyToPathBuilder().withKey(FLINK_CONF_FILENAME).withPath(FLINK_CONF_FILENAME).build());
final List<Volume> expectedVolumes = Collections.singletonList(new VolumeBuilder().withName(Constants.FLINK_CONF_VOLUME).withNewConfigMap().withName(getFlinkConfConfigMapName(CLUSTER_ID)).withItems(expectedKeyToPaths).endConfigMap().build());
assertEquals(expectedVolumes, resultFlinkPod.getPodWithoutMainContainer().getSpec().getVolumes());
}
Aggregations