diff --git a/pkg/network/common/common.go b/pkg/network/common/common.go index e44ba78a6077..c9740a1ba581 100644 --- a/pkg/network/common/common.go +++ b/pkg/network/common/common.go @@ -62,8 +62,10 @@ func ParseNetworkInfo(clusterNetwork []networkapi.ClusterNetworkEntry, serviceNe return nil, fmt.Errorf("failed to parse ClusterNetwork CIDR %s: %v", entry.CIDR, err) } glog.Errorf("Configured clusterNetworks value %q is invalid; treating it as %q", entry.CIDR, cidr.String()) + cns = append(cns, ClusterNetwork{ClusterCIDR: cidr, HostSubnetLength: entry.HostSubnetLength}) + } else { + cns = append(cns, ClusterNetwork{ClusterCIDR: cidr, HostSubnetLength: entry.HostSubnetLength}) } - cns = append(cns, ClusterNetwork{ClusterCIDR: cidr, HostSubnetLength: entry.HostSubnetLength}) } sn, err := netutils.ParseCIDRMask(serviceNetwork) diff --git a/pkg/network/master/master.go b/pkg/network/master/master.go index 6c7401d18228..e9a1f8d286eb 100644 --- a/pkg/network/master/master.go +++ b/pkg/network/master/master.go @@ -66,17 +66,22 @@ func Start(networkConfig osconfigapi.MasterNetworkConfig, networkClient networkc panic("No ClusterNetworks set in networkConfig; should have been defaulted in if not configured") } + var parsedClusterNetworkEntries []networkapi.ClusterNetworkEntry + for _, entry := range master.networkInfo.ClusterNetworks { + parsedClusterNetworkEntries = append(parsedClusterNetworkEntries, networkapi.ClusterNetworkEntry{CIDR: entry.ClusterCIDR.String(), HostSubnetLength: entry.HostSubnetLength}) + } + configCN := &networkapi.ClusterNetwork{ TypeMeta: metav1.TypeMeta{Kind: "ClusterNetwork"}, ObjectMeta: metav1.ObjectMeta{Name: networkapi.ClusterNetworkDefault}, - ClusterNetworks: clusterNetworkEntries, - ServiceNetwork: networkConfig.ServiceNetworkCIDR, + ClusterNetworks: parsedClusterNetworkEntries, + ServiceNetwork: master.networkInfo.ServiceNetwork.String(), PluginName: networkConfig.NetworkPluginName, // Need to set these for backward compat - Network: clusterNetworkEntries[0].CIDR, - HostSubnetLength: clusterNetworkEntries[0].HostSubnetLength, + Network: parsedClusterNetworkEntries[0].CIDR, + HostSubnetLength: parsedClusterNetworkEntries[0].HostSubnetLength, } osapivalidation.SetDefaultClusterNetwork(*configCN)