如何通过Kubernetes api将节点设置为不可调度状态?

时间:2016-03-08 17:03:21

标签: kubernetes

我试图模仿function Base() { this.type = "base"; } Base.prototype = { clone: function () { var c = new this.constructor(); // let clone initialize itself from the original c.init(this); return c; }, setName: function(name) { this.name = name; }, init: function(obj) { // copy over name instance data this.name = obj.name; } } // set .constructor property for use with .clone() Base.prototype.constructor = Base; function Derived() { Base.call(this); this.type = "derived"; } // inherit from Base Derived.prototype = Object.create(Base.prototype); Derived.prototype.setOccupation = function(occupation) { this.occupation = occupation; } Derived.prototype.init = function(obj) { // let base object init itself Base.prototype.init.call(this, obj); // copy over our own instance data this.occupation = obj.occupation; } // set .constructor property for use with .clone() Derived.prototype.constructor = Derived; var x = new Derived(); x.setName("Bob"); x.setOccupation("Engineer"); var xx = x.clone(); var y = new Base(); y.setName("Alice"); var yy = y.clone(); log(x !== xx) log(x); log(xx); log(y); log(yy) // function just for output in snippet function log(a) { var div = document.createElement("div"); if (typeof a === "object") { a = JSON.stringify(a); } div.innerHTML = a; document.body.appendChild(div); }的行为。我正在发送一个带有以下json有效负载的HTTP PATCH:

kubectl patch

然而,无论我如何调整这个JSON,我都会继续获得415和以下JSON状态:

{
    "apiVersion": "v1",
    "kind": "Node",
    "metadata": {
        "name": "my-node-hostname"
    },
    "spec": {
        "unschedulable": true
    }
}

即使将kube-apiserver上的调试设置为1000,我也没有得到有关有效负载错误原因的反馈!

是否应该在通过PATCH发送的JSON有效负载中使用特定格式以使其能够正常工作?

1 个答案:

答案 0 :(得分:2)

在提到Kubernetes Slack频道的有用成员后,我可以通过--verbose标志从kubectl patch获取有效负载,结果发现Kubernetes希望在发送PATCH时获得"Content-Type: application/strategic-merge-patch+json"有效载荷。