mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
zeppelin.k8s.mode -> zeppelin.run.mode
This commit is contained in:
parent
4e7d8170d0
commit
423412a938
5 changed files with 26 additions and 13 deletions
|
|
@ -586,9 +586,9 @@
|
|||
-->
|
||||
|
||||
<property>
|
||||
<name>zeppelin.k8s.mode</name>
|
||||
<name>zeppelin.run.mode</name>
|
||||
<value>auto</value>
|
||||
<description>Run interpreters on Kubernetes. 'auto|on|off'</description>
|
||||
<description>'auto|local|k8s'</description>
|
||||
</configuration>
|
||||
|
||||
<property>
|
||||
|
|
|
|||
|
|
@ -366,10 +366,10 @@ If both are defined, then the **environment variables** will take priority.
|
|||
<td>GitHub remote name. Default is `origin`</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><h6 class="properties">ZEPPELIN_K8S_MODE</h6></td>
|
||||
<td><h6 class="properties">zeppelin.k8s.mode</h6></td>
|
||||
<td><h6 class="properties">ZEPPELIN_RUN_MODE</h6></td>
|
||||
<td><h6 class="properties">zeppelin.run.mode</h6></td>
|
||||
<td>auto</td>
|
||||
<td>Run interpreters on Kubernetes. 'auto|on|off'. 'auto' autodetect environment. 'on' is useful for developer while it allows run Zeppelin server on your IDE and Interpreter on Kubernetes cluster</td>
|
||||
<td>Run mode. 'auto|local|k8s'. 'auto' autodetect environment. 'local' runs interpreter as a local process. k8s runs interpreter on Kubernetes cluster</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><h6 class="properties">ZEPPELIN_K8S_PORTFORWARD</h6></td>
|
||||
|
|
|
|||
|
|
@ -48,6 +48,11 @@ public class ZeppelinConfiguration extends XMLConfiguration {
|
|||
|
||||
private Map<String, String> properties = new HashMap<>();
|
||||
|
||||
public enum RUN_MODE {
|
||||
LOCAL,
|
||||
K8S
|
||||
}
|
||||
|
||||
public ZeppelinConfiguration(URL url) throws ConfigurationException {
|
||||
setDelimiterParsingDisabled(true);
|
||||
load(url);
|
||||
|
|
@ -665,8 +670,17 @@ public class ZeppelinConfiguration extends XMLConfiguration {
|
|||
return getInt(ConfVars.ZEPPELIN_CLUSTER_HEARTBEAT_TIMEOUT);
|
||||
}
|
||||
|
||||
public String getK8sMode() {
|
||||
return getString(ConfVars.ZEPPELIN_K8S_MODE);
|
||||
public RUN_MODE getRunMode() {
|
||||
String mode = getString(ConfVars.ZEPPELIN_RUN_MODE);
|
||||
if ("auto".equalsIgnoreCase(mode)) { // auto detect
|
||||
if (new File("/var/run/secrets/kubernetes.io").exists()) {
|
||||
return RUN_MODE.K8S;
|
||||
} else {
|
||||
return RUN_MODE.LOCAL;
|
||||
}
|
||||
} else {
|
||||
return RUN_MODE.valueOf(mode.toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getK8sPortForward() {
|
||||
|
|
@ -840,7 +854,8 @@ public class ZeppelinConfiguration extends XMLConfiguration {
|
|||
ZEPPELIN_CLUSTER_HEARTBEAT_INTERVAL("zeppelin.cluster.heartbeat.interval", 3000),
|
||||
ZEPPELIN_CLUSTER_HEARTBEAT_TIMEOUT("zeppelin.cluster.heartbeat.timeout", 9000),
|
||||
|
||||
ZEPPELIN_K8S_MODE("zeppelin.k8s.mode", "auto"), // auto | on | off
|
||||
ZEPPELIN_RUN_MODE("zeppelin.run.mode", "auto"), // auto | local | k8s
|
||||
|
||||
ZEPPELIN_K8S_PORTFORWARD("zeppelin.k8s.portforward", false), // kubectl port-forward incase of Zeppelin is running outside of kuberentes
|
||||
ZEPPELIN_K8S_KUBECTL("zeppelin.k8s.kubectl", "kubectl"), // kubectl command
|
||||
ZEPPELIN_K8S_CONTAINER_IMAGE("zeppelin.k8s.container.image", "apache/zeppelin:" + Util.getVersion()),
|
||||
|
|
|
|||
|
|
@ -60,10 +60,10 @@ public class K8sStandardInterpreterLauncher extends InterpreterLauncher {
|
|||
|
||||
/**
|
||||
* Check if i'm running inside of kubernetes or not.
|
||||
* It should return truth regardless of ZeppelinConfiguration.getK8sMode().
|
||||
* It should return truth regardless of ZeppelinConfiguration.getRunMode().
|
||||
*
|
||||
* Normally, unless Zeppelin is running on Kubernetes, K8sStandardInterpreterLauncher shouldn't even have initialized.
|
||||
* However, when ZeppelinConfiguration.getK8sMode() is force 'on', InterpreterSetting.getLauncherPlugin() will try
|
||||
* However, when ZeppelinConfiguration.getRunMode() is force 'k8s', InterpreterSetting.getLauncherPlugin() will try
|
||||
* to use K8sStandardInterpreterLauncher. This is useful for development. It allows Zeppelin server running on your
|
||||
* IDE and creates your interpreters in Kubernetes. So any code changes on Zeppelin server or kubernetes yaml spec
|
||||
* can be applied without re-building docker image.
|
||||
|
|
|
|||
|
|
@ -648,9 +648,7 @@ public class InterpreterSetting {
|
|||
}
|
||||
|
||||
private boolean isRunningOnKubernetes() {
|
||||
String mode = conf.getK8sMode();
|
||||
return ("auto".equalsIgnoreCase(mode) && new File("/var/run/secrets/kubernetes.io").exists())
|
||||
|| "on".equalsIgnoreCase(mode);
|
||||
return conf.getRunMode() == ZeppelinConfiguration.RUN_MODE.K8S;
|
||||
}
|
||||
|
||||
public boolean isUserAuthorized(List<String> userAndRoles) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue