@@ -118,6 +118,7 @@ const (
118
118
DefaultEndpointReconcilerTTL = 15 * time .Second
119
119
)
120
120
121
+ // ExtraConfig defines extra configuration for the master
121
122
type ExtraConfig struct {
122
123
ClientCARegistrationHook ClientCARegistrationHook
123
124
@@ -189,6 +190,7 @@ type ExtraConfig struct {
189
190
VersionedInformers informers.SharedInformerFactory
190
191
}
191
192
193
+ // Config defines configuration for the master
192
194
type Config struct {
193
195
GenericConfig * genericapiserver.Config
194
196
ExtraConfig ExtraConfig
@@ -199,8 +201,8 @@ type completedConfig struct {
199
201
ExtraConfig * ExtraConfig
200
202
}
201
203
204
+ // CompletedConfig embeds a private pointer that cannot be instantiated outside of this package
202
205
type CompletedConfig struct {
203
- // Embed a private pointer that cannot be instantiated outside of this package.
204
206
* completedConfig
205
207
}
206
208
@@ -272,50 +274,50 @@ func (c *Config) createEndpointReconciler() reconcilers.EndpointReconciler {
272
274
}
273
275
274
276
// Complete fills in any fields not set that are required to have valid data. It's mutating the receiver.
275
- func (cfg * Config ) Complete () CompletedConfig {
276
- c := completedConfig {
277
- cfg .GenericConfig .Complete (cfg .ExtraConfig .VersionedInformers ),
278
- & cfg .ExtraConfig ,
277
+ func (c * Config ) Complete () CompletedConfig {
278
+ cfg := completedConfig {
279
+ c .GenericConfig .Complete (c .ExtraConfig .VersionedInformers ),
280
+ & c .ExtraConfig ,
279
281
}
280
282
281
- serviceIPRange , apiServerServiceIP , err := ServiceIPRange (c .ExtraConfig .ServiceIPRange )
283
+ serviceIPRange , apiServerServiceIP , err := ServiceIPRange (cfg .ExtraConfig .ServiceIPRange )
282
284
if err != nil {
283
285
klog .Fatalf ("Error determining service IP ranges: %v" , err )
284
286
}
285
- if c .ExtraConfig .ServiceIPRange .IP == nil {
286
- c .ExtraConfig .ServiceIPRange = serviceIPRange
287
+ if cfg .ExtraConfig .ServiceIPRange .IP == nil {
288
+ cfg .ExtraConfig .ServiceIPRange = serviceIPRange
287
289
}
288
- if c .ExtraConfig .APIServerServiceIP == nil {
289
- c .ExtraConfig .APIServerServiceIP = apiServerServiceIP
290
+ if cfg .ExtraConfig .APIServerServiceIP == nil {
291
+ cfg .ExtraConfig .APIServerServiceIP = apiServerServiceIP
290
292
}
291
293
292
- discoveryAddresses := discovery.DefaultAddresses {DefaultAddress : c .GenericConfig .ExternalAddress }
294
+ discoveryAddresses := discovery.DefaultAddresses {DefaultAddress : cfg .GenericConfig .ExternalAddress }
293
295
discoveryAddresses .CIDRRules = append (discoveryAddresses .CIDRRules ,
294
- discovery.CIDRRule {IPRange : c .ExtraConfig .ServiceIPRange , Address : net .JoinHostPort (c .ExtraConfig .APIServerServiceIP .String (), strconv .Itoa (c .ExtraConfig .APIServerServicePort ))})
295
- c .GenericConfig .DiscoveryAddresses = discoveryAddresses
296
+ discovery.CIDRRule {IPRange : cfg .ExtraConfig .ServiceIPRange , Address : net .JoinHostPort (cfg .ExtraConfig .APIServerServiceIP .String (), strconv .Itoa (cfg .ExtraConfig .APIServerServicePort ))})
297
+ cfg .GenericConfig .DiscoveryAddresses = discoveryAddresses
296
298
297
- if c .ExtraConfig .ServiceNodePortRange .Size == 0 {
299
+ if cfg .ExtraConfig .ServiceNodePortRange .Size == 0 {
298
300
// TODO: Currently no way to specify an empty range (do we need to allow this?)
299
301
// We should probably allow this for clouds that don't require NodePort to do load-balancing (GCE)
300
302
// but then that breaks the strict nestedness of ServiceType.
301
303
// Review post-v1
302
- c .ExtraConfig .ServiceNodePortRange = kubeoptions .DefaultServiceNodePortRange
303
- klog .Infof ("Node port range unspecified. Defaulting to %v." , c .ExtraConfig .ServiceNodePortRange )
304
+ cfg .ExtraConfig .ServiceNodePortRange = kubeoptions .DefaultServiceNodePortRange
305
+ klog .Infof ("Node port range unspecified. Defaulting to %v." , cfg .ExtraConfig .ServiceNodePortRange )
304
306
}
305
307
306
- if c .ExtraConfig .EndpointReconcilerConfig .Interval == 0 {
307
- c .ExtraConfig .EndpointReconcilerConfig .Interval = DefaultEndpointReconcilerInterval
308
+ if cfg .ExtraConfig .EndpointReconcilerConfig .Interval == 0 {
309
+ cfg .ExtraConfig .EndpointReconcilerConfig .Interval = DefaultEndpointReconcilerInterval
308
310
}
309
311
310
- if c .ExtraConfig .MasterEndpointReconcileTTL == 0 {
311
- c .ExtraConfig .MasterEndpointReconcileTTL = DefaultEndpointReconcilerTTL
312
+ if cfg .ExtraConfig .MasterEndpointReconcileTTL == 0 {
313
+ cfg .ExtraConfig .MasterEndpointReconcileTTL = DefaultEndpointReconcilerTTL
312
314
}
313
315
314
- if c .ExtraConfig .EndpointReconcilerConfig .Reconciler == nil {
315
- c .ExtraConfig .EndpointReconcilerConfig .Reconciler = cfg .createEndpointReconciler ()
316
+ if cfg .ExtraConfig .EndpointReconcilerConfig .Reconciler == nil {
317
+ cfg .ExtraConfig .EndpointReconcilerConfig .Reconciler = c .createEndpointReconciler ()
316
318
}
317
319
318
- return CompletedConfig {& c }
320
+ return CompletedConfig {& cfg }
319
321
}
320
322
321
323
// New returns a new instance of Master from the given config.
@@ -403,6 +405,7 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget)
403
405
return m , nil
404
406
}
405
407
408
+ // InstallLegacyAPI will install the legacy APIs for the restStorageProviders if they are enabled.
406
409
func (m * Master ) InstallLegacyAPI (c * completedConfig , restOptionsGetter generic.RESTOptionsGetter , legacyRESTStorageProvider corerest.LegacyRESTStorageProvider ) error {
407
410
legacyRESTStorage , apiGroupInfo , err := legacyRESTStorageProvider .NewLegacyRESTStorage (restOptionsGetter )
408
411
if err != nil {
@@ -452,7 +455,7 @@ func (m *Master) InstallAPIs(apiResourceConfigSource serverstorage.APIResourceCo
452
455
}
453
456
apiGroupInfo , enabled , err := restStorageBuilder .NewRESTStorage (apiResourceConfigSource , restOptionsGetter )
454
457
if err != nil {
455
- return fmt .Errorf ("problem initializing API group %q : %v. " , groupName , err )
458
+ return fmt .Errorf ("problem initializing API group %q : %v" , groupName , err )
456
459
}
457
460
if ! enabled {
458
461
klog .Warningf ("API group %q is not enabled, skipping." , groupName )
@@ -512,6 +515,7 @@ func (n nodeAddressProvider) externalAddresses() ([]string, error) {
512
515
return addrs , nil
513
516
}
514
517
518
+ // DefaultAPIResourceConfigSource returns default configuration for an APIResource.
515
519
func DefaultAPIResourceConfigSource () * serverstorage.ResourceConfig {
516
520
ret := serverstorage .NewResourceConfig ()
517
521
// NOTE: GroupVersions listed here will be enabled by default. Don't put alpha versions in the list.
0 commit comments