mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Merge pull request #87035 from CecileRobertMichon/add-azure-nsg-rg
Add Azure network security group resource group
This commit is contained in:
commit
d2a526bc0e
@ -118,6 +118,8 @@ type Config struct {
|
||||
SubnetName string `json:"subnetName,omitempty" yaml:"subnetName,omitempty"`
|
||||
// The name of the security group attached to the cluster's subnet
|
||||
SecurityGroupName string `json:"securityGroupName,omitempty" yaml:"securityGroupName,omitempty"`
|
||||
// The name of the resource group that the security group is deployed in
|
||||
SecurityGroupResourceGroup string `json:"securityGroupResourceGroup,omitempty" yaml:"securityGroupResourceGroup,omitempty"`
|
||||
// (Optional in 1.6) The name of the route table attached to the subnet that the cluster is deployed in
|
||||
RouteTableName string `json:"routeTableName,omitempty" yaml:"routeTableName,omitempty"`
|
||||
// The name of the resource group that the RouteTable is deployed in
|
||||
@ -332,6 +334,10 @@ func (az *Cloud) InitializeCloudFromConfig(config *Config, fromSecret bool) erro
|
||||
config.RouteTableResourceGroup = config.ResourceGroup
|
||||
}
|
||||
|
||||
if config.SecurityGroupResourceGroup == "" {
|
||||
config.SecurityGroupResourceGroup = config.ResourceGroup
|
||||
}
|
||||
|
||||
if config.VMType == "" {
|
||||
// default to standard vmType if not set.
|
||||
config.VMType = vmTypeStandard
|
||||
|
@ -187,7 +187,7 @@ func (az *Cloud) CreateOrUpdateSecurityGroup(service *v1.Service, sg network.Sec
|
||||
ctx, cancel := getContextWithCancel()
|
||||
defer cancel()
|
||||
|
||||
rerr := az.SecurityGroupsClient.CreateOrUpdate(ctx, az.ResourceGroup, *sg.Name, sg, to.String(sg.Etag))
|
||||
rerr := az.SecurityGroupsClient.CreateOrUpdate(ctx, az.SecurityGroupResourceGroup, *sg.Name, sg, to.String(sg.Etag))
|
||||
klog.V(10).Infof("SecurityGroupsClient.CreateOrUpdate(%s): end", *sg.Name)
|
||||
if rerr == nil {
|
||||
// Invalidate the cache right after updating
|
||||
@ -217,7 +217,7 @@ func (az *Cloud) CreateOrUpdateSGWithRetry(service *v1.Service, sg network.Secur
|
||||
ctx, cancel := getContextWithCancel()
|
||||
defer cancel()
|
||||
|
||||
rerr := az.SecurityGroupsClient.CreateOrUpdate(ctx, az.ResourceGroup, *sg.Name, sg, to.String(sg.Etag))
|
||||
rerr := az.SecurityGroupsClient.CreateOrUpdate(ctx, az.SecurityGroupResourceGroup, *sg.Name, sg, to.String(sg.Etag))
|
||||
klog.V(10).Infof("SecurityGroupsClient.CreateOrUpdate(%s): end", *sg.Name)
|
||||
if rerr == nil {
|
||||
// Invalidate the cache right after updating
|
||||
|
@ -69,6 +69,7 @@ var (
|
||||
"routeTableName": "routeTableName",
|
||||
"routeTableResourceGroup": "routeTableResourceGroup",
|
||||
"securityGroupName": "securityGroupName",
|
||||
"securityGroupResourceGroup": "securityGroupResourceGroup",
|
||||
"subnetName": "subnetName",
|
||||
"subscriptionId": "subscriptionId",
|
||||
"tenantId": "tenantId",
|
||||
@ -131,6 +132,7 @@ func TestParseConfig(t *testing.T) {
|
||||
RouteTableName: "routeTableName",
|
||||
RouteTableResourceGroup: "routeTableResourceGroup",
|
||||
SecurityGroupName: "securityGroupName",
|
||||
SecurityGroupResourceGroup: "securityGroupResourceGroup",
|
||||
SubnetName: "subnetName",
|
||||
UseInstanceMetadata: true,
|
||||
VMType: "standard",
|
||||
|
@ -893,6 +893,7 @@ func getTestCloud() (az *Cloud) {
|
||||
ResourceGroup: "rg",
|
||||
VnetResourceGroup: "rg",
|
||||
RouteTableResourceGroup: "rg",
|
||||
SecurityGroupResourceGroup: "rg",
|
||||
Location: "westus",
|
||||
VnetName: "vnet",
|
||||
SubnetName: "subnet",
|
||||
@ -1149,7 +1150,7 @@ func getTestSecurityGroup(az *Cloud, services ...v1.Service) *network.SecurityGr
|
||||
defer cancel()
|
||||
az.SecurityGroupsClient.CreateOrUpdate(
|
||||
ctx,
|
||||
az.ResourceGroup,
|
||||
az.SecurityGroupResourceGroup,
|
||||
az.SecurityGroupName,
|
||||
sg,
|
||||
"")
|
||||
@ -1492,6 +1493,7 @@ func TestNewCloudFromJSON(t *testing.T) {
|
||||
"aadClientCertPassword": "--aad-client-cert-password--",
|
||||
"resourceGroup": "--resource-group--",
|
||||
"routeTableResourceGroup": "--route-table-resource-group--",
|
||||
"securityGroupResourceGroup": "--security-group-resource-group--",
|
||||
"location": "--location--",
|
||||
"subnetName": "--subnet-name--",
|
||||
"securityGroupName": "--security-group-name--",
|
||||
@ -1544,6 +1546,7 @@ aadClientCertPath: --aad-client-cert-path--
|
||||
aadClientCertPassword: --aad-client-cert-password--
|
||||
resourceGroup: --resource-group--
|
||||
routeTableResourceGroup: --route-table-resource-group--
|
||||
securityGroupResourceGroup: --security-group-resource-group--
|
||||
location: --location--
|
||||
subnetName: --subnet-name--
|
||||
securityGroupName: --security-group-name--
|
||||
@ -1596,6 +1599,9 @@ func validateConfig(t *testing.T, config string) {
|
||||
if azureCloud.RouteTableResourceGroup != "--route-table-resource-group--" {
|
||||
t.Errorf("got incorrect value for RouteTableResourceGroup")
|
||||
}
|
||||
if azureCloud.SecurityGroupResourceGroup != "--security-group-resource-group--" {
|
||||
t.Errorf("got incorrect value for SecurityGroupResourceGroup")
|
||||
}
|
||||
if azureCloud.Location != "--location--" {
|
||||
t.Errorf("got incorrect value for Location")
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ func (az *Cloud) newNSGCache() (*timedCache, error) {
|
||||
getter := func(key string) (interface{}, error) {
|
||||
ctx, cancel := getContextWithCancel()
|
||||
defer cancel()
|
||||
nsg, err := az.SecurityGroupsClient.Get(ctx, az.ResourceGroup, key, "")
|
||||
nsg, err := az.SecurityGroupsClient.Get(ctx, az.SecurityGroupResourceGroup, key, "")
|
||||
exists, rerr := checkResourceExistsFromError(err)
|
||||
if rerr != nil {
|
||||
return nil, rerr.Error()
|
||||
|
@ -318,6 +318,7 @@ func getTestCloudForVMCache(vmList []string) (az *Cloud) {
|
||||
ResourceGroup: "rg",
|
||||
VnetResourceGroup: "rg",
|
||||
RouteTableResourceGroup: "rg",
|
||||
SecurityGroupResourceGroup: "rg",
|
||||
Location: "westus",
|
||||
VnetName: "vnet",
|
||||
SubnetName: "subnet",
|
||||
|
Loading…
Reference in New Issue
Block a user