Azure: Allow VNet to be in a separate Resource Group

Define a new config VnetResourceGroup in order to be able to use a VNet
which is not in the same resource group as kubernetes.

Signed-off-by: Sylvain Rabot <s.rabot@lectra.com>
This commit is contained in:
Sylvain Rabot 2017-07-26 19:04:08 +02:00
parent 0940a25440
commit 499d6c3473
2 changed files with 10 additions and 1 deletions

View File

@ -68,6 +68,8 @@ type Config struct {
Location string `json:"location" yaml:"location"` Location string `json:"location" yaml:"location"`
// The name of the VNet that the cluster is deployed in // The name of the VNet that the cluster is deployed in
VnetName string `json:"vnetName" yaml:"vnetName"` VnetName string `json:"vnetName" yaml:"vnetName"`
// The name of the resource group that the Vnet is deployed in
VnetResourceGroup string `json:"vnetResourceGroup" yaml:"vnetResourceGroup"`
// The name of the subnet that the cluster is deployed in // The name of the subnet that the cluster is deployed in
SubnetName string `json:"subnetName" yaml:"subnetName"` SubnetName string `json:"subnetName" yaml:"subnetName"`
// The name of the security group attached to the cluster's subnet // The name of the security group attached to the cluster's subnet

View File

@ -143,10 +143,17 @@ func (az *Cloud) getPublicIPAddress(name string) (pip network.PublicIPAddress, e
func (az *Cloud) getSubnet(virtualNetworkName string, subnetName string) (subnet network.Subnet, exists bool, err error) { func (az *Cloud) getSubnet(virtualNetworkName string, subnetName string) (subnet network.Subnet, exists bool, err error) {
var realErr error var realErr error
var rg string
if len(az.VnetResourceGroup) > 0 {
rg = az.VnetResourceGroup
} else {
rg = az.ResourceGroup
}
az.operationPollRateLimiter.Accept() az.operationPollRateLimiter.Accept()
glog.V(10).Infof("SubnetsClient.Get(%s): start", subnetName) glog.V(10).Infof("SubnetsClient.Get(%s): start", subnetName)
subnet, err = az.SubnetsClient.Get(az.ResourceGroup, virtualNetworkName, subnetName, "") subnet, err = az.SubnetsClient.Get(rg, virtualNetworkName, subnetName, "")
glog.V(10).Infof("SubnetsClient.Get(%s): end", subnetName) glog.V(10).Infof("SubnetsClient.Get(%s): end", subnetName)
exists, realErr = checkResourceExistsFromError(err) exists, realErr = checkResourceExistsFromError(err)