1

I need to patch or change the node condition status, any idea how to do that using go lang "k8s client" ?

Edit: I can see that inside the Node interface there is patch, not sure about the usage, documentation lacks info about data should be sent, how to know what kind of data

Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Node, err error)

Link: Nodes Interface Nodes Interface

Edit2: I am running below and am not getting any errors but yet it's not adding or patching the node condition.

Payload := `{ "op": "replace", "path": "/status/conditions/12","value": { "type": "QuayStateSmelik", "status": "False" }}`
bytePayload := []byte(Payload)

Then run:

node, err := clientset.CoreV1().Nodes().Patch(context.TODO(), "NodeName", types.StrategicMergePatchType, bytePayload, metav1.PatchOptions{})
Sam
  • 345
  • 3
  • 14

1 Answers1

0

As per this Kubernetes Client issue on GitHub you need to add "status" as a subresource parameter, for example:

node, err := clientset.CoreV1().Nodes().Patch(context.TODO(), "<Node-Name>", types.JSONPatchType, bytesPayloadTT, metav1.PatchOptions{}, "status")
Darren Hague
  • 948
  • 2
  • 8
  • 8