@@ -43,6 +43,7 @@ type Provider struct {
4343var _ clusterapi.PreProvider = (* Provider )(nil )
4444var _ clusterapi.InfraReadyProvider = (* Provider )(nil )
4545var _ clusterapi.PostProvider = (* Provider )(nil )
46+ var _ clusterapi.IgnitionProvider = (* Provider )(nil )
4647
4748// Name returns the name of the provider.
4849func (p * Provider ) Name () string {
@@ -69,6 +70,7 @@ func (p *Provider) PreProvision(ctx context.Context, in clusterapi.PreProvisionI
6970 for k , v := range userTags {
7071 tags [k ] = ptr .To (v )
7172 }
73+ p .Tags = tags
7274
7375 // Create resource group
7476 resourcesClientFactory , err := armresources .NewClientFactory (
@@ -98,9 +100,7 @@ func (p *Provider) PreProvision(ctx context.Context, in clusterapi.PreProvisionI
98100 return fmt .Errorf ("error creating resource group %s: %w" , resourceGroupName , err )
99101 }
100102 logrus .Debugf ("ResourceGroup.ID=%s" , * resourceGroup .ID )
101-
102103 p .ResourceGroupName = resourceGroupName
103- p .Tags = tags
104104
105105 return nil
106106}
@@ -116,9 +116,8 @@ func (p *Provider) InfraReady(ctx context.Context, in clusterapi.InfraReadyInput
116116 platform := installConfig .Platform .Azure
117117 subscriptionID := session .Credentials .SubscriptionID
118118 cloudConfiguration := session .CloudConfig
119- resourceGroupName := p .ResourceGroupName
120- tags := p .Tags
121119
120+ resourceGroupName := p .ResourceGroupName
122121 storageAccountName := fmt .Sprintf ("cluster%s" , randomString (5 ))
123122 containerName := "vhd"
124123 blobName := fmt .Sprintf ("rhcos%s.vhd" , randomString (5 ))
@@ -155,6 +154,13 @@ func (p *Provider) InfraReady(ctx context.Context, in clusterapi.InfraReadyInput
155154 return fmt .Errorf ("image length is not alisnged on a 512 byte boundary" )
156155 }
157156
157+ userTags := platform .UserTags
158+ tags := make (map [string ]* string , len (userTags )+ 1 )
159+ tags [fmt .Sprintf ("kubernetes.io_cluster.%s" , in .InfraID )] = ptr .To ("owned" )
160+ for k , v := range userTags {
161+ tags [k ] = ptr .To (v )
162+ }
163+
158164 tokenCredential := session .TokenCreds
159165 storageURL := fmt .Sprintf ("https://%s.blob.core.windows.net" , storageAccountName )
160166 blobURL := fmt .Sprintf ("%s/%s/%s" , storageURL , containerName , blobName )
@@ -470,3 +476,51 @@ func randomString(length int) string {
470476
471477 return string (s )
472478}
479+
480+ // Ignition provisions the Azure container that holds the bootstrap ignition
481+ // file.
482+ func (p Provider ) Ignition (ctx context.Context , in clusterapi.IgnitionInput ) ([]byte , error ) {
483+ session , err := in .InstallConfig .Azure .Session ()
484+ if err != nil {
485+ return nil , fmt .Errorf ("failed to get session: %w" , err )
486+ }
487+
488+ bootstrapIgnData := in .BootstrapIgnData
489+ subscriptionID := session .Credentials .SubscriptionID
490+ cloudConfiguration := session .CloudConfig
491+
492+ ignitionContainerName := "ignition"
493+ blobName := "bootstrap.ign"
494+ blobURL := fmt .Sprintf ("%s/%s/%s" , p .StorageURL , ignitionContainerName , blobName )
495+
496+ // Create ignition blob storage container
497+ createBlobContainerOutput , err := CreateBlobContainer (ctx , & CreateBlobContainerInput {
498+ ContainerName : ignitionContainerName ,
499+ SubscriptionID : subscriptionID ,
500+ ResourceGroupName : p .ResourceGroupName ,
501+ StorageAccountName : p .StorageAccountName ,
502+ StorageClientFactory : p .StorageClientFactory ,
503+ })
504+ if err != nil {
505+ return nil , err
506+ }
507+
508+ blobIgnitionContainer := createBlobContainerOutput .BlobContainer
509+ logrus .Debugf ("BlobIgnitionContainer.ID=%s" , * blobIgnitionContainer .ID )
510+
511+ _ , err = CreateBlockBlob (ctx , & CreateBlockBlobInput {
512+ StorageURL : p .StorageURL ,
513+ BlobURL : blobURL ,
514+ StorageAccountName : p .StorageAccountName ,
515+ StorageAccountKeys : p .StorageAccountKeys ,
516+ CloudConfiguration : cloudConfiguration ,
517+ BootstrapIgnData : bootstrapIgnData ,
518+ })
519+ if err != nil {
520+ return nil , err
521+ }
522+
523+ // XXX access it as SAS
524+
525+ return []byte {}, nil
526+ }
0 commit comments