client-go 是用 GoLang 编写的官方编程式交互客户端库,提供对 Kubernetes API Server 服务的交互访问,也是 Kubernetes 的核心处理框架,其源码中已经集成了 client-go 的源码,无需单独下载。
简介
K8S 提供的 client-go 包中包含了 k8s.io/client-go/tools/remotecommand 包用于与容器建立长连接,并设置容器的 stdin、stdout 等,提供了基于 SPDY 协议的 Executor 接口,用于和 pod 终端的流传输。
初始化一个 Executor 很简单,只需要调用 remotecommand 的 NewSPDYExecutor 并传入对应参数。