forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flink Kubernetes Support #2
Open
esevastyanov
wants to merge
13
commits into
release-1.7
Choose a base branch
from
release-1.7-k8s
base: release-1.7
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
897860f
Pass jobVertex's ResourceProfile to SlotPool and ResourceManager
esevastyanov 44e14db
Added a comment for new method getResourceProfile()
esevastyanov a8cc09b
Use min resources instead of preferred to increase the probability of
esevastyanov 8b988ba
BACKEND-1137: K8s integration - initial commit
esevastyanov e4da06d
BACKEND-1137: K8s integration
esevastyanov f8fb172
BACKEND-1137: K8s integration - fixed a script
esevastyanov 60094aa
BACKEND-1137: K8s integration - refactoring
esevastyanov ccd1318
BACKEND-1137: K8s integration - README
esevastyanov 2028d72
BACKEND-1137: Fixed style
esevastyanov 41e2f66
BACKEND-1137: Refactored and added some comments
esevastyanov ec62634
BACKEND-1137: Refactored and added some comments
esevastyanov 9efe807
BACKEND-1137: Refactored KubernetesClusterDescriptor
esevastyanov 54f7c7d
BACKEND-1137: Refactored KubernetesClusterDescriptor and dependent
esevastyanov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Flink On Kubernetes | ||
|
||
## Job manager | ||
Job manager is run as a pod of corresponding deployment which is supposed to be prepared beforehand. | ||
To create the deployment and a service for it the following templates (under `flink-kubernets/templates` path) | ||
should be used: | ||
``` | ||
jobmanager-deployment.yaml | ||
jobmanager-service.yaml | ||
``` | ||
Example: | ||
``` | ||
kubectl create -f jobmanager-deployment.yaml | ||
kubectl create -f jobmanager-service.yaml | ||
``` | ||
That creates the deployment with one job manager and a service around it that exposes | ||
(ClusterIP, NodePort, LoadBalancer, ExternalName) the job manager. | ||
|
||
## Task Manager | ||
Task manager is a temporary essence and is created (and deleted) by a job manager for a particular slot. | ||
No deployments/jobs/services are created for a task manager, only pods. | ||
A template for a task manager is hardcoded into the implementation | ||
(`org.apache.flink.kubernetes.client.DefaultKubernetesClient`). | ||
|
||
For every slot request the job manager passes a resource profile to a resource manager | ||
(`org.apache.flink.kubernetes.KubernetesResourceManager`). The resource profile contains specific hardware requirements | ||
(CPU, Memory and other). All these requirements are included into the pod template as labels thus they could be used for | ||
binding specific pods onto specific VMs. | ||
|
||
## Resource Profile | ||
A resource profile might be set to a `StreamTransformation` by calling a corresponding method. A resource profile has | ||
cpu cores, heap memory, direct memory, native memory, network memory and extended resources (GPU and user defined). | ||
Only `StreamTransformation.minResources` is used for a pod template. | ||
|
||
### Resource Profile Configuration Example | ||
TBD | ||
|
||
## Kubernetes Resource Management | ||
Resource management uses a default service account every pod contains. It should have admin privileges to be able | ||
to create and delete pods: | ||
``` | ||
kubectl create clusterrolebinding serviceaccounts-cluster-admin \ | ||
--clusterrole=cluster-admin \ | ||
--group=system:serviceaccounts | ||
``` | ||
|
||
## Build and run | ||
The implementation is based on existing mechanism of packaging (maven) and containerization (docker). | ||
|
||
Prepare a package first: | ||
```mvn clean package -DskipTests``` | ||
Then in needs to be containerized: | ||
```cd flink-contrib/docker-flink/ | ||
sh build.sh --from-local-dist --image-name flink-mmx | ||
``` | ||
And uploaded to gcp (for example): | ||
``` | ||
docker tag flink-mmx gcr.io/metamarkets-prod-xpn-host/flink-mmx | ||
gcloud docker -- push gcr.io/metamarkets-prod-xpn-host/flink-mmx | ||
``` | ||
If minikube is used then a container image should be uploaded into minikube node. | ||
So before building a container image a docker env is supposed to be exported: | ||
``` | ||
eval $(minikube docker-env) | ||
``` | ||
Job manager deployment and service: | ||
``` | ||
cd ../../flink-kubernetes/templates/ | ||
kubectl create -f jobmanager-deployment.yaml | ||
kubectl create -f jobmanager-service.yaml | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one | ||
~ or more contributor license agreements. See the NOTICE file | ||
~ distributed with this work for additional information | ||
~ regarding copyright ownership. The ASF licenses this file | ||
~ to you under the Apache License, Version 2.0 (the | ||
~ "License"); you may not use this file except in compliance | ||
~ with the License. You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-parent</artifactId> | ||
<version>1.7-SNAPSHOT</version> | ||
<relativePath>..</relativePath> | ||
</parent> | ||
|
||
<artifactId>flink-kubernetes_${scala.binary.version}</artifactId> | ||
<name>flink-kubernetes</name> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<kubernetes.version>1.0.1</kubernetes.version> | ||
</properties> | ||
|
||
<dependencies> | ||
|
||
<!-- set all Flink dependencies to provided, so they and their transitive --> | ||
<!-- dependencies do not get promoted to direct dependencies during shading --> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-clients_${scala.binary.version}</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-runtime_${scala.binary.version}</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.scala-lang</groupId> | ||
<artifactId>scala-library</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.kubernetes</groupId> | ||
<artifactId>client-java</artifactId> | ||
<version>4.0.0</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
|
||
<!-- test dependencies --> | ||
|
||
<dependency> | ||
<groupId>org.apache.flink</groupId> | ||
<artifactId>flink-test-utils-junit</artifactId> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-enforcer-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>dependency-convergence</id> | ||
<goals> | ||
<goal>enforce</goal> | ||
</goals> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<!-- Scala Compiler --> | ||
<plugin> | ||
<groupId>net.alchim31.maven</groupId> | ||
<artifactId>scala-maven-plugin</artifactId> | ||
<executions> | ||
<!-- Run scala compiler in the process-resources phase, so that dependencies on | ||
scala classes can be resolved later in the (Java) compile phase --> | ||
<execution> | ||
<id>scala-compile-first</id> | ||
<phase>process-resources</phase> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
|
||
<!-- Run scala compiler in the process-test-resources phase, so that dependencies on | ||
scala classes can be resolved later in the (Java) test-compile phase --> | ||
<execution> | ||
<id>scala-test-compile</id> | ||
<phase>process-test-resources</phase> | ||
<goals> | ||
<goal>testCompile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<jvmArgs> | ||
<jvmArg>-Xms128m</jvmArg> | ||
<jvmArg>-Xmx512m</jvmArg> | ||
</jvmArgs> | ||
</configuration> | ||
</plugin> | ||
|
||
<!-- Eclipse Integration --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-eclipse-plugin</artifactId> | ||
<version>2.8</version> | ||
<configuration> | ||
<downloadSources>true</downloadSources> | ||
<projectnatures> | ||
<projectnature>org.scala-ide.sdt.core.scalanature</projectnature> | ||
<projectnature>org.eclipse.jdt.core.javanature</projectnature> | ||
</projectnatures> | ||
<buildcommands> | ||
<buildcommand>org.scala-ide.sdt.core.scalabuilder</buildcommand> | ||
</buildcommands> | ||
<classpathContainers> | ||
<classpathContainer>org.scala-ide.sdt.launching.SCALA_CONTAINER</classpathContainer> | ||
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer> | ||
</classpathContainers> | ||
<excludes> | ||
<exclude>org.scala-lang:scala-library</exclude> | ||
<exclude>org.scala-lang:scala-compiler</exclude> | ||
</excludes> | ||
<sourceIncludes> | ||
<sourceInclude>**/*.scala</sourceInclude> | ||
<sourceInclude>**/*.java</sourceInclude> | ||
</sourceIncludes> | ||
</configuration> | ||
</plugin> | ||
|
||
<!-- Adding scala source directories to build path --> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>build-helper-maven-plugin</artifactId> | ||
<version>1.7</version> | ||
<executions> | ||
<!-- Add src/main/scala to eclipse build path --> | ||
<execution> | ||
<id>add-source</id> | ||
<phase>generate-sources</phase> | ||
<goals> | ||
<goal>add-source</goal> | ||
</goals> | ||
<configuration> | ||
<sources> | ||
<source>src/main/scala</source> | ||
</sources> | ||
</configuration> | ||
</execution> | ||
<!-- Add src/test/scala to eclipse build path --> | ||
<execution> | ||
<id>add-test-source</id> | ||
<phase>generate-test-sources</phase> | ||
<goals> | ||
<goal>add-test-source</goal> | ||
</goals> | ||
<configuration> | ||
<sources> | ||
<source>src/test/scala</source> | ||
</sources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<!-- Scala Code Style, most of the configuration done via plugin management --> | ||
<plugin> | ||
<groupId>org.scalastyle</groupId> | ||
<artifactId>scalastyle-maven-plugin</artifactId> | ||
<configuration> | ||
<configLocation>${project.basedir}/../tools/maven/scalastyle-config.xml</configLocation> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>test-jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
37 changes: 37 additions & 0 deletions
37
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/FlinkKubernetesOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.flink.kubernetes; | ||
|
||
import org.apache.flink.configuration.Configuration; | ||
|
||
/** | ||
* Parameters that will be used in Flink on k8s cluster. | ||
* */ | ||
public class FlinkKubernetesOptions { | ||
|
||
private Configuration configuration; | ||
|
||
public Configuration getConfiguration() { | ||
return configuration; | ||
} | ||
|
||
public FlinkKubernetesOptions(Configuration configuration) { | ||
this.configuration = configuration; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jobmanager-exposer-deployment.yaml ?
Also, a question сomes up instantly how exactly it exposes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That creates the deployment with one job manager and service around it that exposes
(ClusterIP/NodePort/LoadBalancer/ExternalName) the job manager
https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types