@@ -239,12 +239,12 @@ var (
239239)
240240
241241// SetPropertiesDefaults for the container Properties, returns true if certs are generated
242- func SetPropertiesDefaults (cs * api.ContainerService ) (bool , error ) {
242+ func SetPropertiesDefaults (cs * api.ContainerService , isUpgrade bool ) (bool , error ) {
243243 properties := cs .Properties
244244
245245 setOrchestratorDefaults (cs )
246246
247- setMasterNetworkDefaults (properties )
247+ setMasterNetworkDefaults (properties , isUpgrade )
248248
249249 setHostedMasterNetworkDefaults (properties )
250250
@@ -456,7 +456,7 @@ func setHostedMasterNetworkDefaults(a *api.Properties) {
456456}
457457
458458// SetMasterNetworkDefaults for masters
459- func setMasterNetworkDefaults (a * api.Properties ) {
459+ func setMasterNetworkDefaults (a * api.Properties , isUpgrade bool ) {
460460 if a .MasterProfile == nil {
461461 return
462462 }
@@ -471,17 +471,29 @@ func setMasterNetworkDefaults(a *api.Properties) {
471471 if a .OrchestratorProfile .IsAzureCNI () {
472472 // When VNET integration is enabled, all masters, agents and pods share the same large subnet.
473473 a .MasterProfile .Subnet = a .OrchestratorProfile .KubernetesConfig .ClusterSubnet
474- a .MasterProfile .FirstConsecutiveStaticIP = getFirstConsecutiveStaticIPAddress (a .MasterProfile .Subnet )
474+ // FirstConsecutiveStaticIP is not reset if it is upgrade and some value already exists
475+ if ! isUpgrade || len (a .MasterProfile .FirstConsecutiveStaticIP ) == 0 {
476+ a .MasterProfile .FirstConsecutiveStaticIP = getFirstConsecutiveStaticIPAddress (a .MasterProfile .Subnet )
477+ }
475478 } else {
476479 a .MasterProfile .Subnet = DefaultKubernetesMasterSubnet
477- a .MasterProfile .FirstConsecutiveStaticIP = DefaultFirstConsecutiveKubernetesStaticIP
480+ // FirstConsecutiveStaticIP is not reset if it is upgrade and some value already exists
481+ if ! isUpgrade || len (a .MasterProfile .FirstConsecutiveStaticIP ) == 0 {
482+ a .MasterProfile .FirstConsecutiveStaticIP = DefaultFirstConsecutiveKubernetesStaticIP
483+ }
478484 }
479485 } else if a .HasWindows () {
480486 a .MasterProfile .Subnet = DefaultSwarmWindowsMasterSubnet
481- a .MasterProfile .FirstConsecutiveStaticIP = DefaultSwarmWindowsFirstConsecutiveStaticIP
487+ // FirstConsecutiveStaticIP is not reset if it is upgrade and some value already exists
488+ if ! isUpgrade || len (a .MasterProfile .FirstConsecutiveStaticIP ) == 0 {
489+ a .MasterProfile .FirstConsecutiveStaticIP = DefaultSwarmWindowsFirstConsecutiveStaticIP
490+ }
482491 } else {
483492 a .MasterProfile .Subnet = DefaultMasterSubnet
484- a .MasterProfile .FirstConsecutiveStaticIP = DefaultFirstConsecutiveStaticIP
493+ // FirstConsecutiveStaticIP is not reset if it is upgrade and some value already exists
494+ if ! isUpgrade || len (a .MasterProfile .FirstConsecutiveStaticIP ) == 0 {
495+ a .MasterProfile .FirstConsecutiveStaticIP = DefaultFirstConsecutiveStaticIP
496+ }
485497 }
486498 }
487499
0 commit comments