@@ -259,7 +259,7 @@ func newCreateClusterPairCommand(cmdFactory Factory, ioStreams genericclioptions
259259 return
260260 }
261261 printMsg ("Using PX-Service Endpoint of DR cluster to create clusterpair...\n " , ioStreams .Out )
262- ip , port , token , err := getClusterPairParams (dFile , dIP )
262+ ip , port , token , err := getClusterPairParams (dFile , dIP , dPort )
263263 if err != nil {
264264 err := fmt .Errorf ("unable to create clusterpair from source to DR cluster. Err: %v" , err )
265265 util .CheckErr (err )
@@ -296,7 +296,7 @@ func newCreateClusterPairCommand(cmdFactory Factory, ioStreams genericclioptions
296296 return
297297 }
298298 printMsg ("Using PX-Service endpoints of source cluster to create clusterpair...\n " , ioStreams .Out )
299- ip , port , token , err = getClusterPairParams (sFile , sIP )
299+ ip , port , token , err = getClusterPairParams (sFile , sIP , sPort )
300300 if err != nil {
301301 err := fmt .Errorf ("unable to create clusterpair from DR to source cluster. Err: %v" , err )
302302 util .CheckErr (err )
@@ -476,7 +476,7 @@ func getConfig(configFile string) clientcmd.ClientConfig {
476476 return clientcmd .NewNonInteractiveDeferredLoadingClientConfig (configLoadingRules , configOverrides )
477477}
478478
479- func getClusterPairParams (config , endpoint string ) (string , string , string , error ) {
479+ func getClusterPairParams (config , endpoint string , customPort string ) (string , string , string , error ) {
480480 var ip , port , token string
481481 client , err := core .NewInstanceFromConfigFile (config )
482482 if err != nil {
@@ -500,10 +500,14 @@ func getClusterPairParams(config, endpoint string) (string, string, string, erro
500500 ip = svc .Spec .LoadBalancerIP
501501 }
502502 pxToken := os .Getenv ("PX_AUTH_TOKEN" )
503- for _ , svcPort := range svc .Spec .Ports {
504- if svcPort .Name == "px-api" {
505- port = strconv .Itoa (int (svcPort .Port ))
506- break
503+ if len (customPort ) > 0 {
504+ port = customPort
505+ } else {
506+ for _ , svcPort := range svc .Spec .Ports {
507+ if svcPort .Name == "px-api" {
508+ port = strconv .Itoa (int (svcPort .Port ))
509+ break
510+ }
507511 }
508512 }
509513 pxEndpoint := net .JoinHostPort (ip , port )
0 commit comments