@@ -54,7 +54,6 @@ import (
54
54
storageapiv1beta1 "k8s.io/api/storage/v1beta1"
55
55
svmv1alpha1 "k8s.io/api/storagemigration/v1alpha1"
56
56
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
57
- kruntime "k8s.io/apimachinery/pkg/runtime"
58
57
"k8s.io/apimachinery/pkg/runtime/schema"
59
58
utilnet "k8s.io/apimachinery/pkg/util/net"
60
59
"k8s.io/apimachinery/pkg/util/runtime"
@@ -67,14 +66,10 @@ import (
67
66
genericapiserver "k8s.io/apiserver/pkg/server"
68
67
"k8s.io/apiserver/pkg/server/dynamiccertificates"
69
68
serverstorage "k8s.io/apiserver/pkg/server/storage"
70
- "k8s.io/apiserver/pkg/storageversion"
71
69
utilfeature "k8s.io/apiserver/pkg/util/feature"
72
- utilpeerproxy "k8s.io/apiserver/pkg/util/peerproxy"
73
- clientgoinformers "k8s.io/client-go/informers"
74
70
"k8s.io/client-go/kubernetes"
75
71
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
76
72
discoveryclient "k8s.io/client-go/kubernetes/typed/discovery/v1"
77
- "k8s.io/client-go/transport"
78
73
"k8s.io/component-helpers/apimachinery/lease"
79
74
"k8s.io/klog/v2"
80
75
api "k8s.io/kubernetes/pkg/apis/core"
@@ -157,16 +152,6 @@ type Extra struct {
157
152
EndpointReconcilerConfig EndpointReconcilerConfig
158
153
KubeletClientConfig kubeletclient.KubeletClientConfig
159
154
160
- // PeerProxy, if not nil, sets proxy transport between kube-apiserver peers for requests
161
- // that can not be served locally
162
- PeerProxy utilpeerproxy.Interface
163
- // PeerEndpointLeaseReconciler updates the peer endpoint leases
164
- PeerEndpointLeaseReconciler peerreconcilers.PeerEndpointLeaseReconciler
165
- // PeerAdvertiseAddress is the IP for this kube-apiserver which is used by peer apiservers to route a request
166
- // to this apiserver. This happens in cases where the peer is not able to serve the request due to
167
- // version skew. If unset, AdvertiseAddress/BindAddress will be used.
168
- PeerAdvertiseAddress peerreconcilers.PeerAdvertiseAddress
169
-
170
155
// Values to build the IP addresses used by discovery
171
156
// The range of IPs to be assigned to services with type=ClusterIP or greater
172
157
ServiceIPRange net.IPNet
@@ -290,6 +275,12 @@ func (c *Config) createEndpointReconciler() reconcilers.EndpointReconciler {
290
275
291
276
// Complete fills in any fields not set that are required to have valid data. It's mutating the receiver.
292
277
func (c * Config ) Complete () CompletedConfig {
278
+ if c .ControlPlane .PeerEndpointReconcileInterval == 0 && c .EndpointReconcilerConfig .Interval != 0 {
279
+ // default this to the endpoint reconciler value before the generic
280
+ // controlplane completion can kick in
281
+ c .ControlPlane .PeerEndpointReconcileInterval = c .EndpointReconcilerConfig .Interval
282
+ }
283
+
293
284
cfg := completedConfig {
294
285
c .ControlPlane .Complete (),
295
286
& c .Extra ,
@@ -508,11 +499,11 @@ func (c CompletedConfig) New(delegationTarget genericapiserver.DelegationTarget)
508
499
}
509
500
510
501
if utilfeature .DefaultFeatureGate .Enabled (features .UnknownVersionInteroperabilityProxy ) {
511
- peeraddress := getPeerAddress (c .Extra .PeerAdvertiseAddress , c .ControlPlane .Generic .PublicAddress , publicServicePort )
502
+ peeraddress := getPeerAddress (c .ControlPlane . Extra .PeerAdvertiseAddress , c .ControlPlane .Generic .PublicAddress , publicServicePort )
512
503
peerEndpointCtrl := peerreconcilers .New (
513
504
c .ControlPlane .Generic .APIServerID ,
514
505
peeraddress ,
515
- c .Extra .PeerEndpointLeaseReconciler ,
506
+ c .ControlPlane . Extra .PeerEndpointLeaseReconciler ,
516
507
c .Extra .EndpointReconcilerConfig .Interval ,
517
508
client )
518
509
if err != nil {
@@ -529,9 +520,9 @@ func (c CompletedConfig) New(delegationTarget genericapiserver.DelegationTarget)
529
520
return nil
530
521
})
531
522
// Add PostStartHooks for Unknown Version Proxy filter.
532
- if c .Extra .PeerProxy != nil {
523
+ if c .ControlPlane . Extra .PeerProxy != nil {
533
524
m .GenericAPIServer .AddPostStartHookOrDie ("unknown-version-proxy-filter" , func (context genericapiserver.PostStartHookContext ) error {
534
- err := c .Extra .PeerProxy .WaitForCacheSync (context .StopCh )
525
+ err := c .ControlPlane . Extra .PeerProxy .WaitForCacheSync (context .StopCh )
535
526
return err
536
527
})
537
528
}
@@ -579,7 +570,7 @@ func (c CompletedConfig) New(delegationTarget genericapiserver.DelegationTarget)
579
570
leaseName := m .GenericAPIServer .APIServerID
580
571
holderIdentity := m .GenericAPIServer .APIServerID + "_" + string (uuid .NewUUID ())
581
572
582
- peeraddress := getPeerAddress (c .Extra .PeerAdvertiseAddress , c .ControlPlane .Generic .PublicAddress , publicServicePort )
573
+ peeraddress := getPeerAddress (c .ControlPlane . Extra .PeerAdvertiseAddress , c .ControlPlane .Generic .PublicAddress , publicServicePort )
583
574
// must replace ':,[]' in [ip:port] to be able to store this as a valid label value
584
575
controller := lease .NewController (
585
576
clock.RealClock {},
@@ -782,53 +773,6 @@ func DefaultAPIResourceConfigSource() *serverstorage.ResourceConfig {
782
773
return ret
783
774
}
784
775
785
- // CreatePeerEndpointLeaseReconciler creates a apiserver endpoint lease reconciliation loop
786
- // The peer endpoint leases are used to find network locations of apiservers for peer proxy
787
- func CreatePeerEndpointLeaseReconciler (c genericapiserver.Config , storageFactory serverstorage.StorageFactory ) (peerreconcilers.PeerEndpointLeaseReconciler , error ) {
788
- ttl := DefaultEndpointReconcilerTTL
789
- config , err := storageFactory .NewConfig (api .Resource ("apiServerPeerIPInfo" ))
790
- if err != nil {
791
- return nil , fmt .Errorf ("error creating storage factory config: %w" , err )
792
- }
793
- reconciler , err := peerreconcilers .NewPeerEndpointLeaseReconciler (config , "/peerserverleases/" , ttl )
794
- return reconciler , err
795
- }
796
-
797
- func BuildPeerProxy (versionedInformer clientgoinformers.SharedInformerFactory , svm storageversion.Manager ,
798
- proxyClientCertFile string , proxyClientKeyFile string , peerCAFile string , peerAdvertiseAddress peerreconcilers.PeerAdvertiseAddress ,
799
- apiServerID string , reconciler peerreconcilers.PeerEndpointLeaseReconciler , serializer kruntime.NegotiatedSerializer ) (utilpeerproxy.Interface , error ) {
800
- if proxyClientCertFile == "" {
801
- return nil , fmt .Errorf ("error building peer proxy handler, proxy-cert-file not specified" )
802
- }
803
- if proxyClientKeyFile == "" {
804
- return nil , fmt .Errorf ("error building peer proxy handler, proxy-key-file not specified" )
805
- }
806
- // create proxy client config
807
- clientConfig := & transport.Config {
808
- TLS : transport.TLSConfig {
809
- Insecure : false ,
810
- CertFile : proxyClientCertFile ,
811
- KeyFile : proxyClientKeyFile ,
812
- CAFile : peerCAFile ,
813
- ServerName : "kubernetes.default.svc" ,
814
- }}
815
-
816
- // build proxy transport
817
- proxyRoundTripper , transportBuildingError := transport .New (clientConfig )
818
- if transportBuildingError != nil {
819
- klog .Error (transportBuildingError .Error ())
820
- return nil , transportBuildingError
821
- }
822
- return utilpeerproxy .NewPeerProxyHandler (
823
- versionedInformer ,
824
- svm ,
825
- proxyRoundTripper ,
826
- apiServerID ,
827
- reconciler ,
828
- serializer ,
829
- ), nil
830
- }
831
-
832
776
// utility function to get the apiserver address that is used by peer apiservers to proxy
833
777
// requests to this apiserver in case the peer is incapable of serving the request
834
778
func getPeerAddress (peerAdvertiseAddress peerreconcilers.PeerAdvertiseAddress , publicAddress net.IP , publicServicePort int ) string {
0 commit comments