use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class HadoopConfMountDecorator method decorateFlinkPod.
@Override
public FlinkPod decorateFlinkPod(FlinkPod flinkPod) {
Volume hadoopConfVolume;
final Optional<String> existingConfigMap = kubernetesParameters.getExistingHadoopConfigurationConfigMap();
if (existingConfigMap.isPresent()) {
hadoopConfVolume = new VolumeBuilder().withName(Constants.HADOOP_CONF_VOLUME).withNewConfigMap().withName(existingConfigMap.get()).endConfigMap().build();
} else {
final Optional<String> localHadoopConfigurationDirectory = kubernetesParameters.getLocalHadoopConfigurationDirectory();
if (!localHadoopConfigurationDirectory.isPresent()) {
return flinkPod;
}
final List<File> hadoopConfigurationFileItems = getHadoopConfigurationFileItems(localHadoopConfigurationDirectory.get());
if (hadoopConfigurationFileItems.isEmpty()) {
LOG.warn("Found 0 files in directory {}, skip to mount the Hadoop Configuration ConfigMap.", localHadoopConfigurationDirectory.get());
return flinkPod;
}
final List<KeyToPath> keyToPaths = hadoopConfigurationFileItems.stream().map(file -> new KeyToPathBuilder().withKey(file.getName()).withPath(file.getName()).build()).collect(Collectors.toList());
hadoopConfVolume = new VolumeBuilder().withName(Constants.HADOOP_CONF_VOLUME).withNewConfigMap().withName(getHadoopConfConfigMapName(kubernetesParameters.getClusterId())).withItems(keyToPaths).endConfigMap().build();
}
final Pod podWithHadoopConf = new PodBuilder(flinkPod.getPodWithoutMainContainer()).editOrNewSpec().addNewVolumeLike(hadoopConfVolume).endVolume().endSpec().build();
final Container containerWithHadoopConf = new ContainerBuilder(flinkPod.getMainContainer()).addNewVolumeMount().withName(Constants.HADOOP_CONF_VOLUME).withMountPath(Constants.HADOOP_CONF_DIR_IN_POD).endVolumeMount().addNewEnv().withName(Constants.ENV_HADOOP_CONF_DIR).withValue(Constants.HADOOP_CONF_DIR_IN_POD).endEnv().build();
return new FlinkPod.Builder(flinkPod).withPod(podWithHadoopConf).withMainContainer(containerWithHadoopConf).build();
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class KerberosMountDecorator method decorateFlinkPod.
@Override
public FlinkPod decorateFlinkPod(FlinkPod flinkPod) {
PodBuilder podBuilder = new PodBuilder(flinkPod.getPodWithoutMainContainer());
ContainerBuilder containerBuilder = new ContainerBuilder(flinkPod.getMainContainer());
if (!StringUtils.isNullOrWhitespaceOnly(securityConfig.getKeytab()) && !StringUtils.isNullOrWhitespaceOnly(securityConfig.getPrincipal())) {
podBuilder = podBuilder.editOrNewSpec().addNewVolume().withName(Constants.KERBEROS_KEYTAB_VOLUME).withNewSecret().withSecretName(getKerberosKeytabSecretName(kubernetesParameters.getClusterId())).endSecret().endVolume().endSpec();
containerBuilder = containerBuilder.addNewVolumeMount().withName(Constants.KERBEROS_KEYTAB_VOLUME).withMountPath(Constants.KERBEROS_KEYTAB_MOUNT_POINT).endVolumeMount();
}
if (!StringUtils.isNullOrWhitespaceOnly(kubernetesParameters.getFlinkConfiguration().get(SecurityOptions.KERBEROS_KRB5_PATH))) {
final File krb5Conf = new File(kubernetesParameters.getFlinkConfiguration().get(SecurityOptions.KERBEROS_KRB5_PATH));
podBuilder = podBuilder.editOrNewSpec().addNewVolume().withName(Constants.KERBEROS_KRB5CONF_VOLUME).withNewConfigMap().withName(getKerberosKrb5confConfigMapName(kubernetesParameters.getClusterId())).withItems(new KeyToPathBuilder().withKey(krb5Conf.getName()).withPath(KERBEROS_KRB5CONF_FILE).build()).endConfigMap().endVolume().endSpec();
containerBuilder = containerBuilder.addNewVolumeMount().withName(Constants.KERBEROS_KRB5CONF_VOLUME).withMountPath(Constants.KERBEROS_KRB5CONF_MOUNT_DIR + "/" + KERBEROS_KRB5CONF_FILE).withSubPath(KERBEROS_KRB5CONF_FILE).endVolumeMount();
}
return new FlinkPod(podBuilder.build(), containerBuilder.build());
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod in project flink by apache.
the class MountSecretsDecorator method decorateFlinkPod.
@Override
public FlinkPod decorateFlinkPod(FlinkPod flinkPod) {
final Pod podWithMount = decoratePod(flinkPod.getPodWithoutMainContainer());
final Container containerWithMount = decorateMainContainer(flinkPod.getMainContainer());
return new FlinkPod.Builder(flinkPod).withPod(podWithMount).withMainContainer(containerWithMount).build();
}
use of org.apache.flink.kubernetes.kubeclient.FlinkPod 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.FlinkPod in project flink by apache.
the class PodTemplateMountDecorator method decorateFlinkPod.
@Override
public FlinkPod decorateFlinkPod(FlinkPod flinkPod) {
if (!getTaskManagerPodTemplateFile().isPresent()) {
return flinkPod;
}
final Pod mountedPod = decoratePod(flinkPod.getPodWithoutMainContainer());
final Container mountedMainContainer = new ContainerBuilder(flinkPod.getMainContainer()).addNewVolumeMount().withName(POD_TEMPLATE_VOLUME).withMountPath(POD_TEMPLATE_DIR_IN_POD).endVolumeMount().build();
return new FlinkPod.Builder(flinkPod).withPod(mountedPod).withMainContainer(mountedMainContainer).build();
}
Aggregations