зеркало из https://github.com/Azure/ARO-RP.git
continue to reduce use of api.OpenShiftClusterDocument
This commit is contained in:
Родитель
c7fcae014d
Коммит
4301a91a9f
|
@ -133,10 +133,10 @@ func (b *backend) handle(ctx context.Context, log *logrus.Entry, doc *api.OpenSh
|
|||
switch doc.OpenShiftCluster.Properties.ProvisioningState {
|
||||
case api.ProvisioningStateUpdating:
|
||||
log.Print("updating")
|
||||
err = b.update(ctx, log, doc)
|
||||
err = b.update(ctx, log, doc.OpenShiftCluster)
|
||||
case api.ProvisioningStateDeleting:
|
||||
log.Print("deleting")
|
||||
err = b.delete(ctx, log, doc)
|
||||
err = b.delete(ctx, log, doc.OpenShiftCluster)
|
||||
}
|
||||
|
||||
stop()
|
||||
|
|
|
@ -15,8 +15,8 @@ import (
|
|||
"github.com/jim-minter/rp/pkg/util/subnet"
|
||||
)
|
||||
|
||||
func (b *backend) delete(ctx context.Context, log *logrus.Entry, doc *api.OpenShiftClusterDocument) error {
|
||||
r, err := azure.ParseResourceID(doc.OpenShiftCluster.ID)
|
||||
func (b *backend) delete(ctx context.Context, log *logrus.Entry, oc *api.OpenShiftCluster) error {
|
||||
r, err := azure.ParseResourceID(oc.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -29,18 +29,18 @@ func (b *backend) delete(ctx context.Context, log *logrus.Entry, doc *api.OpenSh
|
|||
groups.Client.PollingDuration = time.Hour
|
||||
|
||||
log.Printf("deleting dns")
|
||||
_, err = recordsets.Delete(ctx, os.Getenv("RESOURCEGROUP"), b.domain, "api."+doc.OpenShiftCluster.Name, dns.CNAME, "")
|
||||
_, err = recordsets.Delete(ctx, os.Getenv("RESOURCEGROUP"), b.domain, "api."+oc.Name, dns.CNAME, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: ideally we would do this after all the VMs have been deleted
|
||||
for _, subnetID := range []string{
|
||||
doc.OpenShiftCluster.Properties.MasterProfile.SubnetID,
|
||||
doc.OpenShiftCluster.Properties.WorkerProfiles[0].SubnetID,
|
||||
oc.Properties.MasterProfile.SubnetID,
|
||||
oc.Properties.WorkerProfiles[0].SubnetID,
|
||||
} {
|
||||
// TODO: there is probably an undesirable race condition here - check if etags can help.
|
||||
s, err := subnet.Get(ctx, &doc.OpenShiftCluster.Properties.ServicePrincipalProfile, subnetID)
|
||||
s, err := subnet.Get(ctx, &oc.Properties.ServicePrincipalProfile, subnetID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -49,14 +49,14 @@ func (b *backend) delete(ctx context.Context, log *logrus.Entry, doc *api.OpenSh
|
|||
s.SubnetPropertiesFormat.NetworkSecurityGroup = nil
|
||||
|
||||
log.Printf("removing network security group from subnet %s", subnetID)
|
||||
err = subnet.CreateOrUpdate(ctx, &doc.OpenShiftCluster.Properties.ServicePrincipalProfile, subnetID, s)
|
||||
err = subnet.CreateOrUpdate(ctx, &oc.Properties.ServicePrincipalProfile, subnetID, s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resp, err := groups.CheckExistence(ctx, doc.OpenShiftCluster.Properties.ResourceGroup)
|
||||
resp, err := groups.CheckExistence(ctx, oc.Properties.ResourceGroup)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ func (b *backend) delete(ctx context.Context, log *logrus.Entry, doc *api.OpenSh
|
|||
return nil
|
||||
}
|
||||
|
||||
log.Printf("deleting resource group %s", doc.OpenShiftCluster.Properties.ResourceGroup)
|
||||
future, err := groups.Delete(ctx, doc.OpenShiftCluster.Properties.ResourceGroup)
|
||||
log.Printf("deleting resource group %s", oc.Properties.ResourceGroup)
|
||||
future, err := groups.Delete(ctx, oc.Properties.ResourceGroup)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -23,18 +23,18 @@ import (
|
|||
"github.com/jim-minter/rp/pkg/util/subnet"
|
||||
)
|
||||
|
||||
func (b *backend) install(ctx context.Context, log *logrus.Entry, doc *api.OpenShiftClusterDocument) error {
|
||||
r, err := azure.ParseResourceID(doc.OpenShiftCluster.ID)
|
||||
func (b *backend) install(ctx context.Context, log *logrus.Entry, oc *api.OpenShiftCluster) error {
|
||||
r, err := azure.ParseResourceID(oc.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
vnetID, masterSubnetName, err := subnet.Split(doc.OpenShiftCluster.Properties.MasterProfile.SubnetID)
|
||||
vnetID, masterSubnetName, err := subnet.Split(oc.Properties.MasterProfile.SubnetID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
vnetID, workerSubnetName, err := subnet.Split(doc.OpenShiftCluster.Properties.WorkerProfiles[0].SubnetID)
|
||||
vnetID, workerSubnetName, err := subnet.Split(oc.Properties.WorkerProfiles[0].SubnetID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func (b *backend) install(ctx context.Context, log *logrus.Entry, doc *api.OpenS
|
|||
return err
|
||||
}
|
||||
|
||||
sshkey, err := ssh.NewPublicKey(&doc.OpenShiftCluster.Properties.SSHKey.PublicKey)
|
||||
sshkey, err := ssh.NewPublicKey(&oc.Properties.SSHKey.PublicKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -52,8 +52,8 @@ func (b *backend) install(ctx context.Context, log *logrus.Entry, doc *api.OpenS
|
|||
platformCreds := &installconfig.PlatformCreds{
|
||||
Azure: &icazure.Credentials{
|
||||
TenantID: os.Getenv("AZURE_TENANT_ID"),
|
||||
ClientID: doc.OpenShiftCluster.Properties.ServicePrincipalProfile.ClientID,
|
||||
ClientSecret: doc.OpenShiftCluster.Properties.ServicePrincipalProfile.ClientSecret,
|
||||
ClientID: oc.Properties.ServicePrincipalProfile.ClientID,
|
||||
ClientSecret: oc.Properties.ServicePrincipalProfile.ClientSecret,
|
||||
SubscriptionID: r.SubscriptionID,
|
||||
},
|
||||
Passthrough: true, // TODO: not working yet
|
||||
|
@ -65,7 +65,7 @@ func (b *backend) install(ctx context.Context, log *logrus.Entry, doc *api.OpenS
|
|||
APIVersion: "v1",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: doc.OpenShiftCluster.Name,
|
||||
Name: oc.Name,
|
||||
},
|
||||
SSHKey: sshkey.Type() + " " + base64.StdEncoding.EncodeToString(sshkey.Marshal()),
|
||||
BaseDomain: b.domain,
|
||||
|
@ -74,12 +74,12 @@ func (b *backend) install(ctx context.Context, log *logrus.Entry, doc *api.OpenS
|
|||
NetworkType: "OpenShiftSDN",
|
||||
ClusterNetwork: []types.ClusterNetworkEntry{
|
||||
{
|
||||
CIDR: *ipnet.MustParseCIDR(doc.OpenShiftCluster.Properties.NetworkProfile.PodCIDR),
|
||||
CIDR: *ipnet.MustParseCIDR(oc.Properties.NetworkProfile.PodCIDR),
|
||||
HostPrefix: 23,
|
||||
},
|
||||
},
|
||||
ServiceNetwork: []ipnet.IPNet{
|
||||
*ipnet.MustParseCIDR(doc.OpenShiftCluster.Properties.NetworkProfile.ServiceCIDR),
|
||||
*ipnet.MustParseCIDR(oc.Properties.NetworkProfile.ServiceCIDR),
|
||||
},
|
||||
},
|
||||
ControlPlane: &types.MachinePool{
|
||||
|
@ -87,20 +87,20 @@ func (b *backend) install(ctx context.Context, log *logrus.Entry, doc *api.OpenS
|
|||
Replicas: to.Int64Ptr(3),
|
||||
Platform: types.MachinePoolPlatform{
|
||||
Azure: &azuretypes.MachinePool{
|
||||
InstanceType: string(doc.OpenShiftCluster.Properties.MasterProfile.VMSize),
|
||||
InstanceType: string(oc.Properties.MasterProfile.VMSize),
|
||||
},
|
||||
},
|
||||
Hyperthreading: "Enabled",
|
||||
},
|
||||
Compute: []types.MachinePool{
|
||||
{
|
||||
Name: doc.OpenShiftCluster.Properties.WorkerProfiles[0].Name,
|
||||
Replicas: to.Int64Ptr(int64(doc.OpenShiftCluster.Properties.WorkerProfiles[0].Count)),
|
||||
Name: oc.Properties.WorkerProfiles[0].Name,
|
||||
Replicas: to.Int64Ptr(int64(oc.Properties.WorkerProfiles[0].Count)),
|
||||
Platform: types.MachinePoolPlatform{
|
||||
Azure: &azuretypes.MachinePool{
|
||||
InstanceType: string(doc.OpenShiftCluster.Properties.WorkerProfiles[0].VMSize),
|
||||
InstanceType: string(oc.Properties.WorkerProfiles[0].VMSize),
|
||||
OSDisk: azuretypes.OSDisk{
|
||||
DiskSizeGB: int32(doc.OpenShiftCluster.Properties.WorkerProfiles[0].DiskSizeGB),
|
||||
DiskSizeGB: int32(oc.Properties.WorkerProfiles[0].DiskSizeGB),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -109,8 +109,8 @@ func (b *backend) install(ctx context.Context, log *logrus.Entry, doc *api.OpenS
|
|||
},
|
||||
Platform: types.Platform{
|
||||
Azure: &azuretypes.Platform{
|
||||
Region: doc.OpenShiftCluster.Location,
|
||||
ResourceGroupName: doc.OpenShiftCluster.Properties.ResourceGroup,
|
||||
Region: oc.Location,
|
||||
ResourceGroupName: oc.Properties.ResourceGroup,
|
||||
BaseDomainResourceGroupName: os.Getenv("RESOURCEGROUP"),
|
||||
NetworkResourceGroupName: vnetr.ResourceGroup,
|
||||
VirtualNetwork: vnetr.ResourceName,
|
||||
|
@ -128,5 +128,5 @@ func (b *backend) install(ctx context.Context, log *logrus.Entry, doc *api.OpenS
|
|||
return err
|
||||
}
|
||||
|
||||
return install.NewInstaller(log, b.db, b.domain, b.authorizer, r.SubscriptionID).Install(ctx, doc, installConfig, platformCreds)
|
||||
return install.NewInstaller(log, b.db, b.domain, b.authorizer, r.SubscriptionID).Install(ctx, oc, installConfig, platformCreds)
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ func find(xs interface{}, f func(int, int) bool) interface{} {
|
|||
return v.Index(j).Addr().Interface()
|
||||
}
|
||||
|
||||
func (b *backend) scale(ctx context.Context, log *logrus.Entry, doc *api.OpenShiftClusterDocument) error {
|
||||
restConfig, err := restconfig.RestConfig(doc.OpenShiftCluster.Properties.AdminKubeconfig)
|
||||
func (b *backend) scale(ctx context.Context, log *logrus.Entry, oc *api.OpenShiftCluster) error {
|
||||
restConfig, err := restconfig.RestConfig(oc.Properties.AdminKubeconfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -51,13 +51,13 @@ func (b *backend) scale(ctx context.Context, log *logrus.Entry, doc *api.OpenShi
|
|||
have += int(*m.Spec.Replicas)
|
||||
}
|
||||
|
||||
for have > doc.OpenShiftCluster.Properties.WorkerProfiles[0].Count {
|
||||
for have > oc.Properties.WorkerProfiles[0].Count {
|
||||
m := find(l.Items, func(i, j int) bool { return *l.Items[i].Spec.Replicas > *l.Items[j].Spec.Replicas }).(*machinev1beta1.MachineSet)
|
||||
*m.Spec.Replicas--
|
||||
have--
|
||||
}
|
||||
|
||||
for have < doc.OpenShiftCluster.Properties.WorkerProfiles[0].Count {
|
||||
for have < oc.Properties.WorkerProfiles[0].Count {
|
||||
m := find(l.Items, func(i, j int) bool { return *l.Items[i].Spec.Replicas < *l.Items[j].Spec.Replicas }).(*machinev1beta1.MachineSet)
|
||||
*m.Spec.Replicas++
|
||||
have++
|
||||
|
|
|
@ -8,10 +8,10 @@ import (
|
|||
"github.com/jim-minter/rp/pkg/api"
|
||||
)
|
||||
|
||||
func (b *backend) update(ctx context.Context, log *logrus.Entry, doc *api.OpenShiftClusterDocument) error {
|
||||
if doc.OpenShiftCluster.Properties.Installation != nil {
|
||||
return b.install(ctx, log, doc)
|
||||
func (b *backend) update(ctx context.Context, log *logrus.Entry, oc *api.OpenShiftCluster) error {
|
||||
if oc.Properties.Installation != nil {
|
||||
return b.install(ctx, log, oc)
|
||||
}
|
||||
|
||||
return b.scale(ctx, log, doc)
|
||||
return b.scale(ctx, log, oc)
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ var apiVersions = map[string]string{
|
|||
"storage": "2019-04-01",
|
||||
}
|
||||
|
||||
func (i *Installer) installStorage(ctx context.Context, doc *api.OpenShiftClusterDocument, installConfig *installconfig.InstallConfig, platformCreds *installconfig.PlatformCreds) error {
|
||||
r, err := azure.ParseResourceID(doc.OpenShiftCluster.ID)
|
||||
func (i *Installer) installStorage(ctx context.Context, oc *api.OpenShiftCluster, installConfig *installconfig.InstallConfig, platformCreds *installconfig.PlatformCreds) error {
|
||||
r, err := azure.ParseResourceID(oc.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ func (i *Installer) installStorage(ctx context.Context, doc *api.OpenShiftCluste
|
|||
|
||||
clusterID := &installconfig.ClusterID{
|
||||
UUID: uuid.NewV4().String(),
|
||||
InfraID: doc.OpenShiftCluster.Name,
|
||||
InfraID: oc.Name,
|
||||
}
|
||||
|
||||
g := graph{
|
||||
|
@ -79,7 +79,7 @@ func (i *Installer) installStorage(ctx context.Context, doc *api.OpenShiftCluste
|
|||
rhcosImage := g[reflect.TypeOf(new(rhcos.Image))].(*rhcos.Image)
|
||||
|
||||
i.log.Print("creating resource group")
|
||||
_, err = i.groups.CreateOrUpdate(ctx, doc.OpenShiftCluster.Properties.ResourceGroup, resources.Group{
|
||||
_, err = i.groups.CreateOrUpdate(ctx, oc.Properties.ResourceGroup, resources.Group{
|
||||
Location: &installConfig.Config.Azure.Region,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -107,7 +107,7 @@ func (i *Installer) installStorage(ctx context.Context, doc *api.OpenShiftCluste
|
|||
Sku: &storage.Sku{
|
||||
Name: "Standard_LRS",
|
||||
},
|
||||
Name: to.StringPtr("cluster" + doc.OpenShiftCluster.Properties.StorageSuffix),
|
||||
Name: to.StringPtr("cluster" + oc.Properties.StorageSuffix),
|
||||
Location: &installConfig.Config.Azure.Region,
|
||||
Type: to.StringPtr("Microsoft.Storage/storageAccounts"),
|
||||
},
|
||||
|
@ -116,32 +116,32 @@ func (i *Installer) installStorage(ctx context.Context, doc *api.OpenShiftCluste
|
|||
{
|
||||
// should go away when we use a cloud partner image
|
||||
Resource: &storage.BlobContainer{
|
||||
Name: to.StringPtr("cluster" + doc.OpenShiftCluster.Properties.StorageSuffix + "/default/vhd"),
|
||||
Name: to.StringPtr("cluster" + oc.Properties.StorageSuffix + "/default/vhd"),
|
||||
Type: to.StringPtr("Microsoft.Storage/storageAccounts/blobServices/containers"),
|
||||
},
|
||||
APIVersion: apiVersions["storage"],
|
||||
DependsOn: []string{
|
||||
"Microsoft.Storage/storageAccounts/cluster" + doc.OpenShiftCluster.Properties.StorageSuffix,
|
||||
"Microsoft.Storage/storageAccounts/cluster" + oc.Properties.StorageSuffix,
|
||||
},
|
||||
},
|
||||
{
|
||||
Resource: &storage.BlobContainer{
|
||||
Name: to.StringPtr("cluster" + doc.OpenShiftCluster.Properties.StorageSuffix + "/default/ignition"),
|
||||
Name: to.StringPtr("cluster" + oc.Properties.StorageSuffix + "/default/ignition"),
|
||||
Type: to.StringPtr("Microsoft.Storage/storageAccounts/blobServices/containers"),
|
||||
},
|
||||
APIVersion: apiVersions["storage"],
|
||||
DependsOn: []string{
|
||||
"Microsoft.Storage/storageAccounts/cluster" + doc.OpenShiftCluster.Properties.StorageSuffix,
|
||||
"Microsoft.Storage/storageAccounts/cluster" + oc.Properties.StorageSuffix,
|
||||
},
|
||||
},
|
||||
{
|
||||
Resource: &storage.BlobContainer{
|
||||
Name: to.StringPtr("cluster" + doc.OpenShiftCluster.Properties.StorageSuffix + "/default/aro"),
|
||||
Name: to.StringPtr("cluster" + oc.Properties.StorageSuffix + "/default/aro"),
|
||||
Type: to.StringPtr("Microsoft.Storage/storageAccounts/blobServices/containers"),
|
||||
},
|
||||
APIVersion: apiVersions["storage"],
|
||||
DependsOn: []string{
|
||||
"Microsoft.Storage/storageAccounts/cluster" + doc.OpenShiftCluster.Properties.StorageSuffix,
|
||||
"Microsoft.Storage/storageAccounts/cluster" + oc.Properties.StorageSuffix,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -194,7 +194,7 @@ func (i *Installer) installStorage(ctx context.Context, doc *api.OpenShiftCluste
|
|||
}
|
||||
|
||||
i.log.Print("deploying storage template")
|
||||
future, err := i.deployments.CreateOrUpdate(ctx, doc.OpenShiftCluster.Properties.ResourceGroup, "azuredeploy", resources.Deployment{
|
||||
future, err := i.deployments.CreateOrUpdate(ctx, oc.Properties.ResourceGroup, "azuredeploy", resources.Deployment{
|
||||
Properties: &resources.DeploymentProperties{
|
||||
Template: t,
|
||||
Mode: resources.Incremental,
|
||||
|
@ -212,14 +212,14 @@ func (i *Installer) installStorage(ctx context.Context, doc *api.OpenShiftCluste
|
|||
}
|
||||
|
||||
{
|
||||
blobService, err := i.getBlobService(ctx, doc.OpenShiftCluster)
|
||||
blobService, err := i.getBlobService(ctx, oc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// blob copying should go away when we use a cloud partner image
|
||||
i.log.Print("copying rhcos blob")
|
||||
rhcosVhd := blobService.GetContainerReference("vhd").GetBlobReference("rhcos" + doc.OpenShiftCluster.Properties.StorageSuffix + ".vhd")
|
||||
rhcosVhd := blobService.GetContainerReference("vhd").GetBlobReference("rhcos" + oc.Properties.StorageSuffix + ".vhd")
|
||||
err = rhcosVhd.Copy(string(*rhcosImage), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -255,13 +255,13 @@ func (i *Installer) installStorage(ctx context.Context, doc *api.OpenShiftCluste
|
|||
}
|
||||
|
||||
for subnetID, nsgID := range map[string]string{
|
||||
doc.OpenShiftCluster.Properties.MasterProfile.SubnetID: "/subscriptions/" + r.SubscriptionID + "/resourceGroups/" + doc.OpenShiftCluster.Properties.ResourceGroup + "/providers/Microsoft.Network/networkSecurityGroups/" + clusterID.InfraID + "-controlplane-nsg",
|
||||
doc.OpenShiftCluster.Properties.WorkerProfiles[0].SubnetID: "/subscriptions/" + r.SubscriptionID + "/resourceGroups/" + doc.OpenShiftCluster.Properties.ResourceGroup + "/providers/Microsoft.Network/networkSecurityGroups/" + clusterID.InfraID + "-node-nsg",
|
||||
oc.Properties.MasterProfile.SubnetID: "/subscriptions/" + r.SubscriptionID + "/resourceGroups/" + oc.Properties.ResourceGroup + "/providers/Microsoft.Network/networkSecurityGroups/" + clusterID.InfraID + "-controlplane-nsg",
|
||||
oc.Properties.WorkerProfiles[0].SubnetID: "/subscriptions/" + r.SubscriptionID + "/resourceGroups/" + oc.Properties.ResourceGroup + "/providers/Microsoft.Network/networkSecurityGroups/" + clusterID.InfraID + "-node-nsg",
|
||||
} {
|
||||
i.log.Printf("attaching network security group to subnet %s", subnetID)
|
||||
|
||||
// TODO: there is probably an undesirable race condition here - check if etags can help.
|
||||
s, err := subnet.Get(ctx, &doc.OpenShiftCluster.Properties.ServicePrincipalProfile, subnetID)
|
||||
s, err := subnet.Get(ctx, &oc.Properties.ServicePrincipalProfile, subnetID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -274,14 +274,14 @@ func (i *Installer) installStorage(ctx context.Context, doc *api.OpenShiftCluste
|
|||
ID: to.StringPtr(nsgID),
|
||||
}
|
||||
|
||||
err = subnet.CreateOrUpdate(ctx, &doc.OpenShiftCluster.Properties.ServicePrincipalProfile, subnetID, s)
|
||||
err = subnet.CreateOrUpdate(ctx, &oc.Properties.ServicePrincipalProfile, subnetID, s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
identity, err := i.userassignedidentities.Get(ctx, doc.OpenShiftCluster.Properties.ResourceGroup, clusterID.InfraID+"-identity")
|
||||
identity, err := i.userassignedidentities.Get(ctx, oc.Properties.ResourceGroup, clusterID.InfraID+"-identity")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ func (i *Installer) installStorage(ctx context.Context, doc *api.OpenShiftCluste
|
|||
}
|
||||
}
|
||||
|
||||
doc, err = i.db.Patch(doc.OpenShiftCluster.ID, func(doc *api.OpenShiftClusterDocument) (err error) {
|
||||
_, err = i.db.Patch(oc.ID, func(doc *api.OpenShiftClusterDocument) (err error) {
|
||||
// used for the SAS token with which the bootstrap node retrieves its
|
||||
// ignition payload
|
||||
doc.OpenShiftCluster.Properties.Installation.Now = time.Now().UTC()
|
||||
|
|
|
@ -28,8 +28,8 @@ import (
|
|||
"github.com/jim-minter/rp/pkg/util/subnet"
|
||||
)
|
||||
|
||||
func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClusterDocument) error {
|
||||
g, err := i.getGraph(ctx, doc.OpenShiftCluster)
|
||||
func (i *Installer) installResources(ctx context.Context, oc *api.OpenShiftCluster) error {
|
||||
g, err := i.getGraph(ctx, oc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -38,12 +38,12 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
machinesMaster := g[reflect.TypeOf(&machines.Master{})].(*machines.Master)
|
||||
machineMaster := g[reflect.TypeOf(&machine.Master{})].(*machine.Master)
|
||||
|
||||
vnetID, _, err := subnet.Split(doc.OpenShiftCluster.Properties.MasterProfile.SubnetID)
|
||||
vnetID, _, err := subnet.Split(oc.Properties.MasterProfile.SubnetID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
masterSubnet, err := subnet.Get(ctx, &doc.OpenShiftCluster.Properties.ServicePrincipalProfile, doc.OpenShiftCluster.Properties.MasterProfile.SubnetID)
|
||||
masterSubnet, err := subnet.Get(ctx, &oc.Properties.ServicePrincipalProfile, oc.Properties.MasterProfile.SubnetID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -81,12 +81,12 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
Resources: []arm.Resource{
|
||||
{
|
||||
Resource: &authorization.RoleAssignment{
|
||||
Name: to.StringPtr("[guid(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', '" + doc.OpenShiftCluster.Properties.ClusterID + "-identity'), 'contributor')]"),
|
||||
Name: to.StringPtr("[guid(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', '" + oc.Properties.ClusterID + "-identity'), 'contributor')]"),
|
||||
Type: to.StringPtr("Microsoft.Authorization/roleAssignments"),
|
||||
Properties: &authorization.RoleAssignmentPropertiesWithScope{
|
||||
Scope: to.StringPtr("[resourceGroup().id]"),
|
||||
RoleDefinitionID: to.StringPtr("[resourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]"), // Contributor
|
||||
PrincipalID: to.StringPtr("[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', '" + doc.OpenShiftCluster.Properties.ClusterID + "-identity'), '2018-11-30').principalId]"),
|
||||
PrincipalID: to.StringPtr("[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', '" + oc.Properties.ClusterID + "-identity'), '2018-11-30').principalId]"),
|
||||
},
|
||||
},
|
||||
APIVersion: apiVersions["authorization"],
|
||||
|
@ -174,7 +174,7 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
TTL: to.Int64Ptr(60),
|
||||
ARecords: &[]privatedns.ARecord{
|
||||
{
|
||||
Ipv4Address: to.StringPtr("[reference(resourceId('Microsoft.Network/networkInterfaces', concat('" + doc.OpenShiftCluster.Properties.ClusterID + "-master', copyIndex(), '-nic')), '2019-07-01').ipConfigurations[0].properties.privateIPAddress]"),
|
||||
Ipv4Address: to.StringPtr("[reference(resourceId('Microsoft.Network/networkInterfaces', concat('" + oc.Properties.ClusterID + "-master', copyIndex(), '-nic')), '2019-07-01').ipConfigurations[0].properties.privateIPAddress]"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -185,14 +185,14 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
Count: len(machinesMaster.MachineFiles),
|
||||
},
|
||||
DependsOn: []string{
|
||||
"[concat('Microsoft.Network/networkInterfaces/" + doc.OpenShiftCluster.Properties.ClusterID + "-master', copyIndex(), '-nic')]",
|
||||
"[concat('Microsoft.Network/networkInterfaces/" + oc.Properties.ClusterID + "-master', copyIndex(), '-nic')]",
|
||||
"Microsoft.Network/privateDnsZones/" + installConfig.Config.ObjectMeta.Name + "." + installConfig.Config.BaseDomain,
|
||||
},
|
||||
},
|
||||
{
|
||||
// TODO: upstream doesn't appear to wire this in to any vnet - investigate.
|
||||
Resource: &network.RouteTable{
|
||||
Name: to.StringPtr(doc.OpenShiftCluster.Properties.ClusterID + "-node-routetable"),
|
||||
Name: to.StringPtr(oc.Properties.ClusterID + "-node-routetable"),
|
||||
Type: to.StringPtr("Microsoft.Network/routeTables"),
|
||||
Location: &installConfig.Config.Azure.Region,
|
||||
},
|
||||
|
@ -206,7 +206,7 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{
|
||||
PublicIPAllocationMethod: network.Static,
|
||||
},
|
||||
Name: to.StringPtr(doc.OpenShiftCluster.Properties.ClusterID + "-bootstrap-pip"),
|
||||
Name: to.StringPtr(oc.Properties.ClusterID + "-bootstrap-pip"),
|
||||
Type: to.StringPtr("Microsoft.Network/publicIPAddresses"),
|
||||
Location: &installConfig.Config.Azure.Region,
|
||||
},
|
||||
|
@ -220,10 +220,10 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{
|
||||
PublicIPAllocationMethod: network.Static,
|
||||
DNSSettings: &network.PublicIPAddressDNSSettings{
|
||||
DomainNameLabel: &doc.OpenShiftCluster.Properties.ClusterID,
|
||||
DomainNameLabel: &oc.Properties.ClusterID,
|
||||
},
|
||||
},
|
||||
Name: to.StringPtr(doc.OpenShiftCluster.Properties.ClusterID + "-pip"),
|
||||
Name: to.StringPtr(oc.Properties.ClusterID + "-pip"),
|
||||
Type: to.StringPtr("Microsoft.Network/publicIPAddresses"),
|
||||
Location: &installConfig.Config.Azure.Region,
|
||||
},
|
||||
|
@ -239,7 +239,7 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
{
|
||||
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
|
||||
PublicIPAddress: &network.PublicIPAddress{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/publicIPAddresses', '" + doc.OpenShiftCluster.Properties.ClusterID + "-pip')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/publicIPAddresses', '" + oc.Properties.ClusterID + "-pip')]"),
|
||||
},
|
||||
},
|
||||
Name: to.StringPtr("public-lb-ip"),
|
||||
|
@ -247,20 +247,20 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
},
|
||||
BackendAddressPools: &[]network.BackendAddressPool{
|
||||
{
|
||||
Name: to.StringPtr(doc.OpenShiftCluster.Properties.ClusterID + "-public-lb-control-plane"),
|
||||
Name: to.StringPtr(oc.Properties.ClusterID + "-public-lb-control-plane"),
|
||||
},
|
||||
},
|
||||
LoadBalancingRules: &[]network.LoadBalancingRule{
|
||||
{
|
||||
LoadBalancingRulePropertiesFormat: &network.LoadBalancingRulePropertiesFormat{
|
||||
FrontendIPConfiguration: &network.SubResource{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', '" + doc.OpenShiftCluster.Properties.ClusterID + "-public-lb', 'public-lb-ip')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', '" + oc.Properties.ClusterID + "-public-lb', 'public-lb-ip')]"),
|
||||
},
|
||||
BackendAddressPool: &network.SubResource{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + doc.OpenShiftCluster.Properties.ClusterID + "-public-lb', '" + doc.OpenShiftCluster.Properties.ClusterID + "-public-lb-control-plane')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + oc.Properties.ClusterID + "-public-lb', '" + oc.Properties.ClusterID + "-public-lb-control-plane')]"),
|
||||
},
|
||||
Probe: &network.SubResource{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/probes', '" + doc.OpenShiftCluster.Properties.ClusterID + "-public-lb', 'api-internal-probe')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/probes', '" + oc.Properties.ClusterID + "-public-lb', 'api-internal-probe')]"),
|
||||
},
|
||||
Protocol: network.TransportProtocolTCP,
|
||||
LoadDistribution: network.LoadDistributionDefault,
|
||||
|
@ -284,13 +284,13 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
},
|
||||
},
|
||||
},
|
||||
Name: to.StringPtr(doc.OpenShiftCluster.Properties.ClusterID + "-public-lb"),
|
||||
Name: to.StringPtr(oc.Properties.ClusterID + "-public-lb"),
|
||||
Type: to.StringPtr("Microsoft.Network/loadBalancers"),
|
||||
Location: &installConfig.Config.Azure.Region,
|
||||
},
|
||||
APIVersion: apiVersions["network"],
|
||||
DependsOn: []string{
|
||||
"Microsoft.Network/publicIPAddresses/" + doc.OpenShiftCluster.Properties.ClusterID + "-pip",
|
||||
"Microsoft.Network/publicIPAddresses/" + oc.Properties.ClusterID + "-pip",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -305,7 +305,7 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
PrivateIPAddress: to.StringPtr(lbIP.String()),
|
||||
PrivateIPAllocationMethod: network.Static,
|
||||
Subnet: &network.Subnet{
|
||||
ID: to.StringPtr(doc.OpenShiftCluster.Properties.MasterProfile.SubnetID),
|
||||
ID: to.StringPtr(oc.Properties.MasterProfile.SubnetID),
|
||||
},
|
||||
},
|
||||
Name: to.StringPtr("internal-lb-ip"),
|
||||
|
@ -313,20 +313,20 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
},
|
||||
BackendAddressPools: &[]network.BackendAddressPool{
|
||||
{
|
||||
Name: to.StringPtr(doc.OpenShiftCluster.Properties.ClusterID + "-internal-controlplane"),
|
||||
Name: to.StringPtr(oc.Properties.ClusterID + "-internal-controlplane"),
|
||||
},
|
||||
},
|
||||
LoadBalancingRules: &[]network.LoadBalancingRule{
|
||||
{
|
||||
LoadBalancingRulePropertiesFormat: &network.LoadBalancingRulePropertiesFormat{
|
||||
FrontendIPConfiguration: &network.SubResource{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', '" + doc.OpenShiftCluster.Properties.ClusterID + "-internal-lb', 'internal-lb-ip')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', '" + oc.Properties.ClusterID + "-internal-lb', 'internal-lb-ip')]"),
|
||||
},
|
||||
BackendAddressPool: &network.SubResource{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + doc.OpenShiftCluster.Properties.ClusterID + "-internal-lb', '" + doc.OpenShiftCluster.Properties.ClusterID + "-internal-controlplane')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + oc.Properties.ClusterID + "-internal-lb', '" + oc.Properties.ClusterID + "-internal-controlplane')]"),
|
||||
},
|
||||
Probe: &network.SubResource{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/probes', '" + doc.OpenShiftCluster.Properties.ClusterID + "-internal-lb', 'api-internal-probe')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/probes', '" + oc.Properties.ClusterID + "-internal-lb', 'api-internal-probe')]"),
|
||||
},
|
||||
Protocol: network.TransportProtocolTCP,
|
||||
LoadDistribution: network.LoadDistributionDefault,
|
||||
|
@ -339,13 +339,13 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
{
|
||||
LoadBalancingRulePropertiesFormat: &network.LoadBalancingRulePropertiesFormat{
|
||||
FrontendIPConfiguration: &network.SubResource{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', '" + doc.OpenShiftCluster.Properties.ClusterID + "-internal-lb', 'internal-lb-ip')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', '" + oc.Properties.ClusterID + "-internal-lb', 'internal-lb-ip')]"),
|
||||
},
|
||||
BackendAddressPool: &network.SubResource{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + doc.OpenShiftCluster.Properties.ClusterID + "-internal-lb', '" + doc.OpenShiftCluster.Properties.ClusterID + "-internal-controlplane')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + oc.Properties.ClusterID + "-internal-lb', '" + oc.Properties.ClusterID + "-internal-controlplane')]"),
|
||||
},
|
||||
Probe: &network.SubResource{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/probes', '" + doc.OpenShiftCluster.Properties.ClusterID + "-internal-lb', 'sint-probe')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/probes', '" + oc.Properties.ClusterID + "-internal-lb', 'sint-probe')]"),
|
||||
},
|
||||
Protocol: network.TransportProtocolTCP,
|
||||
LoadDistribution: network.LoadDistributionDefault,
|
||||
|
@ -377,7 +377,7 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
},
|
||||
},
|
||||
},
|
||||
Name: to.StringPtr(doc.OpenShiftCluster.Properties.ClusterID + "-internal-lb"),
|
||||
Name: to.StringPtr(oc.Properties.ClusterID + "-internal-lb"),
|
||||
Type: to.StringPtr("Microsoft.Network/loadBalancers"),
|
||||
Location: &installConfig.Config.Azure.Region,
|
||||
},
|
||||
|
@ -394,32 +394,32 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
InterfaceIPConfigurationPropertiesFormat: &network.InterfaceIPConfigurationPropertiesFormat{
|
||||
LoadBalancerBackendAddressPools: &[]network.BackendAddressPool{
|
||||
{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + doc.OpenShiftCluster.Properties.ClusterID + "-public-lb', '" + doc.OpenShiftCluster.Properties.ClusterID + "-public-lb-control-plane')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + oc.Properties.ClusterID + "-public-lb', '" + oc.Properties.ClusterID + "-public-lb-control-plane')]"),
|
||||
},
|
||||
{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + doc.OpenShiftCluster.Properties.ClusterID + "-internal-lb', '" + doc.OpenShiftCluster.Properties.ClusterID + "-internal-controlplane')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + oc.Properties.ClusterID + "-internal-lb', '" + oc.Properties.ClusterID + "-internal-controlplane')]"),
|
||||
},
|
||||
},
|
||||
Subnet: &network.Subnet{
|
||||
ID: to.StringPtr(doc.OpenShiftCluster.Properties.MasterProfile.SubnetID),
|
||||
ID: to.StringPtr(oc.Properties.MasterProfile.SubnetID),
|
||||
},
|
||||
PublicIPAddress: &network.PublicIPAddress{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/publicIPAddresses', '" + doc.OpenShiftCluster.Properties.ClusterID + "-bootstrap-pip')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/publicIPAddresses', '" + oc.Properties.ClusterID + "-bootstrap-pip')]"),
|
||||
},
|
||||
},
|
||||
Name: to.StringPtr("bootstrap-nic-ip"),
|
||||
},
|
||||
},
|
||||
},
|
||||
Name: to.StringPtr(doc.OpenShiftCluster.Properties.ClusterID + "-bootstrap-nic"),
|
||||
Name: to.StringPtr(oc.Properties.ClusterID + "-bootstrap-nic"),
|
||||
Type: to.StringPtr("Microsoft.Network/networkInterfaces"),
|
||||
Location: &installConfig.Config.Azure.Region,
|
||||
},
|
||||
APIVersion: apiVersions["network"],
|
||||
DependsOn: []string{
|
||||
"Microsoft.Network/loadBalancers/" + doc.OpenShiftCluster.Properties.ClusterID + "-internal-lb",
|
||||
"Microsoft.Network/loadBalancers/" + doc.OpenShiftCluster.Properties.ClusterID + "-public-lb",
|
||||
"Microsoft.Network/publicIPAddresses/" + doc.OpenShiftCluster.Properties.ClusterID + "-bootstrap-pip",
|
||||
"Microsoft.Network/loadBalancers/" + oc.Properties.ClusterID + "-internal-lb",
|
||||
"Microsoft.Network/loadBalancers/" + oc.Properties.ClusterID + "-public-lb",
|
||||
"Microsoft.Network/publicIPAddresses/" + oc.Properties.ClusterID + "-bootstrap-pip",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -430,21 +430,21 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
InterfaceIPConfigurationPropertiesFormat: &network.InterfaceIPConfigurationPropertiesFormat{
|
||||
LoadBalancerBackendAddressPools: &[]network.BackendAddressPool{
|
||||
{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + doc.OpenShiftCluster.Properties.ClusterID + "-public-lb', '" + doc.OpenShiftCluster.Properties.ClusterID + "-public-lb-control-plane')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + oc.Properties.ClusterID + "-public-lb', '" + oc.Properties.ClusterID + "-public-lb-control-plane')]"),
|
||||
},
|
||||
{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + doc.OpenShiftCluster.Properties.ClusterID + "-internal-lb', '" + doc.OpenShiftCluster.Properties.ClusterID + "-internal-controlplane')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + oc.Properties.ClusterID + "-internal-lb', '" + oc.Properties.ClusterID + "-internal-controlplane')]"),
|
||||
},
|
||||
},
|
||||
Subnet: &network.Subnet{
|
||||
ID: to.StringPtr(doc.OpenShiftCluster.Properties.MasterProfile.SubnetID),
|
||||
ID: to.StringPtr(oc.Properties.MasterProfile.SubnetID),
|
||||
},
|
||||
},
|
||||
Name: to.StringPtr("pipConfig"),
|
||||
},
|
||||
},
|
||||
},
|
||||
Name: to.StringPtr("[concat('" + doc.OpenShiftCluster.Properties.ClusterID + "-master', copyIndex(), '-nic')]"),
|
||||
Name: to.StringPtr("[concat('" + oc.Properties.ClusterID + "-master', copyIndex(), '-nic')]"),
|
||||
Type: to.StringPtr("Microsoft.Network/networkInterfaces"),
|
||||
Location: &installConfig.Config.Azure.Region,
|
||||
},
|
||||
|
@ -454,8 +454,8 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
Count: len(machinesMaster.MachineFiles),
|
||||
},
|
||||
DependsOn: []string{
|
||||
"Microsoft.Network/loadBalancers/" + doc.OpenShiftCluster.Properties.ClusterID + "-internal-lb",
|
||||
"Microsoft.Network/loadBalancers/" + doc.OpenShiftCluster.Properties.ClusterID + "-public-lb",
|
||||
"Microsoft.Network/loadBalancers/" + oc.Properties.ClusterID + "-internal-lb",
|
||||
"Microsoft.Network/loadBalancers/" + oc.Properties.ClusterID + "-public-lb",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -464,12 +464,12 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
StorageProfile: &compute.ImageStorageProfile{
|
||||
OsDisk: &compute.ImageOSDisk{
|
||||
OsType: compute.Linux,
|
||||
BlobURI: to.StringPtr("https://cluster" + doc.OpenShiftCluster.Properties.StorageSuffix + ".blob.core.windows.net/vhd/rhcos" + doc.OpenShiftCluster.Properties.StorageSuffix + ".vhd"),
|
||||
BlobURI: to.StringPtr("https://cluster" + oc.Properties.StorageSuffix + ".blob.core.windows.net/vhd/rhcos" + oc.Properties.StorageSuffix + ".vhd"),
|
||||
},
|
||||
},
|
||||
HyperVGeneration: compute.HyperVGenerationTypesV1,
|
||||
},
|
||||
Name: &doc.OpenShiftCluster.Properties.ClusterID,
|
||||
Name: &oc.Properties.ClusterID,
|
||||
Type: to.StringPtr("Microsoft.Compute/images"),
|
||||
Location: &installConfig.Config.Azure.Region,
|
||||
},
|
||||
|
@ -483,10 +483,10 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
},
|
||||
StorageProfile: &compute.StorageProfile{
|
||||
ImageReference: &compute.ImageReference{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Compute/images', '" + doc.OpenShiftCluster.Properties.ClusterID + "')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Compute/images', '" + oc.Properties.ClusterID + "')]"),
|
||||
},
|
||||
OsDisk: &compute.OSDisk{
|
||||
Name: to.StringPtr(doc.OpenShiftCluster.Properties.ClusterID + "-bootstrap_OSDisk"),
|
||||
Name: to.StringPtr(oc.Properties.ClusterID + "-bootstrap_OSDisk"),
|
||||
Caching: compute.CachingTypesReadWrite,
|
||||
CreateOption: compute.DiskCreateOptionTypesFromImage,
|
||||
DiskSizeGB: to.Int32Ptr(100),
|
||||
|
@ -496,10 +496,10 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
},
|
||||
},
|
||||
OsProfile: &compute.OSProfile{
|
||||
ComputerName: to.StringPtr(doc.OpenShiftCluster.Properties.ClusterID + "-bootstrap-vm"),
|
||||
ComputerName: to.StringPtr(oc.Properties.ClusterID + "-bootstrap-vm"),
|
||||
AdminUsername: to.StringPtr("core"),
|
||||
AdminPassword: to.StringPtr("NotActuallyApplied!"),
|
||||
CustomData: to.StringPtr(`[base64(concat('{"ignition":{"version":"2.2.0","config":{"replace":{"source":"https://cluster` + doc.OpenShiftCluster.Properties.StorageSuffix + `.blob.core.windows.net/ignition/bootstrap.ign?', listAccountSas(resourceId('Microsoft.Storage/storageAccounts', 'cluster` + doc.OpenShiftCluster.Properties.StorageSuffix + `'), '2019-04-01', parameters('sas')).accountSasToken, '"}}}}'))]`),
|
||||
CustomData: to.StringPtr(`[base64(concat('{"ignition":{"version":"2.2.0","config":{"replace":{"source":"https://cluster` + oc.Properties.StorageSuffix + `.blob.core.windows.net/ignition/bootstrap.ign?', listAccountSas(resourceId('Microsoft.Storage/storageAccounts', 'cluster` + oc.Properties.StorageSuffix + `'), '2019-04-01', parameters('sas')).accountSasToken, '"}}}}'))]`),
|
||||
LinuxConfiguration: &compute.LinuxConfiguration{
|
||||
DisablePasswordAuthentication: to.BoolPtr(false),
|
||||
},
|
||||
|
@ -507,31 +507,31 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
NetworkProfile: &compute.NetworkProfile{
|
||||
NetworkInterfaces: &[]compute.NetworkInterfaceReference{
|
||||
{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/networkInterfaces', '" + doc.OpenShiftCluster.Properties.ClusterID + "-bootstrap-nic')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/networkInterfaces', '" + oc.Properties.ClusterID + "-bootstrap-nic')]"),
|
||||
},
|
||||
},
|
||||
},
|
||||
DiagnosticsProfile: &compute.DiagnosticsProfile{
|
||||
BootDiagnostics: &compute.BootDiagnostics{
|
||||
Enabled: to.BoolPtr(true),
|
||||
StorageURI: to.StringPtr("https://cluster" + doc.OpenShiftCluster.Properties.StorageSuffix + ".blob.core.windows.net/"),
|
||||
StorageURI: to.StringPtr("https://cluster" + oc.Properties.StorageSuffix + ".blob.core.windows.net/"),
|
||||
},
|
||||
},
|
||||
},
|
||||
Identity: &compute.VirtualMachineIdentity{
|
||||
Type: compute.ResourceIdentityTypeUserAssigned,
|
||||
UserAssignedIdentities: map[string]*compute.VirtualMachineIdentityUserAssignedIdentitiesValue{
|
||||
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', '" + doc.OpenShiftCluster.Properties.ClusterID + "-identity')]": &compute.VirtualMachineIdentityUserAssignedIdentitiesValue{},
|
||||
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', '" + oc.Properties.ClusterID + "-identity')]": &compute.VirtualMachineIdentityUserAssignedIdentitiesValue{},
|
||||
},
|
||||
},
|
||||
Name: to.StringPtr(doc.OpenShiftCluster.Properties.ClusterID + "-bootstrap"),
|
||||
Name: to.StringPtr(oc.Properties.ClusterID + "-bootstrap"),
|
||||
Type: to.StringPtr("Microsoft.Compute/virtualMachines"),
|
||||
Location: &installConfig.Config.Azure.Region,
|
||||
},
|
||||
APIVersion: apiVersions["compute"],
|
||||
DependsOn: []string{
|
||||
"Microsoft.Compute/images/" + doc.OpenShiftCluster.Properties.ClusterID,
|
||||
"Microsoft.Network/networkInterfaces/" + doc.OpenShiftCluster.Properties.ClusterID + "-bootstrap-nic",
|
||||
"Microsoft.Compute/images/" + oc.Properties.ClusterID,
|
||||
"Microsoft.Network/networkInterfaces/" + oc.Properties.ClusterID + "-bootstrap-nic",
|
||||
"Microsoft.Network/privateDnsZones/" + installConfig.Config.ObjectMeta.Name + "." + installConfig.Config.BaseDomain + "/virtualNetworkLinks/" + installConfig.Config.ObjectMeta.Name + "-network-link",
|
||||
},
|
||||
},
|
||||
|
@ -543,10 +543,10 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
},
|
||||
StorageProfile: &compute.StorageProfile{
|
||||
ImageReference: &compute.ImageReference{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Compute/images', '" + doc.OpenShiftCluster.Properties.ClusterID + "')]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Compute/images', '" + oc.Properties.ClusterID + "')]"),
|
||||
},
|
||||
OsDisk: &compute.OSDisk{
|
||||
Name: to.StringPtr("[concat('" + doc.OpenShiftCluster.Properties.ClusterID + "-master-', copyIndex(), '_OSDisk')]"),
|
||||
Name: to.StringPtr("[concat('" + oc.Properties.ClusterID + "-master-', copyIndex(), '_OSDisk')]"),
|
||||
Caching: compute.CachingTypesReadOnly,
|
||||
CreateOption: compute.DiskCreateOptionTypesFromImage,
|
||||
DiskSizeGB: &installConfig.Config.ControlPlane.Platform.Azure.OSDisk.DiskSizeGB,
|
||||
|
@ -556,7 +556,7 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
},
|
||||
},
|
||||
OsProfile: &compute.OSProfile{
|
||||
ComputerName: to.StringPtr("[concat('" + doc.OpenShiftCluster.Properties.ClusterID + "-master-', copyIndex())]"),
|
||||
ComputerName: to.StringPtr("[concat('" + oc.Properties.ClusterID + "-master-', copyIndex())]"),
|
||||
AdminUsername: to.StringPtr("core"),
|
||||
AdminPassword: to.StringPtr("NotActuallyApplied!"),
|
||||
CustomData: to.StringPtr(base64.StdEncoding.EncodeToString(machineMaster.File.Data)),
|
||||
|
@ -567,27 +567,27 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
NetworkProfile: &compute.NetworkProfile{
|
||||
NetworkInterfaces: &[]compute.NetworkInterfaceReference{
|
||||
{
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/networkInterfaces', concat('" + doc.OpenShiftCluster.Properties.ClusterID + "-master', copyIndex(), '-nic'))]"),
|
||||
ID: to.StringPtr("[resourceId('Microsoft.Network/networkInterfaces', concat('" + oc.Properties.ClusterID + "-master', copyIndex(), '-nic'))]"),
|
||||
},
|
||||
},
|
||||
},
|
||||
DiagnosticsProfile: &compute.DiagnosticsProfile{
|
||||
BootDiagnostics: &compute.BootDiagnostics{
|
||||
Enabled: to.BoolPtr(true),
|
||||
StorageURI: to.StringPtr("https://cluster" + doc.OpenShiftCluster.Properties.StorageSuffix + ".blob.core.windows.net/"),
|
||||
StorageURI: to.StringPtr("https://cluster" + oc.Properties.StorageSuffix + ".blob.core.windows.net/"),
|
||||
},
|
||||
},
|
||||
},
|
||||
Identity: &compute.VirtualMachineIdentity{
|
||||
Type: compute.ResourceIdentityTypeUserAssigned,
|
||||
UserAssignedIdentities: map[string]*compute.VirtualMachineIdentityUserAssignedIdentitiesValue{
|
||||
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', '" + doc.OpenShiftCluster.Properties.ClusterID + "-identity')]": &compute.VirtualMachineIdentityUserAssignedIdentitiesValue{},
|
||||
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', '" + oc.Properties.ClusterID + "-identity')]": &compute.VirtualMachineIdentityUserAssignedIdentitiesValue{},
|
||||
},
|
||||
},
|
||||
Zones: &[]string{
|
||||
"[copyIndex(1)]",
|
||||
},
|
||||
Name: to.StringPtr("[concat('" + doc.OpenShiftCluster.Properties.ClusterID + "-master-', copyIndex())]"),
|
||||
Name: to.StringPtr("[concat('" + oc.Properties.ClusterID + "-master-', copyIndex())]"),
|
||||
Type: to.StringPtr("Microsoft.Compute/virtualMachines"),
|
||||
Location: &installConfig.Config.Azure.Region,
|
||||
},
|
||||
|
@ -597,8 +597,8 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
Count: len(machinesMaster.MachineFiles),
|
||||
},
|
||||
DependsOn: []string{
|
||||
"Microsoft.Compute/images/" + doc.OpenShiftCluster.Properties.ClusterID,
|
||||
"[concat('Microsoft.Network/networkInterfaces/" + doc.OpenShiftCluster.Properties.ClusterID + "-master', copyIndex(), '-nic')]",
|
||||
"Microsoft.Compute/images/" + oc.Properties.ClusterID,
|
||||
"[concat('Microsoft.Network/networkInterfaces/" + oc.Properties.ClusterID + "-master', copyIndex(), '-nic')]",
|
||||
"Microsoft.Network/privateDnsZones/" + installConfig.Config.ObjectMeta.Name + "." + installConfig.Config.BaseDomain + "/virtualNetworkLinks/" + installConfig.Config.ObjectMeta.Name + "-network-link",
|
||||
},
|
||||
},
|
||||
|
@ -606,14 +606,14 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
}
|
||||
|
||||
i.log.Print("deploying resources template")
|
||||
future, err := i.deployments.CreateOrUpdate(ctx, doc.OpenShiftCluster.Properties.ResourceGroup, "azuredeploy", resources.Deployment{
|
||||
future, err := i.deployments.CreateOrUpdate(ctx, oc.Properties.ResourceGroup, "azuredeploy", resources.Deployment{
|
||||
Properties: &resources.DeploymentProperties{
|
||||
Template: t,
|
||||
Parameters: map[string]interface{}{
|
||||
"sas": map[string]interface{}{
|
||||
"value": map[string]interface{}{
|
||||
"signedStart": doc.OpenShiftCluster.Properties.Installation.Now.UTC().Format(time.RFC3339),
|
||||
"signedExpiry": doc.OpenShiftCluster.Properties.Installation.Now.Add(24 * time.Hour).Format(time.RFC3339),
|
||||
"signedStart": oc.Properties.Installation.Now.UTC().Format(time.RFC3339),
|
||||
"signedExpiry": oc.Properties.Installation.Now.Add(24 * time.Hour).Format(time.RFC3339),
|
||||
"signedPermission": "rl",
|
||||
"signedResourceTypes": "o",
|
||||
"signedServices": "b",
|
||||
|
@ -640,7 +640,7 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
RecordSetProperties: &dns.RecordSetProperties{
|
||||
TTL: to.Int64Ptr(300),
|
||||
CnameRecord: &dns.CnameRecord{
|
||||
Cname: to.StringPtr(doc.OpenShiftCluster.Properties.ClusterID + "." + installConfig.Config.Azure.Region + ".cloudapp.azure.com"),
|
||||
Cname: to.StringPtr(oc.Properties.ClusterID + "." + installConfig.Config.Azure.Region + ".cloudapp.azure.com"),
|
||||
},
|
||||
},
|
||||
}, "", "")
|
||||
|
@ -650,7 +650,7 @@ func (i *Installer) installResources(ctx context.Context, doc *api.OpenShiftClus
|
|||
}
|
||||
|
||||
{
|
||||
restConfig, err := restconfig.RestConfig(doc.OpenShiftCluster.Properties.AdminKubeconfig)
|
||||
restConfig, err := restconfig.RestConfig(oc.Properties.AdminKubeconfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -15,8 +15,8 @@ import (
|
|||
"github.com/jim-minter/rp/pkg/util/restconfig"
|
||||
)
|
||||
|
||||
func (i *Installer) removeBootstrap(ctx context.Context, doc *api.OpenShiftClusterDocument) error {
|
||||
g, err := i.getGraph(ctx, doc.OpenShiftCluster)
|
||||
func (i *Installer) removeBootstrap(ctx context.Context, oc *api.OpenShiftCluster) error {
|
||||
g, err := i.getGraph(ctx, oc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func (i *Installer) removeBootstrap(ctx context.Context, doc *api.OpenShiftClust
|
|||
|
||||
{
|
||||
i.log.Print("removing bootstrap vm")
|
||||
future, err := i.virtualmachines.Delete(ctx, doc.OpenShiftCluster.Properties.ResourceGroup, doc.OpenShiftCluster.Properties.ClusterID+"-bootstrap")
|
||||
future, err := i.virtualmachines.Delete(ctx, oc.Properties.ResourceGroup, oc.Properties.ClusterID+"-bootstrap")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ func (i *Installer) removeBootstrap(ctx context.Context, doc *api.OpenShiftClust
|
|||
|
||||
{
|
||||
i.log.Print("removing bootstrap disk")
|
||||
future, err := i.disks.Delete(ctx, doc.OpenShiftCluster.Properties.ResourceGroup, doc.OpenShiftCluster.Properties.ClusterID+"-bootstrap_OSDisk")
|
||||
future, err := i.disks.Delete(ctx, oc.Properties.ResourceGroup, oc.Properties.ClusterID+"-bootstrap_OSDisk")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func (i *Installer) removeBootstrap(ctx context.Context, doc *api.OpenShiftClust
|
|||
|
||||
{
|
||||
i.log.Print("removing bootstrap nic")
|
||||
future, err := i.interfaces.Delete(ctx, doc.OpenShiftCluster.Properties.ResourceGroup, doc.OpenShiftCluster.Properties.ClusterID+"-bootstrap-nic")
|
||||
future, err := i.interfaces.Delete(ctx, oc.Properties.ResourceGroup, oc.Properties.ClusterID+"-bootstrap-nic")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ func (i *Installer) removeBootstrap(ctx context.Context, doc *api.OpenShiftClust
|
|||
|
||||
{
|
||||
i.log.Print("removing bootstrap ip")
|
||||
future, err := i.publicipaddresses.Delete(ctx, doc.OpenShiftCluster.Properties.ResourceGroup, doc.OpenShiftCluster.Properties.ClusterID+"-bootstrap-pip")
|
||||
future, err := i.publicipaddresses.Delete(ctx, oc.Properties.ResourceGroup, oc.Properties.ClusterID+"-bootstrap-pip")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ func (i *Installer) removeBootstrap(ctx context.Context, doc *api.OpenShiftClust
|
|||
}
|
||||
|
||||
{
|
||||
restConfig, err := restconfig.RestConfig(doc.OpenShiftCluster.Properties.AdminKubeconfig)
|
||||
restConfig, err := restconfig.RestConfig(oc.Properties.AdminKubeconfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ func (i *Installer) removeBootstrap(ctx context.Context, doc *api.OpenShiftClust
|
|||
}
|
||||
}
|
||||
|
||||
doc, err = i.db.Patch(doc.OpenShiftCluster.ID, func(doc *api.OpenShiftClusterDocument) error {
|
||||
_, err = i.db.Patch(oc.ID, func(doc *api.OpenShiftClusterDocument) error {
|
||||
doc.OpenShiftCluster.Properties.APIServerURL = "https://api." + doc.OpenShiftCluster.Name + "." + i.domain + ":6443/"
|
||||
doc.OpenShiftCluster.Properties.ConsoleURL = "https://console-openshift-console.apps." + doc.OpenShiftCluster.Name + "." + i.domain + "/"
|
||||
doc.OpenShiftCluster.Properties.KubeadminPassword = kubeadminPassword.Password
|
||||
|
|
|
@ -75,46 +75,46 @@ func NewInstaller(log *logrus.Entry, db database.OpenShiftClusters, domain strin
|
|||
return d
|
||||
}
|
||||
|
||||
func (i *Installer) Install(ctx context.Context, doc *api.OpenShiftClusterDocument, installConfig *installconfig.InstallConfig, platformCreds *installconfig.PlatformCreds) error {
|
||||
func (i *Installer) Install(ctx context.Context, oc *api.OpenShiftCluster, installConfig *installconfig.InstallConfig, platformCreds *installconfig.PlatformCreds) error {
|
||||
for {
|
||||
i.log.Printf("starting phase %s", doc.OpenShiftCluster.Properties.Installation.Phase)
|
||||
switch doc.OpenShiftCluster.Properties.Installation.Phase {
|
||||
i.log.Printf("starting phase %s", oc.Properties.Installation.Phase)
|
||||
switch oc.Properties.Installation.Phase {
|
||||
case api.InstallationPhaseDeployStorage:
|
||||
err := i.installStorage(ctx, doc, installConfig, platformCreds)
|
||||
err := i.installStorage(ctx, oc, installConfig, platformCreds)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
case api.InstallationPhaseDeployResources:
|
||||
err := i.installResources(ctx, doc)
|
||||
err := i.installResources(ctx, oc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
case api.InstallationPhaseRemoveBootstrap:
|
||||
err := i.removeBootstrap(ctx, doc)
|
||||
err := i.removeBootstrap(ctx, oc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = i.db.Patch(doc.OpenShiftCluster.ID, func(doc *api.OpenShiftClusterDocument) error {
|
||||
_, err = i.db.Patch(oc.ID, func(doc *api.OpenShiftClusterDocument) error {
|
||||
doc.OpenShiftCluster.Properties.Installation = nil
|
||||
return nil
|
||||
})
|
||||
return err
|
||||
|
||||
default:
|
||||
return fmt.Errorf("unrecognised phase %s", doc.OpenShiftCluster.Properties.Installation.Phase)
|
||||
return fmt.Errorf("unrecognised phase %s", oc.Properties.Installation.Phase)
|
||||
}
|
||||
|
||||
var err error
|
||||
doc, err = i.db.Patch(doc.OpenShiftCluster.ID, func(doc *api.OpenShiftClusterDocument) error {
|
||||
doc, err := i.db.Patch(oc.ID, func(doc *api.OpenShiftClusterDocument) error {
|
||||
doc.OpenShiftCluster.Properties.Installation.Phase++
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
oc = doc.OpenShiftCluster
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче