@@ -22,6 +22,7 @@ import (
22
22
v1 "k8s.io/api/core/v1"
23
23
policy "k8s.io/api/policy/v1beta1"
24
24
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
25
+ "k8s.io/apimachinery/pkg/util/net"
25
26
"k8s.io/client-go/kubernetes/scheme"
26
27
restclient "k8s.io/client-go/rest"
27
28
)
@@ -31,6 +32,7 @@ type PodExpansion interface {
31
32
Bind (ctx context.Context , binding * v1.Binding , opts metav1.CreateOptions ) error
32
33
Evict (ctx context.Context , eviction * policy.Eviction ) error
33
34
GetLogs (name string , opts * v1.PodLogOptions ) * restclient.Request
35
+ ProxyGet (scheme , name , port , path string , params map [string ]string ) restclient.ResponseWrapper
34
36
}
35
37
36
38
// Bind applies the provided binding to the named pod in the current namespace (binding.Namespace is ignored).
@@ -46,3 +48,17 @@ func (c *pods) Evict(ctx context.Context, eviction *policy.Eviction) error {
46
48
func (c * pods ) GetLogs (name string , opts * v1.PodLogOptions ) * restclient.Request {
47
49
return c .client .Get ().Namespace (c .ns ).Name (name ).Resource ("pods" ).SubResource ("log" ).VersionedParams (opts , scheme .ParameterCodec )
48
50
}
51
+
52
+ // ProxyGet returns a response of the pod by calling it through the proxy.
53
+ func (c * pods ) ProxyGet (scheme , name , port , path string , params map [string ]string ) restclient.ResponseWrapper {
54
+ request := c .client .Get ().
55
+ Namespace (c .ns ).
56
+ Resource ("pods" ).
57
+ SubResource ("proxy" ).
58
+ Name (net .JoinSchemeNamePort (scheme , name , port )).
59
+ Suffix (path )
60
+ for k , v := range params {
61
+ request = request .Param (k , v )
62
+ }
63
+ return request
64
+ }
0 commit comments