@@ -149,6 +149,7 @@ type initFederationOptions struct {
149
149
apiServerServiceType v1.ServiceType
150
150
apiServerAdvertiseAddress string
151
151
apiServerNodePortPort int32
152
+ apiServerNodePortPortPtr * int32
152
153
apiServerEnableHTTPBasicAuth bool
153
154
apiServerEnableTokenAuth bool
154
155
}
@@ -236,6 +237,9 @@ func (i *initFederation) Complete(cmd *cobra.Command, args []string) error {
236
237
if i .options .apiServerServiceType != v1 .ServiceTypeNodePort {
237
238
return fmt .Errorf ("%s should be passed only with '%s=NodePort'" , apiserverPortFlag , apiserverServiceTypeFlag )
238
239
}
240
+ i .options .apiServerNodePortPortPtr = & i .options .apiServerNodePortPort
241
+ } else {
242
+ i .options .apiServerNodePortPortPtr = nil
239
243
}
240
244
if i .options .apiServerNodePortPort < 0 || i .options .apiServerNodePortPort > 65535 {
241
245
return fmt .Errorf ("Please provide a valid port number for %s" , apiserverPortFlag )
@@ -304,7 +308,7 @@ func (i *initFederation) Run(cmdOut io.Writer, config util.AdminConfig) error {
304
308
305
309
fmt .Fprint (cmdOut , "Creating federation control plane service..." )
306
310
glog .V (4 ).Info ("Creating federation control plane service" )
307
- svc , ips , hostnames , err := createService (cmdOut , hostClientset , i .commonOptions .FederationSystemNamespace , serverName , i .commonOptions .Name , i .options .apiServerAdvertiseAddress , i .options .apiServerNodePortPort , i .options .apiServerServiceType , i .options .dryRun )
311
+ svc , ips , hostnames , err := createService (cmdOut , hostClientset , i .commonOptions .FederationSystemNamespace , serverName , i .commonOptions .Name , i .options .apiServerAdvertiseAddress , i .options .apiServerNodePortPortPtr , i .options .apiServerServiceType , i .options .dryRun )
308
312
if err != nil {
309
313
return err
310
314
}
@@ -454,15 +458,15 @@ func createNamespace(clientset client.Interface, federationName, namespace strin
454
458
return clientset .Core ().Namespaces ().Create (ns )
455
459
}
456
460
457
- func createService (cmdOut io.Writer , clientset client.Interface , namespace , svcName , federationName , apiserverAdvertiseAddress string , apiserverPort int32 , apiserverServiceType v1.ServiceType , dryRun bool ) (* api.Service , []string , []string , error ) {
461
+ func createService (cmdOut io.Writer , clientset client.Interface , namespace , svcName , federationName , apiserverAdvertiseAddress string , apiserverPort * int32 , apiserverServiceType v1.ServiceType , dryRun bool ) (* api.Service , []string , []string , error ) {
458
462
port := api.ServicePort {
459
463
Name : "https" ,
460
464
Protocol : "TCP" ,
461
465
Port : 443 ,
462
466
TargetPort : intstr .FromString (apiServerSecurePortName ),
463
467
}
464
- if apiserverServiceType == v1 .ServiceTypeNodePort && apiserverPort > 0 {
465
- port .NodePort = apiserverPort
468
+ if apiserverServiceType == v1 .ServiceTypeNodePort && apiserverPort != nil {
469
+ port .NodePort = * apiserverPort
466
470
}
467
471
svc := & api.Service {
468
472
ObjectMeta : metav1.ObjectMeta {
0 commit comments