add portforwarding support to node/api (#1102)

Co-authored-by: Pablo Borrelli <pablo.borrelli0@gmail.com>
Co-authored-by: windyear <1280027646@qq.com>
This commit is contained in:
Salvatore Cirone
2023-06-16 03:45:10 +02:00
committed by GitHub
parent 8205ee2889
commit 59fd7fddb6
10 changed files with 1097 additions and 1 deletions

View File

@@ -36,6 +36,7 @@ type ServeMux interface {
type PodHandlerConfig struct { //nolint:golint
RunInContainer ContainerExecHandlerFunc
AttachToContainer ContainerAttachHandlerFunc
PortForward PortForwardHandlerFunc
GetContainerLogs ContainerLogsHandlerFunc
// GetPods is meant to enumerate the pods that the provider knows about
GetPods PodListerFunc
@@ -58,7 +59,6 @@ func PodHandler(p PodHandlerConfig, debug bool) http.Handler {
if debug {
r.HandleFunc("/runningpods/", HandleRunningPods(p.GetPods)).Methods("GET")
}
r.HandleFunc("/pods", HandleRunningPods(p.GetPodsFromKubernetes)).Methods("GET")
r.HandleFunc("/containerLogs/{namespace}/{pod}/{container}", HandleContainerLogs(p.GetContainerLogs)).Methods("GET")
r.HandleFunc(
@@ -77,6 +77,14 @@ func PodHandler(p PodHandlerConfig, debug bool) http.Handler {
WithExecStreamIdleTimeout(p.StreamIdleTimeout),
),
).Methods("POST", "GET")
r.HandleFunc(
"/portForward/{namespace}/{pod}",
HandlePortForward(
p.PortForward,
WithPortForwardStreamIdleTimeout(p.StreamCreationTimeout),
WithPortForwardCreationTimeout(p.StreamIdleTimeout),
),
).Methods("POST", "GET")
if p.GetStatsSummary != nil {
f := HandlePodStatsSummary(p.GetStatsSummary)