Add support for Attach API functionality (#1090)

Co-authored-by: Pablo Borrelli <pablo.borrelli0@gmail.com>
This commit is contained in:
Salvatore Cirone
2023-03-31 17:51:50 +02:00
committed by GitHub
parent b7030b9dc5
commit 9c32bfb0ae
5 changed files with 244 additions and 5 deletions

View File

@@ -34,8 +34,9 @@ type ServeMux interface {
}
type PodHandlerConfig struct { //nolint:golint
RunInContainer ContainerExecHandlerFunc
GetContainerLogs ContainerLogsHandlerFunc
RunInContainer ContainerExecHandlerFunc
AttachToContainer ContainerAttachHandlerFunc
GetContainerLogs ContainerLogsHandlerFunc
// GetPods is meant to enumerate the pods that the provider knows about
GetPods PodListerFunc
// GetPodsFromKubernetes is meant to enumerate the pods that the node is meant to be running
@@ -68,6 +69,14 @@ func PodHandler(p PodHandlerConfig, debug bool) http.Handler {
WithExecStreamIdleTimeout(p.StreamIdleTimeout),
),
).Methods("POST", "GET")
r.HandleFunc(
"/attach/{namespace}/{pod}/{container}",
HandleContainerAttach(
p.AttachToContainer,
WithExecStreamCreationTimeout(p.StreamCreationTimeout),
WithExecStreamIdleTimeout(p.StreamIdleTimeout),
),
).Methods("POST", "GET")
if p.GetStatsSummary != nil {
f := HandlePodStatsSummary(p.GetStatsSummary)