|
1 | 1 | package acsengine
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "encoding/binary" |
4 | 5 | "fmt"
|
5 | 6 | "net"
|
6 | 7 |
|
@@ -476,9 +477,6 @@ func setMasterNetworkDefaults(a *api.Properties) {
|
476 | 477 |
|
477 | 478 | // Set the default number of IP addresses allocated for masters.
|
478 | 479 | if a.MasterProfile.IPAddressCount == 0 {
|
479 |
| - // Allocate one IP address for the node. |
480 |
| - a.MasterProfile.IPAddressCount = 1 |
481 |
| - |
482 | 480 | // Allocate IP addresses for pods if VNET integration is enabled.
|
483 | 481 | if a.OrchestratorProfile.IsAzureCNI() {
|
484 | 482 | if a.OrchestratorProfile.OrchestratorType == api.Kubernetes {
|
@@ -676,27 +674,23 @@ func certsAlreadyPresent(c *api.CertificateProfile, m int) map[string]bool {
|
676 | 674 |
|
677 | 675 | // getFirstConsecutiveStaticIPAddress returns the first static IP address of the given subnet.
|
678 | 676 | func getFirstConsecutiveStaticIPAddress(subnetStr string) string {
|
679 |
| - _, subnet, err := net.ParseCIDR(subnetStr) |
| 677 | + ip, _, err := net.ParseCIDR(subnetStr) |
680 | 678 | if err != nil {
|
681 | 679 | return DefaultFirstConsecutiveKubernetesStaticIP
|
682 | 680 | }
|
683 | 681 |
|
684 |
| - // Find the first and last octet of the host bits. |
685 |
| - ones, bits := subnet.Mask.Size() |
686 |
| - firstOctet := ones / 8 |
687 |
| - lastOctet := bits/8 - 1 |
688 |
| - |
689 |
| - // Set the remaining host bits in the first octet. |
690 |
| - subnet.IP[firstOctet] |= (1 << byte((8 - (ones % 8)))) - 1 |
691 |
| - |
692 |
| - // Fill the intermediate octets with 1s and last octet with offset. This is done so to match |
693 |
| - // the existing behavior of allocating static IP addresses from the last /24 of the subnet. |
694 |
| - for i := firstOctet + 1; i < lastOctet; i++ { |
695 |
| - subnet.IP[i] = 255 |
| 682 | + ipv4 := ip.To4() |
| 683 | + if ipv4 == nil { |
| 684 | + return DefaultFirstConsecutiveKubernetesStaticIP |
696 | 685 | }
|
697 |
| - subnet.IP[lastOctet] = DefaultKubernetesFirstConsecutiveStaticIPOffset |
698 | 686 |
|
699 |
| - return subnet.IP.String() |
| 687 | + ipint := binary.BigEndian.Uint32(ipv4) |
| 688 | + |
| 689 | + // First 4 IPs will be reserved in Azure and cannot use. |
| 690 | + ipint += 4 |
| 691 | + startIP := make(net.IP, 4) |
| 692 | + binary.BigEndian.PutUint32(startIP, ipint) |
| 693 | + return startIP.String() |
700 | 694 | }
|
701 | 695 |
|
702 | 696 | func getAddonsIndexByName(addons []api.KubernetesAddon, name string) int {
|
|
0 commit comments