@@ -24,13 +24,13 @@ import (
24
24
25
25
"k8s.io/apimachinery/pkg/runtime"
26
26
"k8s.io/apiserver/pkg/reconcilers"
27
+ "k8s.io/client-go/rest"
28
+ "k8s.io/client-go/transport"
29
+
27
30
genericapiserver "k8s.io/apiserver/pkg/server"
28
31
serverstorage "k8s.io/apiserver/pkg/server/storage"
29
- "k8s.io/apiserver/pkg/storageversion"
30
32
utilpeerproxy "k8s.io/apiserver/pkg/util/peerproxy"
31
- clientgoinformers "k8s.io/client-go/informers"
32
- "k8s.io/client-go/transport"
33
- "k8s.io/klog/v2"
33
+ coordinationv1informers "k8s.io/client-go/informers/coordination/v1"
34
34
api "k8s.io/kubernetes/pkg/apis/core"
35
35
)
36
36
@@ -43,17 +43,24 @@ const (
43
43
DefaultPeerEndpointReconcilerTTL = 15 * time .Second
44
44
)
45
45
46
- func BuildPeerProxy (versionedInformer clientgoinformers.SharedInformerFactory , svm storageversion.Manager ,
47
- proxyClientCertFile string , proxyClientKeyFile string , peerCAFile string , peerAdvertiseAddress reconcilers.PeerAdvertiseAddress ,
48
- apiServerID string , reconciler reconcilers.PeerEndpointLeaseReconciler , serializer runtime.NegotiatedSerializer ) (utilpeerproxy.Interface , error ) {
46
+ func BuildPeerProxy (
47
+ leaseInformer coordinationv1informers.LeaseInformer ,
48
+ loopbackClientConfig * rest.Config ,
49
+ proxyClientCertFile string ,
50
+ proxyClientKeyFile string ,
51
+ peerCAFile string ,
52
+ peerAdvertiseAddress reconcilers.PeerAdvertiseAddress ,
53
+ apiServerID string ,
54
+ reconciler reconcilers.PeerEndpointLeaseReconciler ,
55
+ serializer runtime.NegotiatedSerializer ) (utilpeerproxy.Interface , error ) {
49
56
if proxyClientCertFile == "" {
50
57
return nil , fmt .Errorf ("error building peer proxy handler, proxy-cert-file not specified" )
51
58
}
52
59
if proxyClientKeyFile == "" {
53
60
return nil , fmt .Errorf ("error building peer proxy handler, proxy-key-file not specified" )
54
61
}
55
- // create proxy client config
56
- clientConfig := & transport.Config {
62
+
63
+ proxyClientConfig := & transport.Config {
57
64
TLS : transport.TLSConfig {
58
65
Insecure : false ,
59
66
CertFile : proxyClientCertFile ,
@@ -62,20 +69,15 @@ func BuildPeerProxy(versionedInformer clientgoinformers.SharedInformerFactory, s
62
69
ServerName : "kubernetes.default.svc" ,
63
70
}}
64
71
65
- // build proxy transport
66
- proxyRoundTripper , transportBuildingError := transport .New (clientConfig )
67
- if transportBuildingError != nil {
68
- klog .Error (transportBuildingError .Error ())
69
- return nil , transportBuildingError
70
- }
71
72
return utilpeerproxy .NewPeerProxyHandler (
72
- versionedInformer ,
73
- svm ,
74
- proxyRoundTripper ,
75
73
apiServerID ,
74
+ IdentityLeaseComponentLabelKey + "=" + KubeAPIServer ,
75
+ leaseInformer ,
76
76
reconciler ,
77
77
serializer ,
78
- ), nil
78
+ loopbackClientConfig ,
79
+ proxyClientConfig ,
80
+ )
79
81
}
80
82
81
83
// CreatePeerEndpointLeaseReconciler creates a apiserver endpoint lease reconciliation loop
0 commit comments