use of org.apache.flink.kubernetes.utils.Constants.DNS_PLOICY_DEFAULT in project flink by apache.
the class InitJobManagerDecorator method decorateFlinkPod.
@Override
public FlinkPod decorateFlinkPod(FlinkPod flinkPod) {
final PodBuilder basicPodBuilder = new PodBuilder(flinkPod.getPodWithoutMainContainer());
// Overwrite fields
final String serviceAccountName = KubernetesUtils.resolveUserDefinedValue(flinkConfig, KubernetesConfigOptions.JOB_MANAGER_SERVICE_ACCOUNT, kubernetesJobManagerParameters.getServiceAccount(), KubernetesUtils.getServiceAccount(flinkPod), "service account");
if (flinkPod.getPodWithoutMainContainer().getSpec().getRestartPolicy() != null) {
logger.info("The restart policy of JobManager pod will be overwritten to 'always' " + "since it is controlled by the Kubernetes deployment.");
}
basicPodBuilder.withApiVersion(API_VERSION).editOrNewSpec().withServiceAccount(serviceAccountName).withServiceAccountName(serviceAccountName).withHostNetwork(kubernetesJobManagerParameters.isHostNetworkEnabled()).withDnsPolicy(kubernetesJobManagerParameters.isHostNetworkEnabled() ? DNS_PLOICY_HOSTNETWORK : DNS_PLOICY_DEFAULT).endSpec();
// Merge fields
basicPodBuilder.editOrNewMetadata().addToLabels(kubernetesJobManagerParameters.getLabels()).addToAnnotations(kubernetesJobManagerParameters.getAnnotations()).endMetadata().editOrNewSpec().addToImagePullSecrets(kubernetesJobManagerParameters.getImagePullSecrets()).addToNodeSelector(kubernetesJobManagerParameters.getNodeSelector()).addAllToTolerations(kubernetesJobManagerParameters.getTolerations().stream().map(e -> KubernetesToleration.fromMap(e).getInternalResource()).collect(Collectors.toList())).endSpec();
final Container basicMainContainer = decorateMainContainer(flinkPod.getMainContainer());
return new FlinkPod.Builder(flinkPod).withPod(basicPodBuilder.build()).withMainContainer(basicMainContainer).build();
}
use of org.apache.flink.kubernetes.utils.Constants.DNS_PLOICY_DEFAULT in project flink by apache.
the class InitTaskManagerDecorator method decorateFlinkPod.
@Override
public FlinkPod decorateFlinkPod(FlinkPod flinkPod) {
final PodBuilder basicPodBuilder = new PodBuilder(flinkPod.getPodWithoutMainContainer());
// Overwrite fields
final String serviceAccountName = KubernetesUtils.resolveUserDefinedValue(flinkConfig, KubernetesConfigOptions.TASK_MANAGER_SERVICE_ACCOUNT, kubernetesTaskManagerParameters.getServiceAccount(), KubernetesUtils.getServiceAccount(flinkPod), "service account");
if (flinkPod.getPodWithoutMainContainer().getSpec().getRestartPolicy() != null) {
logger.info("The restart policy of TaskManager pod will be overwritten to 'never' " + "since it should not be restarted.");
}
basicPodBuilder.withApiVersion(Constants.API_VERSION).editOrNewMetadata().withName(kubernetesTaskManagerParameters.getPodName()).endMetadata().editOrNewSpec().withServiceAccount(serviceAccountName).withServiceAccountName(serviceAccountName).withRestartPolicy(Constants.RESTART_POLICY_OF_NEVER).withHostNetwork(kubernetesTaskManagerParameters.isHostNetworkEnabled()).withDnsPolicy(kubernetesTaskManagerParameters.isHostNetworkEnabled() ? DNS_PLOICY_HOSTNETWORK : DNS_PLOICY_DEFAULT).endSpec();
// Merge fields
basicPodBuilder.editOrNewMetadata().addToLabels(kubernetesTaskManagerParameters.getLabels()).addToAnnotations(kubernetesTaskManagerParameters.getAnnotations()).endMetadata().editOrNewSpec().addToImagePullSecrets(kubernetesTaskManagerParameters.getImagePullSecrets()).addToNodeSelector(kubernetesTaskManagerParameters.getNodeSelector()).addAllToTolerations(kubernetesTaskManagerParameters.getTolerations().stream().map(e -> KubernetesToleration.fromMap(e).getInternalResource()).collect(Collectors.toList())).endSpec();
final Container basicMainContainer = decorateMainContainer(flinkPod.getMainContainer());
return new FlinkPod.Builder(flinkPod).withPod(basicPodBuilder.build()).withMainContainer(basicMainContainer).build();
}
Aggregations