[GitHub] [flink] zhijiangW commented on a change in pull request #9985: [FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.

2019-12-03 Thread GitBox
zhijiangW commented on a change in pull request #9985: 
[FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.
URL: https://github.com/apache/flink/pull/9985#discussion_r353099734
 
 

 ##
 File path: 
flink-yarn/src/main/java/org/apache/flink/yarn/YarnTaskExecutorRunner.java
 ##
 @@ -97,22 +91,7 @@ private static void run(String[] args) {
final String currDir = ENV.get(Environment.PWD.key());
LOG.info("Current working Directory: {}", currDir);
 
-  // Some dynamic properties for task manager are added to args, such as 
managed memory size.
-   final CommandLineParser 
commandLineParser =
-   new CommandLineParser<>(new 
ClusterConfigurationParserFactory());
-
-   ClusterConfiguration clusterConfiguration = null;
-   try {
-   clusterConfiguration = 
commandLineParser.parse(args);
-   } catch (FlinkParseException e) {
-   LOG.error("Could not parse command line 
arguments {}.", args, e);
-   
commandLineParser.printHelp(YarnTaskExecutorRunner.class.getSimpleName());
-   System.exit(1);
 
 Review comment:
   Sorry I missed the below catch clause for catching this exception and 
exiting finally.
   If so it makes sense for me.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] zhijiangW commented on a change in pull request #9985: [FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.

2019-12-03 Thread GitBox
zhijiangW commented on a change in pull request #9985: 
[FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.
URL: https://github.com/apache/flink/pull/9985#discussion_r353096610
 
 

 ##
 File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/utils/Constants.java
 ##
 @@ -0,0 +1,27 @@
+/*
+ * 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.utils;
+
+/**
+ * Constants for kubernetes.
+ */
+public class Constants {
 
 Review comment:
   Makes sense for me


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] zhijiangW commented on a change in pull request #9985: [FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.

2019-12-02 Thread GitBox
zhijiangW commented on a change in pull request #9985: 
[FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.
URL: https://github.com/apache/flink/pull/9985#discussion_r352998962
 
 

 ##
 File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/utils/Constants.java
 ##
 @@ -0,0 +1,27 @@
+/*
+ * 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.utils;
+
+/**
+ * Constants for kubernetes.
+ */
+public class Constants {
 
 Review comment:
   I am not quite sure whether it is worth defining this class for only one 
constant variable, or we can define this variable directly in 
`KubernetesTaskExecutorRunner` class. If you prefer to a separate class, then 
it is better to rename the class as `KubernetetsConstants` to give a specific 
semantic.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] zhijiangW commented on a change in pull request #9985: [FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.

2019-12-02 Thread GitBox
zhijiangW commented on a change in pull request #9985: 
[FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.
URL: https://github.com/apache/flink/pull/9985#discussion_r352998962
 
 

 ##
 File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/utils/Constants.java
 ##
 @@ -0,0 +1,27 @@
+/*
+ * 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.utils;
+
+/**
+ * Constants for kubernetes.
+ */
+public class Constants {
 
 Review comment:
   I am not quite sure whether it is worth defining this class for only one 
constant variable, or we can define this variable directly in 
`KubernetesTaskExecutorRunner` class. If you prefer to a separate class, then 
it is better to rename the class as KubernetetsConstants to give a specific 
semantic.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] zhijiangW commented on a change in pull request #9985: [FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.

2019-12-02 Thread GitBox
zhijiangW commented on a change in pull request #9985: 
[FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.
URL: https://github.com/apache/flink/pull/9985#discussion_r352973927
 
 

 ##
 File path: 
flink-yarn/src/main/java/org/apache/flink/yarn/YarnTaskExecutorRunner.java
 ##
 @@ -97,22 +91,7 @@ private static void run(String[] args) {
final String currDir = ENV.get(Environment.PWD.key());
LOG.info("Current working Directory: {}", currDir);
 
-  // Some dynamic properties for task manager are added to args, such as 
managed memory size.
-   final CommandLineParser 
commandLineParser =
-   new CommandLineParser<>(new 
ClusterConfigurationParserFactory());
-
-   ClusterConfiguration clusterConfiguration = null;
-   try {
-   clusterConfiguration = 
commandLineParser.parse(args);
-   } catch (FlinkParseException e) {
-   LOG.error("Could not parse command line 
arguments {}.", args, e);
-   
commandLineParser.printHelp(YarnTaskExecutorRunner.class.getSimpleName());
-   System.exit(1);
 
 Review comment:
   Or we can further reuse `TaskManagerRunner#runTaskManagerSecurely` instead?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] zhijiangW commented on a change in pull request #9985: [FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.

2019-12-02 Thread GitBox
zhijiangW commented on a change in pull request #9985: 
[FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.
URL: https://github.com/apache/flink/pull/9985#discussion_r352972835
 
 

 ##
 File path: 
flink-yarn/src/main/java/org/apache/flink/yarn/YarnTaskExecutorRunner.java
 ##
 @@ -97,22 +91,7 @@ private static void run(String[] args) {
final String currDir = ENV.get(Environment.PWD.key());
LOG.info("Current working Directory: {}", currDir);
 
-  // Some dynamic properties for task manager are added to args, such as 
managed memory size.
-   final CommandLineParser 
commandLineParser =
-   new CommandLineParser<>(new 
ClusterConfigurationParserFactory());
-
-   ClusterConfiguration clusterConfiguration = null;
-   try {
-   clusterConfiguration = 
commandLineParser.parse(args);
-   } catch (FlinkParseException e) {
-   LOG.error("Could not parse command line 
arguments {}.", args, e);
-   
commandLineParser.printHelp(YarnTaskExecutorRunner.class.getSimpleName());
-   System.exit(1);
 
 Review comment:
   It seems we changed the behavior here. The `System.exit(1)` is replaced by 
throwing exception after reusing `TaskManagerRunner.loadConfiguration` below. 
   Another option is catching `TaskManagerRunner.loadConfiguration` to exit as 
previous way.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] zhijiangW commented on a change in pull request #9985: [FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.

2019-12-02 Thread GitBox
zhijiangW commented on a change in pull request #9985: 
[FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.
URL: https://github.com/apache/flink/pull/9985#discussion_r352971963
 
 

 ##
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunner.java
 ##
 @@ -331,6 +311,25 @@ public static void runTaskManager(Configuration 
configuration, ResourceID resour
taskManagerRunner.start();
}
 
+   public static void runTaskManagerSecurely(String[] args, ResourceID 
resourceID) {
+   try {
+   final Configuration configuration = 
loadConfiguration(args);
+
+   FileSystem.initialize(configuration, 
PluginUtils.createPluginManagerFromRootFolder(configuration));
+
+   SecurityUtils.install(new 
SecurityConfiguration(configuration));
+
+   
SecurityUtils.getInstalledContext().runSecured((Callable) () -> {
 
 Review comment:
   nit: can remove `(Callable)` I guess


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] zhijiangW commented on a change in pull request #9985: [FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.

2019-12-01 Thread GitBox
zhijiangW commented on a change in pull request #9985: 
[FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.
URL: https://github.com/apache/flink/pull/9985#discussion_r352451266
 
 

 ##
 File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/taskmanager/KubernetesTaskExecutorRunner.java
 ##
 @@ -0,0 +1,79 @@
+/*
+ * 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.taskmanager;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.ConfigurationUtils;
+import org.apache.flink.configuration.GlobalConfiguration;
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.plugin.PluginUtils;
+import org.apache.flink.kubernetes.KubernetesResourceManager;
+import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.entrypoint.ClusterConfiguration;
+import org.apache.flink.runtime.entrypoint.ClusterConfigurationParserFactory;
+import org.apache.flink.runtime.entrypoint.FlinkParseException;
+import org.apache.flink.runtime.entrypoint.parser.CommandLineParser;
+import org.apache.flink.runtime.taskexecutor.TaskManagerRunner;
+import org.apache.flink.runtime.util.EnvironmentInformation;
+import org.apache.flink.runtime.util.JvmShutdownSafeguard;
+import org.apache.flink.runtime.util.SignalHandler;
+import org.apache.flink.util.Preconditions;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is the executable entry point for running a TaskExecutor in a 
Kubernetes pod.
+ */
+public class KubernetesTaskExecutorRunner {
+
+   protected static final Logger LOG = 
LoggerFactory.getLogger(KubernetesTaskExecutorRunner.class);
+
+   public static void main(String[] args) throws Exception {
+   EnvironmentInformation.logEnvironmentInfo(LOG, "Kubernetes 
TaskExecutor runner", args);
+   SignalHandler.register(LOG);
+   JvmShutdownSafeguard.installAsShutdownHook(LOG);
+
+   // Some config options for task manager are added to args, such 
as managed memory size.
+   final CommandLineParser commandLineParser 
=
+   new CommandLineParser<>(new 
ClusterConfigurationParserFactory());
+
+   ClusterConfiguration clusterConfiguration = null;
+   try {
+   clusterConfiguration = commandLineParser.parse(args);
+   } catch (FlinkParseException e) {
+   LOG.error("Could not parse command line arguments {}.", 
args, e);
+   
commandLineParser.printHelp(KubernetesTaskExecutorRunner.class.getSimpleName());
+   System.exit(1);
+   }
+
+   final Configuration dynamicProperties = 
ConfigurationUtils.createConfiguration(
+   clusterConfiguration.getDynamicProperties());
+   final Configuration configuration = 
GlobalConfiguration.loadConfiguration(
+   clusterConfiguration.getConfigDir(), dynamicProperties);
+
+   FileSystem.initialize(configuration, 
PluginUtils.createPluginManagerFromRootFolder(configuration));
+
+   final String resourceID = 
System.getenv().get(KubernetesResourceManager.ENV_RESOURCE_ID);
 
 Review comment:
   Thanks for the explanation. That makes sense for me.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] zhijiangW commented on a change in pull request #9985: [FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.

2019-12-01 Thread GitBox
zhijiangW commented on a change in pull request #9985: 
[FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.
URL: https://github.com/apache/flink/pull/9985#discussion_r352450855
 
 

 ##
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskManagerRunner.java
 ##
 @@ -286,29 +285,10 @@ public static void main(String[] args) throws Exception {
LOG.info("Cannot determine the maximum number of open 
file descriptors");
}
 
-   final Configuration configuration = loadConfiguration(args);
-
-   FileSystem.initialize(configuration, 
PluginUtils.createPluginManagerFromRootFolder(configuration));
-
-   SecurityUtils.install(new SecurityConfiguration(configuration));
-
-   try {
-   SecurityUtils.getInstalledContext().runSecured(new 
Callable() {
-   @Override
-   public Void call() throws Exception {
-   runTaskManager(configuration, 
ResourceID.generate());
-   return null;
-   }
-   });
-   } catch (Throwable t) {
-   final Throwable strippedThrowable = 
ExceptionUtils.stripException(t, UndeclaredThrowableException.class);
-   LOG.error("TaskManager initialization failed.", 
strippedThrowable);
-   System.exit(STARTUP_FAILURE_RETURN_CODE);
-   }
+   runTaskManagerSecurely(args, ResourceID.generate());
}
 
-   @VisibleForTesting
-   static Configuration loadConfiguration(String[] args) throws 
FlinkParseException {
+   public static Configuration loadConfiguration(String[] args) throws 
FlinkParseException {
 
 Review comment:
   This change should be put together with another commit "[hotfix][yarn] Use 
public methods of TaskManagerRunner to simply YarnTaskExecutorRunner codes", 
because it is actually required by that commit, not the scope of this commit.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [flink] zhijiangW commented on a change in pull request #9985: [FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.

2019-11-29 Thread GitBox
zhijiangW commented on a change in pull request #9985: 
[FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.
URL: https://github.com/apache/flink/pull/9985#discussion_r352034574
 
 

 ##
 File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/taskmanager/KubernetesTaskExecutorRunner.java
 ##
 @@ -0,0 +1,79 @@
+/*
+ * 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.taskmanager;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.ConfigurationUtils;
+import org.apache.flink.configuration.GlobalConfiguration;
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.plugin.PluginUtils;
+import org.apache.flink.kubernetes.KubernetesResourceManager;
+import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.entrypoint.ClusterConfiguration;
+import org.apache.flink.runtime.entrypoint.ClusterConfigurationParserFactory;
+import org.apache.flink.runtime.entrypoint.FlinkParseException;
+import org.apache.flink.runtime.entrypoint.parser.CommandLineParser;
+import org.apache.flink.runtime.taskexecutor.TaskManagerRunner;
+import org.apache.flink.runtime.util.EnvironmentInformation;
+import org.apache.flink.runtime.util.JvmShutdownSafeguard;
+import org.apache.flink.runtime.util.SignalHandler;
+import org.apache.flink.util.Preconditions;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is the executable entry point for running a TaskExecutor in a 
Kubernetes pod.
+ */
+public class KubernetesTaskExecutorRunner {
+
+   protected static final Logger LOG = 
LoggerFactory.getLogger(KubernetesTaskExecutorRunner.class);
+
+   public static void main(String[] args) throws Exception {
+   EnvironmentInformation.logEnvironmentInfo(LOG, "Kubernetes 
TaskExecutor runner", args);
+   SignalHandler.register(LOG);
+   JvmShutdownSafeguard.installAsShutdownHook(LOG);
+
+   // Some config options for task manager are added to args, such 
as managed memory size.
+   final CommandLineParser commandLineParser 
=
+   new CommandLineParser<>(new 
ClusterConfigurationParserFactory());
+
+   ClusterConfiguration clusterConfiguration = null;
+   try {
+   clusterConfiguration = commandLineParser.parse(args);
+   } catch (FlinkParseException e) {
+   LOG.error("Could not parse command line arguments {}.", 
args, e);
+   
commandLineParser.printHelp(KubernetesTaskExecutorRunner.class.getSimpleName());
+   System.exit(1);
+   }
+
+   final Configuration dynamicProperties = 
ConfigurationUtils.createConfiguration(
+   clusterConfiguration.getDynamicProperties());
+   final Configuration configuration = 
GlobalConfiguration.loadConfiguration(
+   clusterConfiguration.getConfigDir(), dynamicProperties);
+
+   FileSystem.initialize(configuration, 
PluginUtils.createPluginManagerFromRootFolder(configuration));
+
+   final String resourceID = 
System.getenv().get(KubernetesResourceManager.ENV_RESOURCE_ID);
+   Preconditions.checkArgument(resourceID != null,
+   "Resource ID variable %s not set", 
KubernetesResourceManager.ENV_RESOURCE_ID);
+
+   TaskManagerRunner.runTaskManager(configuration, new 
ResourceID(resourceID));
 
 Review comment:
   Compared with the behavior in  `YarnTaskExecutorRunner`,  it would catch the 
exception to log and exit directly. 
   
   I am curious that are there any considerations for throwing exceptions to 
upper layer and what is the expected behavior for handling exceptions from the 
upper layer? 


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:

[GitHub] [flink] zhijiangW commented on a change in pull request #9985: [FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.

2019-11-29 Thread GitBox
zhijiangW commented on a change in pull request #9985: 
[FLINK-10968][kubernetes] Implement TaskManager Entrypoint for Kubernetes.
URL: https://github.com/apache/flink/pull/9985#discussion_r352033597
 
 

 ##
 File path: 
flink-kubernetes/src/main/java/org/apache/flink/kubernetes/taskmanager/KubernetesTaskExecutorRunner.java
 ##
 @@ -0,0 +1,79 @@
+/*
+ * 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.taskmanager;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.ConfigurationUtils;
+import org.apache.flink.configuration.GlobalConfiguration;
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.plugin.PluginUtils;
+import org.apache.flink.kubernetes.KubernetesResourceManager;
+import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.entrypoint.ClusterConfiguration;
+import org.apache.flink.runtime.entrypoint.ClusterConfigurationParserFactory;
+import org.apache.flink.runtime.entrypoint.FlinkParseException;
+import org.apache.flink.runtime.entrypoint.parser.CommandLineParser;
+import org.apache.flink.runtime.taskexecutor.TaskManagerRunner;
+import org.apache.flink.runtime.util.EnvironmentInformation;
+import org.apache.flink.runtime.util.JvmShutdownSafeguard;
+import org.apache.flink.runtime.util.SignalHandler;
+import org.apache.flink.util.Preconditions;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is the executable entry point for running a TaskExecutor in a 
Kubernetes pod.
+ */
+public class KubernetesTaskExecutorRunner {
+
+   protected static final Logger LOG = 
LoggerFactory.getLogger(KubernetesTaskExecutorRunner.class);
+
+   public static void main(String[] args) throws Exception {
+   EnvironmentInformation.logEnvironmentInfo(LOG, "Kubernetes 
TaskExecutor runner", args);
+   SignalHandler.register(LOG);
+   JvmShutdownSafeguard.installAsShutdownHook(LOG);
+
+   // Some config options for task manager are added to args, such 
as managed memory size.
+   final CommandLineParser commandLineParser 
=
+   new CommandLineParser<>(new 
ClusterConfigurationParserFactory());
+
+   ClusterConfiguration clusterConfiguration = null;
+   try {
+   clusterConfiguration = commandLineParser.parse(args);
+   } catch (FlinkParseException e) {
+   LOG.error("Could not parse command line arguments {}.", 
args, e);
+   
commandLineParser.printHelp(KubernetesTaskExecutorRunner.class.getSimpleName());
+   System.exit(1);
+   }
+
+   final Configuration dynamicProperties = 
ConfigurationUtils.createConfiguration(
+   clusterConfiguration.getDynamicProperties());
+   final Configuration configuration = 
GlobalConfiguration.loadConfiguration(
+   clusterConfiguration.getConfigDir(), dynamicProperties);
+
+   FileSystem.initialize(configuration, 
PluginUtils.createPluginManagerFromRootFolder(configuration));
+
+   final String resourceID = 
System.getenv().get(KubernetesResourceManager.ENV_RESOURCE_ID);
 
 Review comment:
   nit: It might be better to introduce 
`ResourceManagerOptions#ENV_FLINK_CONTAINER_ID`, then the 
`KubernetesTaskExecutorRunner` and previous `YarnTaskExecutorRunner` can both 
reference it.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services