Search in sources :

Example 1 with API_VERSION

use of org.apache.flink.kubernetes.utils.Constants.API_VERSION 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();
}
Also used : EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Arrays(java.util.Arrays) Container(io.fabric8.kubernetes.api.model.Container) DNS_PLOICY_DEFAULT(org.apache.flink.kubernetes.utils.Constants.DNS_PLOICY_DEFAULT) POD_IP_FIELD_PATH(org.apache.flink.kubernetes.utils.Constants.POD_IP_FIELD_PATH) ResourceRequirements(io.fabric8.kubernetes.api.model.ResourceRequirements) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) ENV_FLINK_POD_IP_ADDRESS(org.apache.flink.kubernetes.utils.Constants.ENV_FLINK_POD_IP_ADDRESS) EnvVarSourceBuilder(io.fabric8.kubernetes.api.model.EnvVarSourceBuilder) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) Preconditions.checkNotNull(org.apache.flink.util.Preconditions.checkNotNull) KubernetesJobManagerParameters(org.apache.flink.kubernetes.kubeclient.parameters.KubernetesJobManagerParameters) KubernetesUtils(org.apache.flink.kubernetes.utils.KubernetesUtils) KubernetesConfigOptions(org.apache.flink.kubernetes.configuration.KubernetesConfigOptions) Configuration(org.apache.flink.configuration.Configuration) EnvVarBuilder(io.fabric8.kubernetes.api.model.EnvVarBuilder) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) Collectors(java.util.stream.Collectors) ContainerPort(io.fabric8.kubernetes.api.model.ContainerPort) List(java.util.List) KubernetesToleration(org.apache.flink.kubernetes.kubeclient.resources.KubernetesToleration) Optional(java.util.Optional) DNS_PLOICY_HOSTNETWORK(org.apache.flink.kubernetes.utils.Constants.DNS_PLOICY_HOSTNETWORK) Constants(org.apache.flink.kubernetes.utils.Constants) ContainerPortBuilder(io.fabric8.kubernetes.api.model.ContainerPortBuilder) Collections(java.util.Collections) API_VERSION(org.apache.flink.kubernetes.utils.Constants.API_VERSION) Container(io.fabric8.kubernetes.api.model.Container) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder)

Aggregations

Container (io.fabric8.kubernetes.api.model.Container)1 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)1 ContainerPort (io.fabric8.kubernetes.api.model.ContainerPort)1 ContainerPortBuilder (io.fabric8.kubernetes.api.model.ContainerPortBuilder)1 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)1 EnvVarBuilder (io.fabric8.kubernetes.api.model.EnvVarBuilder)1 EnvVarSourceBuilder (io.fabric8.kubernetes.api.model.EnvVarSourceBuilder)1 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)1 ResourceRequirements (io.fabric8.kubernetes.api.model.ResourceRequirements)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Configuration (org.apache.flink.configuration.Configuration)1 KubernetesConfigOptions (org.apache.flink.kubernetes.configuration.KubernetesConfigOptions)1 FlinkPod (org.apache.flink.kubernetes.kubeclient.FlinkPod)1 KubernetesJobManagerParameters (org.apache.flink.kubernetes.kubeclient.parameters.KubernetesJobManagerParameters)1 KubernetesToleration (org.apache.flink.kubernetes.kubeclient.resources.KubernetesToleration)1 Constants (org.apache.flink.kubernetes.utils.Constants)1