Skip to content

Commit

Permalink
migrating from 2019 to 2021 for storage
Browse files Browse the repository at this point in the history
  • Loading branch information
azoppiserpa committed May 29, 2024
1 parent 14e9f96 commit 59a0b52
Show file tree
Hide file tree
Showing 15 changed files with 522 additions and 28 deletions.
16 changes: 8 additions & 8 deletions pkg/cluster/deploybaseresources_additional.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@ func (m *manager) storageAccount(name, region string, ocpSubnets []string, encry
virtualNetworkRules := []mgmtstorage.VirtualNetworkRule{
{
VirtualNetworkResourceID: to.StringPtr("/subscriptions/" + m.env.SubscriptionID() + "/resourceGroups/" + m.env.ResourceGroup() + "/providers/Microsoft.Network/virtualNetworks/rp-pe-vnet-001/subnets/rp-pe-subnet"),
Action: mgmtstorage.Allow,
Action: mgmtstorage.ActionAllow,
},
{
VirtualNetworkResourceID: to.StringPtr("/subscriptions/" + m.env.SubscriptionID() + "/resourceGroups/" + m.env.ResourceGroup() + "/providers/Microsoft.Network/virtualNetworks/rp-vnet/subnets/rp-subnet"),
Action: mgmtstorage.Allow,
Action: mgmtstorage.ActionAllow,
},
}

// add OCP subnets which have Microsoft.Storage service endpoint enabled
for _, subnet := range ocpSubnets {
virtualNetworkRules = append(virtualNetworkRules, mgmtstorage.VirtualNetworkRule{
VirtualNetworkResourceID: to.StringPtr(subnet),
Action: mgmtstorage.Allow,
Action: mgmtstorage.ActionAllow,
})
}

Expand All @@ -110,7 +110,7 @@ func (m *manager) storageAccount(name, region string, ocpSubnets []string, encry
if m.installViaHive && strings.Index(name, "cluster") == 0 {
virtualNetworkRules = append(virtualNetworkRules, mgmtstorage.VirtualNetworkRule{
VirtualNetworkResourceID: to.StringPtr(fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualNetworks/aks-net/subnets/PodSubnet-%03d", m.env.SubscriptionID(), m.env.ResourceGroup(), hiveShard)),
Action: mgmtstorage.Allow,
Action: mgmtstorage.ActionAllow,
})
}

Expand All @@ -120,21 +120,21 @@ func (m *manager) storageAccount(name, region string, ocpSubnets []string, encry
if !m.env.IsLocalDevelopmentMode() {
virtualNetworkRules = append(virtualNetworkRules, mgmtstorage.VirtualNetworkRule{
VirtualNetworkResourceID: to.StringPtr("/subscriptions/" + m.env.SubscriptionID() + "/resourceGroups/" + m.env.GatewayResourceGroup() + "/providers/Microsoft.Network/virtualNetworks/gateway-vnet/subnets/gateway-subnet"),
Action: mgmtstorage.Allow,
Action: mgmtstorage.ActionAllow,
})
}

sa := &mgmtstorage.Account{
Kind: mgmtstorage.StorageV2,
Kind: mgmtstorage.KindStorageV2,
Sku: &mgmtstorage.Sku{
Name: "Standard_LRS",
},
AccountProperties: &mgmtstorage.AccountProperties{
AllowBlobPublicAccess: to.BoolPtr(false),
EnableHTTPSTrafficOnly: to.BoolPtr(true),
MinimumTLSVersion: mgmtstorage.TLS12,
MinimumTLSVersion: mgmtstorage.MinimumTLSVersionTLS12,
NetworkRuleSet: &mgmtstorage.NetworkRuleSet{
Bypass: mgmtstorage.AzureServices,
Bypass: mgmtstorage.BypassAzureServices,
VirtualNetworkRules: &virtualNetworkRules,
DefaultAction: "Deny",
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/assets/gateway-production.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"location": "[resourceGroup().location]",
"name": "[substring(parameters('gatewayStorageAccountDomain'), 0, indexOf(parameters('gatewayStorageAccountDomain'), '.'))]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01"
"apiVersion": "2021-09-01"
},
{
"sku": {
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/assets/rp-oic.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"location": "[resourceGroup().location]",
"name": "[concat(take(substring(parameters('storageAccountDomain'), 0, indexOf(parameters('storageAccountDomain'), '.')), 21), 'oic')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01"
"apiVersion": "2021-09-01"
},
{
"name": "[concat(concat(take(substring(parameters('storageAccountDomain'), 0, indexOf(parameters('storageAccountDomain'), '.')), 21), 'oic'), '/Microsoft.Authorization/', guid(resourceId('Microsoft.Storage/storageAccounts', concat(take(substring(parameters('storageAccountDomain'), 0, indexOf(parameters('storageAccountDomain'), '.')), 21), 'oic'))))]",
Expand Down
6 changes: 3 additions & 3 deletions pkg/deploy/assets/rp-production-global.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"location": "[resourceGroup().location]",
"name": "[parameters('rpVersionStorageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01"
"apiVersion": "2021-09-01"
},
{
"properties": {
Expand All @@ -119,7 +119,7 @@
},
"name": "[concat(parameters('rpVersionStorageAccountName'), '/default/rpversion')]",
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"apiVersion": "2019-06-01",
"apiVersion": "2021-09-01",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', parameters('rpVersionStorageAccountName'))]"
]
Expand All @@ -131,7 +131,7 @@
},
"name": "[concat(parameters('rpVersionStorageAccountName'), '/default/ocpversions')]",
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"apiVersion": "2019-06-01",
"apiVersion": "2021-09-01",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', parameters('rpVersionStorageAccountName'))]"
]
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/assets/rp-production.json
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@
"location": "[resourceGroup().location]",
"name": "[substring(parameters('storageAccountDomain'), 0, indexOf(parameters('storageAccountDomain'), '.'))]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01"
"apiVersion": "2021-09-01"
},
{
"properties": {
Expand Down
6 changes: 3 additions & 3 deletions pkg/deploy/generator/resources_oic.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ var (

func (g *generator) oicStorageAccount() *arm.Resource {
storageAccount := &mgmtstorage.Account{
Kind: mgmtstorage.StorageV2,
Kind: mgmtstorage.KindStorageV2,
Sku: &mgmtstorage.Sku{
Name: "Standard_LRS",
},
AccountProperties: &mgmtstorage.AccountProperties{
AllowBlobPublicAccess: to.BoolPtr(true),
EnableHTTPSTrafficOnly: to.BoolPtr(true),
MinimumTLSVersion: mgmtstorage.TLS12,
AccessTier: mgmtstorage.Hot,
MinimumTLSVersion: mgmtstorage.MinimumTLSVersionTLS12,
AccessTier: mgmtstorage.AccessTierHot,
},
Name: to.StringPtr(fmt.Sprintf("[%s]", storageAccountName)),
Location: to.StringPtr("[resourceGroup().location]"),
Expand Down
4 changes: 2 additions & 2 deletions pkg/deploy/saveversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ func (d *deployer) SaveVersion(ctx context.Context) error {
t := time.Now().UTC().Truncate(time.Second)
res, err := d.globalaccounts.ListAccountSAS(
ctx, *d.config.Configuration.GlobalResourceGroupName, *d.config.Configuration.RPVersionStorageAccountName, mgmtstorage.AccountSasParameters{
Services: mgmtstorage.B,
Services: mgmtstorage.ServicesB,
ResourceTypes: mgmtstorage.SignedResourceTypesO,
Permissions: "cw", // create and write
Protocols: mgmtstorage.HTTPS,
Protocols: mgmtstorage.HTTPProtocolHTTPS,
SharedAccessStartTime: &date.Time{Time: t},
SharedAccessExpiryTime: &date.Time{Time: t.Add(24 * time.Hour)},
})
Expand Down
6 changes: 3 additions & 3 deletions pkg/frontend/adminactions/vmserialconsole.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ func (a *azureActions) VMSerialConsole(ctx context.Context, w http.ResponseWrite
t := time.Now().UTC().Truncate(time.Second)
res, err := a.storageAccounts.ListAccountSAS(
ctx, clusterRGName, "cluster"+a.oc.Properties.StorageSuffix, mgmtstorage.AccountSasParameters{
Services: mgmtstorage.B,
Services: mgmtstorage.ServicesB,
ResourceTypes: mgmtstorage.SignedResourceTypesO,
Permissions: mgmtstorage.R,
Protocols: mgmtstorage.HTTPS,
Permissions: mgmtstorage.PermissionsR,
Protocols: mgmtstorage.HTTPProtocolHTTPS,
SharedAccessStartTime: &date.Time{Time: t},
SharedAccessExpiryTime: &date.Time{Time: t.Add(24 * time.Hour)},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (r *reconcileManager) reconcileAccounts(ctx context.Context) error {
if !found {
*account.AccountProperties.NetworkRuleSet.VirtualNetworkRules = append(*account.AccountProperties.NetworkRuleSet.VirtualNetworkRules, mgmtstorage.VirtualNetworkRule{
VirtualNetworkResourceID: to.StringPtr(subnet),
Action: mgmtstorage.Allow,
Action: mgmtstorage.ActionAllow,
})
changed = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func getValidAccount(virtualNetworkResourceIDs []string) *mgmtstorage.Account {
for _, rule := range virtualNetworkResourceIDs {
*account.AccountProperties.NetworkRuleSet.VirtualNetworkRules = append(*account.AccountProperties.NetworkRuleSet.VirtualNetworkRules, mgmtstorage.VirtualNetworkRule{
VirtualNetworkResourceID: to.StringPtr(rule),
Action: mgmtstorage.Allow,
Action: mgmtstorage.ActionAllow,
})
}
return account
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/azureclient/apiversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var apiVersions = map[string]string{
"microsoft.network": "2020-08-01",
"microsoft.network/dnszones": "2018-05-01",
"microsoft.network/privatednszones": "2018-09-01",
"microsoft.storage": "2019-06-01",
"microsoft.storage": "2021-09-01",
}

// APIVersion gets the APIVersion from a full resource type
Expand Down
Loading

0 comments on commit 59a0b52

Please sign in to comment.