forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-21128][k8s] Introduce dedicated scripts for native K8s integra…
…tion
- Loading branch information
1 parent
f73b7e7
commit a26388c
Showing
22 changed files
with
428 additions
and
954 deletions.
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
42 changes: 42 additions & 0 deletions
42
flink-dist/src/main/flink-bin/kubernetes-bin/kubernetes-jobmanager.sh
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,42 @@ | ||
#!/usr/bin/env bash | ||
################################################################################ | ||
# 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:https://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. | ||
################################################################################ | ||
|
||
# Start a Flink JobManager for native Kubernetes. | ||
# NOTE: This script is not meant to be started manually. It will be used by native Kubernetes integration. | ||
|
||
USAGE="Usage: kubernetes-jobmanager.sh kubernetes-session|kubernetes-application [args]" | ||
|
||
ENTRY_POINT_NAME=$1 | ||
|
||
ARGS=("${@:2}") | ||
|
||
bin=`dirname "$0"` | ||
bin=`cd "$bin"; pwd` | ||
|
||
. "$bin"/config.sh | ||
|
||
# Add JobManager specific JVM options | ||
export FLINK_ENV_JAVA_OPTS="${FLINK_ENV_JAVA_OPTS} ${FLINK_ENV_JAVA_OPTS_JM}" | ||
parseJmArgsAndExportLogs "${ARGS[@]}" | ||
|
||
if [ ! -z "${DYNAMIC_PARAMETERS}" ]; then | ||
ARGS=(${DYNAMIC_PARAMETERS[@]} "${ARGS[@]}") | ||
fi | ||
|
||
exec "${FLINK_BIN_DIR}"/flink-console.sh ${ENTRY_POINT_NAME} "${ARGS[@]}" |
47 changes: 47 additions & 0 deletions
47
flink-dist/src/main/flink-bin/kubernetes-bin/kubernetes-taskmanager.sh
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,47 @@ | ||
#!/usr/bin/env bash | ||
################################################################################ | ||
# 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:https://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. | ||
################################################################################ | ||
|
||
# Start a Flink TaskManager for native Kubernetes. | ||
# NOTE: This script is not meant to be started manually. It will be used by native Kubernetes integration. | ||
|
||
USAGE="Usage: kubernetes-taskmanager.sh [args]" | ||
|
||
ENTRYPOINT=kubernetes-taskmanager | ||
|
||
ARGS=("${@:1}") | ||
|
||
bin=`dirname "$0"` | ||
bin=`cd "$bin"; pwd` | ||
|
||
. "$bin"/config.sh | ||
|
||
# if no other JVM options are set, set the GC to G1 | ||
if [ -z "${FLINK_ENV_JAVA_OPTS}" ] && [ -z "${FLINK_ENV_JAVA_OPTS_TM}" ]; then | ||
export JVM_ARGS="$JVM_ARGS -XX:+UseG1GC" | ||
fi | ||
|
||
# Add TaskManager specific JVM options | ||
export FLINK_ENV_JAVA_OPTS="${FLINK_ENV_JAVA_OPTS} ${FLINK_ENV_JAVA_OPTS_TM}" | ||
parseTmArgsAndExportLogs "${ARGS[@]}" | ||
|
||
# Do not need to add ${DYNAMIC_PARAMETERS[@]} to ${ARGS[@]} since it is already done in native Kubernetes integration. | ||
|
||
ARGS=("--configDir" "${FLINK_CONF_DIR}" "${ARGS[@]}") | ||
|
||
exec "${FLINK_BIN_DIR}"/flink-console.sh $ENTRYPOINT "${ARGS[@]}" |
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
61 changes: 61 additions & 0 deletions
61
...c/main/java/org/apache/flink/kubernetes/kubeclient/decorators/CmdJobManagerDecorator.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,61 @@ | ||
/* | ||
* 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:https://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.kubeclient.decorators; | ||
|
||
import org.apache.flink.kubernetes.configuration.KubernetesDeploymentTarget; | ||
import org.apache.flink.kubernetes.kubeclient.FlinkPod; | ||
import org.apache.flink.kubernetes.kubeclient.parameters.KubernetesJobManagerParameters; | ||
import org.apache.flink.kubernetes.utils.Constants; | ||
import org.apache.flink.kubernetes.utils.KubernetesUtils; | ||
|
||
import io.fabric8.kubernetes.api.model.Container; | ||
import io.fabric8.kubernetes.api.model.ContainerBuilder; | ||
|
||
import java.util.List; | ||
|
||
import static org.apache.flink.util.Preconditions.checkNotNull; | ||
|
||
/** Attach the command and args to the main container for running the JobManager. */ | ||
public class CmdJobManagerDecorator extends AbstractKubernetesStepDecorator { | ||
|
||
private final KubernetesJobManagerParameters kubernetesJobManagerParameters; | ||
|
||
public CmdJobManagerDecorator(KubernetesJobManagerParameters kubernetesJobManagerParameters) { | ||
this.kubernetesJobManagerParameters = checkNotNull(kubernetesJobManagerParameters); | ||
} | ||
|
||
@Override | ||
public FlinkPod decorateFlinkPod(FlinkPod flinkPod) { | ||
final Container mainContainerWithStartCmd = | ||
new ContainerBuilder(flinkPod.getMainContainer()) | ||
.withCommand(kubernetesJobManagerParameters.getContainerEntrypoint()) | ||
.withArgs(getJobManagerStartCommand()) | ||
.build(); | ||
|
||
return new FlinkPod.Builder(flinkPod).withMainContainer(mainContainerWithStartCmd).build(); | ||
} | ||
|
||
private List<String> getJobManagerStartCommand() { | ||
final KubernetesDeploymentTarget deploymentTarget = | ||
KubernetesDeploymentTarget.fromConfig( | ||
kubernetesJobManagerParameters.getFlinkConfiguration()); | ||
return KubernetesUtils.getStartCommandWithBashWrapper( | ||
Constants.KUBERNETES_JOB_MANAGER_SCRIPT_PATH + " " + deploymentTarget.getName()); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
.../main/java/org/apache/flink/kubernetes/kubeclient/decorators/CmdTaskManagerDecorator.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,71 @@ | ||
/* | ||
* 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:https://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.kubeclient.decorators; | ||
|
||
import org.apache.flink.kubernetes.kubeclient.FlinkPod; | ||
import org.apache.flink.kubernetes.kubeclient.parameters.KubernetesTaskManagerParameters; | ||
import org.apache.flink.kubernetes.utils.Constants; | ||
import org.apache.flink.kubernetes.utils.KubernetesUtils; | ||
import org.apache.flink.runtime.clusterframework.TaskExecutorProcessUtils; | ||
|
||
import io.fabric8.kubernetes.api.model.Container; | ||
import io.fabric8.kubernetes.api.model.ContainerBuilder; | ||
|
||
import java.util.List; | ||
|
||
import static org.apache.flink.util.Preconditions.checkNotNull; | ||
|
||
/** Attach the command and args to the main container for running the TaskManager. */ | ||
public class CmdTaskManagerDecorator extends AbstractKubernetesStepDecorator { | ||
|
||
private final KubernetesTaskManagerParameters kubernetesTaskManagerParameters; | ||
|
||
public CmdTaskManagerDecorator( | ||
KubernetesTaskManagerParameters kubernetesTaskManagerParameters) { | ||
this.kubernetesTaskManagerParameters = checkNotNull(kubernetesTaskManagerParameters); | ||
} | ||
|
||
@Override | ||
public FlinkPod decorateFlinkPod(FlinkPod flinkPod) { | ||
final Container mainContainerWithStartCmd = | ||
new ContainerBuilder(flinkPod.getMainContainer()) | ||
.withCommand(kubernetesTaskManagerParameters.getContainerEntrypoint()) | ||
.withArgs(getTaskManagerStartCommand()) | ||
.build(); | ||
|
||
return new FlinkPod.Builder(flinkPod).withMainContainer(mainContainerWithStartCmd).build(); | ||
} | ||
|
||
private List<String> getTaskManagerStartCommand() { | ||
final String resourceArgs = | ||
TaskExecutorProcessUtils.generateDynamicConfigsStr( | ||
kubernetesTaskManagerParameters | ||
.getContaineredTaskManagerParameters() | ||
.getTaskExecutorProcessSpec()); | ||
|
||
final String dynamicProperties = kubernetesTaskManagerParameters.getDynamicProperties(); | ||
|
||
return KubernetesUtils.getStartCommandWithBashWrapper( | ||
Constants.KUBERNETES_TASK_MANAGER_SCRIPT_PATH | ||
+ " " | ||
+ dynamicProperties | ||
+ " " | ||
+ resourceArgs); | ||
} | ||
} |
108 changes: 0 additions & 108 deletions
108
...in/java/org/apache/flink/kubernetes/kubeclient/decorators/JavaCmdJobManagerDecorator.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.