@@ -4,10 +4,12 @@ import (
4
4
"context"
5
5
"encoding/json"
6
6
"errors"
7
+ "flag"
7
8
"fmt"
8
9
"log/slog"
9
10
"os"
10
11
"os/signal"
12
+ "strconv"
11
13
"strings"
12
14
"time"
13
15
@@ -21,6 +23,7 @@ import (
21
23
"k8s.io/client-go/kubernetes/scheme"
22
24
_ "k8s.io/client-go/plugin/pkg/client/auth"
23
25
"k8s.io/client-go/rest"
26
+ "k8s.io/klog/v2"
24
27
25
28
"github.com/knight42/krelay/pkg/constants"
26
29
"github.com/knight42/krelay/pkg/ports"
@@ -296,11 +299,17 @@ func main() {
296
299
}
297
300
printVersion := false
298
301
302
+ fs := flag .NewFlagSet ("klog" , flag .ExitOnError )
303
+ klog .InitFlags (fs )
304
+
299
305
c := cobra.Command {
300
306
Use : fmt .Sprintf (`%s TYPE/NAME [options] [LOCAL_PORT:]REMOTE_PORT[@PROTOCOL] [...[LOCAL_PORT_N:]REMOTE_PORT_N[@PROTOCOL_N]]` , getProgramName ()),
301
307
Example : example (),
302
308
Long : `This command is similar to "kubectl port-forward", but it also supports UDP and could forward data to a
303
- service, ip and hostname rather than only pods.` ,
309
+ service, ip and hostname rather than only pods.
310
+
311
+ Starting from version v0.1.2, it attempts to tunnel SPDY through websocket, in line with how "kubectl port-forward" works.
312
+ This behavior can be disabled by setting the environment variable "KUBECTL_PORT_FORWARD_WEBSOCKETS" to "false".` ,
304
313
RunE : func (cmd * cobra.Command , args []string ) error {
305
314
if printVersion {
306
315
return json .NewEncoder (cmd .OutOrStdout ()).Encode (struct {
@@ -314,6 +323,7 @@ service, ip and hostname rather than only pods.`,
314
323
})
315
324
}
316
325
326
+ _ = fs .Set ("v" , strconv .Itoa (o .verbosity ))
317
327
slog .SetLogLoggerLevel (slogutil .MapVerbosityToLogLevel (o .verbosity ))
318
328
ctx , cancel := signal .NotifyContext (context .Background (), os .Interrupt )
319
329
defer cancel ()
0 commit comments