Me: "I need to send resize events over the kubernetes tty websocket, what do I need to send"
ChatGPT: struct.pack(">BHH", 4, cols, rows)
Me: Weird this hangs, what am I doing wrong?
ChatGPT: insists that's the right format and starts wild goose chase
4 hours later
Me: I should just read the go code for the kubernetes client and see what it's doing.
Me: WTF. The kubernetes client sends the info in JSON
ChatGPT: That's because the v3 protocol sent in JSON, but v4 and v5 are definitely binary and use struct.pack
Me: Uh, the v4 and v5 clients just forward the message to the v3 code.
ChatGPT:
In
v4.channel.k8s.io, channel 4 is not binary-encoded height/width — it is still a JSON stream from the Go perspective.
Some clients (like older kubectl implementations) did use <BHH> binary format, especially before Go refactored the protocols.
The official Go implementation [as you saw in client-go/tools/remotecommand] sends resizes as JSON.
Yes, if you're using
v4.channel.k8s.io, then resize events must be JSON-encoded — even though the channel protocol looks binary.
This is true because the Go implementation behind it is literally using streamProtocolV3’s resize handler.
Me: Son of a...