--oom-score-adj=-999
kubelet
命令的 docker run --oom-kill-disable
似乎不起作用。从现在开始,我发现只有import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import java.io.FileReader;
public class Test {
private ScriptEngine se;
// Constructor, sets up React and the Component
public Test() throws Throwable {
ScriptEngineManager sem = new ScriptEngineManager();
se = sem.getEngineByName("nashorn");
// React depends on the "global" variable
se.eval("var global = this");
// eval react.js
se.eval(new FileReader("../react-0.14.7/build/react.js"));
// This would also be an external JS file
String component =
"var MyComponent = React.createClass({" +
" render: function() {" +
" return React.DOM.div(null, this.props.text)" +
" }" +
"});";
se.eval(component);
}
// Render the component, which can be called multiple times
public void render(String text) throws Throwable {
String render =
"React.renderToString(React.createFactory(MyComponent)({" +
// using JSONObject here would be cleaner obviously
" text: '" + text + "'" +
"}))";
System.out.println(se.eval(render));
}
public static void main(String... args) throws Throwable {
Test test = new Test();
test.render("I want to Display");
test.render("This on a Browser like google chrome, using Tomcat server with Eclipse, currently it displays on Console in Eclipse.");
}
}
可以正常工作以避免被oom杀死的容器。
那么有没有办法模仿kubernetes中的这个选项?通过环境变量?
答案 0 :(得分:1)
请参阅 https://github.com/kubernetes/community/blob/master/contributors/design-proposals/node/resource-qos.md (尽管在“提案”目录中,所描述的内容已实施)
简短的回答是,不可能在容器上强制使用--oom-score-adj = -999,但设置“limit”和“request”相等可确保系统在尝试时不会轻易杀死容器有OOM(像kubelet这样的关键Kubernetes流程会有更好的oom分数,但没有用户容器会有更好的OOM分数。)