Sitelet https://github.com/kubernetes/kops/pull/18636/files
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
234 changes: 107 additions & 127 deletions tests/integration/update_cluster/gossip-azure/kubernetes.tf

Large diffs are not rendered by default.

234 changes: 107 additions & 127 deletions tests/integration/update_cluster/minimal_azure/kubernetes.tf

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions upup/pkg/fi/cloudup/apply_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ func (c *ApplyClusterCmd) Run(ctx context.Context) (*ApplyResults, error) {
args["subscription_id"] = storageAccountID.SubscriptionID
}
}
tf.AzureStorageAccountID = azureSpec.StorageAccountID
tf.EnsureTerraformProvider("azurerm", args)
}

Expand Down
14 changes: 7 additions & 7 deletions upup/pkg/fi/cloudup/azuretasks/vmscaleset_terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ type terraformAzureVMScaleSetIPConfiguration struct {
}

type terraformAzureVMScaleSetNetworkInterface struct {
Name *string `cty:"name"`
Primary *bool `cty:"primary"`
EnableIPForwarding *bool `cty:"enable_ip_forwarding"`
IPConfiguration []*terraformAzureVMScaleSetIPConfiguration `cty:"ip_configuration"`
Name *string `cty:"name"`
Primary *bool `cty:"primary"`
IPForwardingEnabled *bool `cty:"ip_forwarding_enabled"`
IPConfiguration []*terraformAzureVMScaleSetIPConfiguration `cty:"ip_configuration"`
}

type terraformAzureVMScaleSetIdentity struct {
Expand Down Expand Up @@ -144,9 +144,9 @@ func (*VMScaleSet) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *
}
tf.NetworkInterface = []*terraformAzureVMScaleSetNetworkInterface{
{
Name: e.Name,
Primary: new(true),
EnableIPForwarding: new(true),
Name: e.Name,
Primary: new(true),
IPForwardingEnabled: new(true),
IPConfiguration: []*terraformAzureVMScaleSetIPConfiguration{
ipConfig,
},
Expand Down
2 changes: 1 addition & 1 deletion upup/pkg/fi/cloudup/terraform/target_hcl2.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func (t *TerraformTarget) writeTerraform(buf *bytes.Buffer) {
},
"azurerm": {
"source": "hashicorp/azurerm",
"version": ">= 4.0.0",
"version": ">= 5.0.0",
},
}

Expand Down
6 changes: 6 additions & 0 deletions upup/pkg/fi/cloudup/terraformWriter/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ type TerraformWriter struct {
// Providers is a list of TF Providers we need for writing files
Providers map[string]*TerraformProvider

// AzureStorageAccountID is the Azure Resource Manager ID of the storage
// account holding the cluster's state blobs. It is needed to build the
// storage_container_id argument of azurerm_storage_blob resources, which
// the azurerm provider requires as of v5.0.
AzureStorageAccountID string

// Files is a map of TF resource Files that should be created
Files map[string][]byte
}
Expand Down
25 changes: 13 additions & 12 deletions util/pkg/vfs/azureblob_terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ import (
)

type terraformAzureBlobFile struct {
Name string `cty:"name"`
StorageAccountName string `cty:"storage_account_name"`
StorageContainerName string `cty:"storage_container_name"`
Type string `cty:"type"`
Source *terraformWriter.Literal `cty:"source"`
Provider *terraformWriter.Literal `cty:"provider"`
Name string `cty:"name"`
StorageContainerID string `cty:"storage_container_id"`
Type string `cty:"type"`
Source *terraformWriter.Literal `cty:"source"`
Provider *terraformWriter.Literal `cty:"provider"`
}

func (p *AzureBlobPath) RenderTerraform(w *terraformWriter.TerraformWriter, name string, data io.Reader, acl ACL) error {
Expand All @@ -43,19 +42,21 @@ func (p *AzureBlobPath) RenderTerraform(w *terraformWriter.TerraformWriter, name
if p.account == "" {
return fmt.Errorf("Azure storage account is not set on path %q", p.Path())
}
if w.AzureStorageAccountID == "" {
return fmt.Errorf("Azure storage account ID is not set; it is required to render blob %q", p.Path())
}

source, err := w.AddFilePath("azurerm_storage_blob", name, "source", bytes, false)
if err != nil {
return fmt.Errorf("rendering Azure Blob file: %w", err)
}

tf := &terraformAzureBlobFile{
Name: p.key,
StorageAccountName: p.account,
StorageContainerName: p.container,
Type: "Block",
Source: source,
Provider: terraformWriter.LiteralTokens("azurerm", "files"),
Name: p.key,
StorageContainerID: w.AzureStorageAccountID + "/blobServices/default/containers/" + p.container,
Type: "Block",
Source: source,
Provider: terraformWriter.LiteralTokens("azurerm", "files"),
}
return w.RenderResource("azurerm_storage_blob", name, tf)
}
14 changes: 7 additions & 7 deletions util/pkg/vfs/memfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,14 @@ func (p *MemFSPath) renderTerraformAzure(w *terraformWriter.TerraformWriter, nam
}

// memfs:// paths don't encode an Azure account or container, so this
// fallback (only used in integration tests) hard-codes test placeholders.
// fallback (only used in integration tests) hard-codes a test placeholder
// container on the storage account from the cluster spec.
tf := &terraformAzureBlobFile{
Name: p.location,
StorageAccountName: "teststorage",
StorageContainerName: "testcontainer",
Type: "Block",
Source: source,
Provider: terraformWriter.LiteralTokens("azurerm", "files"),
Name: p.location,
StorageContainerID: w.AzureStorageAccountID + "/blobServices/default/containers/testcontainer",
Type: "Block",
Source: source,
Provider: terraformWriter.LiteralTokens("azurerm", "files"),
}
return w.RenderResource("azurerm_storage_blob", name, tf)
}
Expand Down
Loading