<p>I want to use golang Kubernetes client SDK to cordon specific nodes in my Kubernetes cluster.</p>
<p>According to other posts, I need to pass the following:</p>
<pre><code>PATCH /api/v1/nodes/node-name

Request Body: {&quot;spec&quot;:{&quot;unschedulable&quot;:true}} Content-Type: &quot;application/strategic-merge-patch+json&quot;
</code></pre>
<p>However, I am not familiar with how to pass that.</p>
<p>I have the following, but not sure if those values are correct</p>
<pre><code>type patchStringValue struct {
    Op    string `json:&quot;op&quot;`
    Path  string `json:&quot;path&quot;`
    Value string `json:&quot;value&quot;`
}

func k8NodeCordon() {
    clientSet := k8ClientInit()

    payload := []patchStringValue{{
        Op:    &quot;replace&quot;,
        Path:  &quot;/spec/unschedulable&quot;,
        Value: &quot;true&quot;,
    }}
    payloadBytes, _ := json.Marshal(payload)
    _, err := clientSet.
        CoreV1().Nodes().Patch()
    return err
}
</code></pre>

popopanda
<pre><code>type patchStringValue struct {
    Op    string `json:&quot;op&quot;`
    Path  string `json:&quot;path&quot;`
    Value bool   `json:&quot;value&quot;`
}

func k8NodeCordon() {
    clientSet := k8ClientInit()

    payload := []patchStringValue{{
        Op:    &quot;replace&quot;,
        Path:  &quot;/spec/unschedulable&quot;,
        Value: true,
    }}
    payloadBytes, _ := json.Marshal(payload)
    _, err := clientSet.CoreV1().Nodes().Patch(&quot;&lt;node_name&gt;&quot;, types.JSONPatchType, payloadBytes)
    return err
}
</code></pre>
