@@ -35,12 +35,12 @@ import (
35
35
"github.com/spf13/pflag"
36
36
"google.golang.org/grpc"
37
37
"google.golang.org/grpc/credentials"
38
- "k8s.io/klog"
39
38
"k8s.io/client-go/kubernetes"
40
39
"k8s.io/client-go/tools/clientcmd"
41
- "sigs.k8s.io/apiserver-network-proxy/pkg/agent/agentserver"
42
- "sigs.k8s.io/apiserver-network-proxy/pkg/util"
40
+ "k8s.io/klog"
43
41
"sigs.k8s.io/apiserver-network-proxy/konnectivity-client/proto/client"
42
+ "sigs.k8s.io/apiserver-network-proxy/pkg/server"
43
+ "sigs.k8s.io/apiserver-network-proxy/pkg/util"
44
44
"sigs.k8s.io/apiserver-network-proxy/proto/agent"
45
45
)
46
46
@@ -304,14 +304,14 @@ func (p *Proxy) run(o *ProxyRunOptions) error {
304
304
}
305
305
}
306
306
307
- authOpt := & agentserver .AgentTokenAuthenticationOptions {
307
+ authOpt := & server .AgentTokenAuthenticationOptions {
308
308
Enabled : o .agentNamespace != "" ,
309
309
AgentNamespace : o .agentNamespace ,
310
310
AgentServiceAccount : o .agentServiceAccount ,
311
311
KubernetesClient : k8sClient ,
312
312
AuthenticationAudience : o .authenticationAudience ,
313
313
}
314
- server := agentserver .NewProxyServer (o .serverID , int (o .serverCount ), authOpt )
314
+ server := server .NewProxyServer (o .serverID , int (o .serverCount ), authOpt )
315
315
316
316
klog .Info ("Starting master server for client connections." )
317
317
masterStop , err := p .runMasterServer (ctx , o , server )
@@ -358,18 +358,18 @@ func SetupSignalHandler() (stopCh <-chan struct{}) {
358
358
return stop
359
359
}
360
360
361
- func (p * Proxy ) runMasterServer (ctx context.Context , o * ProxyRunOptions , server * agentserver .ProxyServer ) (StopFunc , error ) {
361
+ func (p * Proxy ) runMasterServer (ctx context.Context , o * ProxyRunOptions , server * server .ProxyServer ) (StopFunc , error ) {
362
362
if o .udsName != "" {
363
363
return p .runUDSMasterServer (ctx , o , server )
364
364
}
365
365
return p .runMTLSMasterServer (ctx , o , server )
366
366
}
367
367
368
- func (p * Proxy ) runUDSMasterServer (ctx context.Context , o * ProxyRunOptions , server * agentserver .ProxyServer ) (StopFunc , error ) {
368
+ func (p * Proxy ) runUDSMasterServer (ctx context.Context , o * ProxyRunOptions , s * server .ProxyServer ) (StopFunc , error ) {
369
369
var stop StopFunc
370
370
if o .mode == "grpc" {
371
371
grpcServer := grpc .NewServer ()
372
- client .RegisterProxyServiceServer (grpcServer , server )
372
+ client .RegisterProxyServiceServer (grpcServer , s )
373
373
var lc net.ListenConfig
374
374
lis , err := lc .Listen (ctx , "unix" , o .udsName )
375
375
if err != nil {
@@ -380,8 +380,8 @@ func (p *Proxy) runUDSMasterServer(ctx context.Context, o *ProxyRunOptions, serv
380
380
} else {
381
381
// http-connect
382
382
server := & http.Server {
383
- Handler : & agentserver .Tunnel {
384
- Server : server ,
383
+ Handler : & server .Tunnel {
384
+ Server : s ,
385
385
},
386
386
}
387
387
stop = func () { server .Shutdown (ctx ) }
@@ -432,7 +432,7 @@ func (p *Proxy) getTLSConfig(caFile, certFile, keyFile string) (*tls.Config, err
432
432
return tlsConfig , nil
433
433
}
434
434
435
- func (p * Proxy ) runMTLSMasterServer (ctx context.Context , o * ProxyRunOptions , server * agentserver .ProxyServer ) (StopFunc , error ) {
435
+ func (p * Proxy ) runMTLSMasterServer (ctx context.Context , o * ProxyRunOptions , s * server .ProxyServer ) (StopFunc , error ) {
436
436
var stop StopFunc
437
437
438
438
var tlsConfig * tls.Config
@@ -446,7 +446,7 @@ func (p *Proxy) runMTLSMasterServer(ctx context.Context, o *ProxyRunOptions, ser
446
446
if o .mode == "grpc" {
447
447
serverOption := grpc .Creds (credentials .NewTLS (tlsConfig ))
448
448
grpcServer := grpc .NewServer (serverOption )
449
- client .RegisterProxyServiceServer (grpcServer , server )
449
+ client .RegisterProxyServiceServer (grpcServer , s )
450
450
lis , err := net .Listen ("tcp" , addr )
451
451
if err != nil {
452
452
return nil , fmt .Errorf ("failed to listen on %s: %v" , addr , err )
@@ -458,8 +458,8 @@ func (p *Proxy) runMTLSMasterServer(ctx context.Context, o *ProxyRunOptions, ser
458
458
server := & http.Server {
459
459
Addr : addr ,
460
460
TLSConfig : tlsConfig ,
461
- Handler : & agentserver .Tunnel {
462
- Server : server ,
461
+ Handler : & server .Tunnel {
462
+ Server : s ,
463
463
},
464
464
TLSNextProto : make (map [string ]func (* http.Server , * tls.Conn , http.Handler )),
465
465
}
@@ -475,7 +475,7 @@ func (p *Proxy) runMTLSMasterServer(ctx context.Context, o *ProxyRunOptions, ser
475
475
return stop , nil
476
476
}
477
477
478
- func (p * Proxy ) runAgentServer (o * ProxyRunOptions , server * agentserver .ProxyServer ) error {
478
+ func (p * Proxy ) runAgentServer (o * ProxyRunOptions , server * server .ProxyServer ) error {
479
479
var tlsConfig * tls.Config
480
480
var err error
481
481
if tlsConfig , err = p .getTLSConfig (o .clusterCaCert , o .clusterCert , o .clusterKey ); err != nil {
@@ -495,7 +495,7 @@ func (p *Proxy) runAgentServer(o *ProxyRunOptions, server *agentserver.ProxyServ
495
495
return nil
496
496
}
497
497
498
- func (p * Proxy ) runAdminServer (o * ProxyRunOptions , server * agentserver .ProxyServer ) error {
498
+ func (p * Proxy ) runAdminServer (o * ProxyRunOptions , server * server .ProxyServer ) error {
499
499
livenessHandler := http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
500
500
fmt .Fprintf (w , "ok" )
501
501
})
0 commit comments