Search in sources :

Example 1 with FLINK_CONF_FILENAME

use of org.apache.flink.configuration.GlobalConfiguration.FLINK_CONF_FILENAME 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();
}
Also used : CONFIG_MAP_PREFIX(org.apache.flink.kubernetes.utils.Constants.CONFIG_MAP_PREFIX) Container(io.fabric8.kubernetes.api.model.Container) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AbstractKubernetesParameters(org.apache.flink.kubernetes.kubeclient.parameters.AbstractKubernetesParameters) TaskManagerOptions(org.apache.flink.configuration.TaskManagerOptions) CONFIG_FILE_LOG4J_NAME(org.apache.flink.kubernetes.utils.Constants.CONFIG_FILE_LOG4J_NAME) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) DeploymentOptionsInternal(org.apache.flink.configuration.DeploymentOptionsInternal) FLINK_CONF_VOLUME(org.apache.flink.kubernetes.utils.Constants.FLINK_CONF_VOLUME) Map(java.util.Map) KeyToPathBuilder(io.fabric8.kubernetes.api.model.KeyToPathBuilder) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) RestOptions(org.apache.flink.configuration.RestOptions) Preconditions.checkNotNull(org.apache.flink.util.Preconditions.checkNotNull) Volume(io.fabric8.kubernetes.api.model.Volume) FLINK_CONF_FILENAME(org.apache.flink.configuration.GlobalConfiguration.FLINK_CONF_FILENAME) PrintWriter(java.io.PrintWriter) KubernetesConfigOptions(org.apache.flink.kubernetes.configuration.KubernetesConfigOptions) KeyToPath(io.fabric8.kubernetes.api.model.KeyToPath) StringWriter(java.io.StringWriter) Configuration(org.apache.flink.configuration.Configuration) Pod(io.fabric8.kubernetes.api.model.Pod) IOException(java.io.IOException) VolumeBuilder(io.fabric8.kubernetes.api.model.VolumeBuilder) JobManagerOptions(org.apache.flink.configuration.JobManagerOptions) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) Collectors(java.util.stream.Collectors) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) VisibleForTesting(org.apache.flink.annotation.VisibleForTesting) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) List(java.util.List) Files(org.apache.flink.shaded.guava30.com.google.common.io.Files) CONFIG_FILE_LOGBACK_NAME(org.apache.flink.kubernetes.utils.Constants.CONFIG_FILE_LOGBACK_NAME) Constants(org.apache.flink.kubernetes.utils.Constants) Collections(java.util.Collections) KeyToPath(io.fabric8.kubernetes.api.model.KeyToPath) Volume(io.fabric8.kubernetes.api.model.Volume) KeyToPathBuilder(io.fabric8.kubernetes.api.model.KeyToPathBuilder) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) VolumeBuilder(io.fabric8.kubernetes.api.model.VolumeBuilder)

Example 2 with FLINK_CONF_FILENAME

use of org.apache.flink.configuration.GlobalConfiguration.FLINK_CONF_FILENAME 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));
}
Also used : Quantity(io.fabric8.kubernetes.api.model.Quantity) SecurityOptions(org.apache.flink.configuration.SecurityOptions) KubernetesTestUtils(org.apache.flink.kubernetes.KubernetesTestUtils) KubernetesJobManagerTestBase(org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerTestBase) CONFIG_FILE_LOG4J_NAME(org.apache.flink.kubernetes.utils.Constants.CONFIG_FILE_LOG4J_NAME) Map(java.util.Map) ExternalServiceDecorator(org.apache.flink.kubernetes.kubeclient.decorators.ExternalServiceDecorator) DeploymentSpec(io.fabric8.kubernetes.api.model.apps.DeploymentSpec) KubernetesUtils(org.apache.flink.kubernetes.utils.KubernetesUtils) KubernetesConfigOptions(org.apache.flink.kubernetes.configuration.KubernetesConfigOptions) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) Collectors(java.util.stream.Collectors) Base64(java.util.Base64) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Secret(io.fabric8.kubernetes.api.model.Secret) Matchers.is(org.hamcrest.Matchers.is) Constants(org.apache.flink.kubernetes.utils.Constants) Container(io.fabric8.kubernetes.api.model.Container) KubernetesConfigOptionsInternal(org.apache.flink.kubernetes.configuration.KubernetesConfigOptionsInternal) HashMap(java.util.HashMap) OwnerReference(io.fabric8.kubernetes.api.model.OwnerReference) KubernetesHaServicesFactory(org.apache.flink.kubernetes.highavailability.KubernetesHaServicesFactory) PodSpec(io.fabric8.kubernetes.api.model.PodSpec) DeploymentOptions(org.apache.flink.configuration.DeploymentOptions) FlinkConfMountDecorator(org.apache.flink.kubernetes.kubeclient.decorators.FlinkConfMountDecorator) Service(io.fabric8.kubernetes.api.model.Service) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) KubernetesDeploymentTarget(org.apache.flink.kubernetes.configuration.KubernetesDeploymentTarget) FLINK_CONF_FILENAME(org.apache.flink.configuration.GlobalConfiguration.FLINK_CONF_FILENAME) InternalServiceDecorator(org.apache.flink.kubernetes.kubeclient.decorators.InternalServiceDecorator) Assert.assertNotNull(org.junit.Assert.assertNotNull) KubernetesJobManagerSpecification(org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerSpecification) Matchers(org.hamcrest.Matchers) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) KubernetesSessionClusterEntrypoint(org.apache.flink.kubernetes.entrypoint.KubernetesSessionClusterEntrypoint) HadoopConfMountDecorator(org.apache.flink.kubernetes.kubeclient.decorators.HadoopConfMountDecorator) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) KerberosMountDecorator(org.apache.flink.kubernetes.kubeclient.decorators.KerberosMountDecorator) Assert.assertNull(org.junit.Assert.assertNull) HeadlessClusterIPService(org.apache.flink.kubernetes.kubeclient.services.HeadlessClusterIPService) CONFIG_FILE_LOGBACK_NAME(org.apache.flink.kubernetes.utils.Constants.CONFIG_FILE_LOGBACK_NAME) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) Collections(java.util.Collections) HighAvailabilityOptions(org.apache.flink.configuration.HighAvailabilityOptions) Assert.assertEquals(org.junit.Assert.assertEquals) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Test(org.junit.Test)

Aggregations

ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)2 Container (io.fabric8.kubernetes.api.model.Container)2 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)2 IOException (java.io.IOException)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 FLINK_CONF_FILENAME (org.apache.flink.configuration.GlobalConfiguration.FLINK_CONF_FILENAME)2 KubernetesConfigOptions (org.apache.flink.kubernetes.configuration.KubernetesConfigOptions)2 FlinkPod (org.apache.flink.kubernetes.kubeclient.FlinkPod)2 Constants (org.apache.flink.kubernetes.utils.Constants)2 CONFIG_FILE_LOG4J_NAME (org.apache.flink.kubernetes.utils.Constants.CONFIG_FILE_LOG4J_NAME)2 CONFIG_FILE_LOGBACK_NAME (org.apache.flink.kubernetes.utils.Constants.CONFIG_FILE_LOGBACK_NAME)2 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)1 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)1 KeyToPath (io.fabric8.kubernetes.api.model.KeyToPath)1 KeyToPathBuilder (io.fabric8.kubernetes.api.model.KeyToPathBuilder)1 OwnerReference (io.fabric8.kubernetes.api.model.OwnerReference)1