Skip to content

Commit

Permalink
Wire cluster and machine actuators to use scope clients
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Augustus <saugustus@vmware.com>
  • Loading branch information
justaugustus committed Jan 26, 2019
1 parent 38da184 commit a14f123
Show file tree
Hide file tree
Showing 25 changed files with 1,351 additions and 554 deletions.
8 changes: 3 additions & 5 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ type AzureClusterProviderSpec struct {

ResourceGroup string `json:"resourceGroup"`
Location string `json:"location"`

// CACertificate is a PEM encoded CA Certificate for the control plane nodes.
CACertificate []byte `json:"caCertificate,omitempty"`

// CAPrivateKey is a PEM encoded PKCS1 CA PrivateKey for the control plane nodes.
CAPrivateKey []byte `json:"caKey,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ type AzureClusterProviderStatus struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

/*
Network Network `json:"network,omitempty"`
Bastion Instance `json:"bastion,omitempty"`
*/
Network Network `json:"network,omitempty"`
Bastion Instance `json:"bastion,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand Down
11 changes: 10 additions & 1 deletion pkg/apis/azureprovider/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ type Network struct {
// Subnets includes all the subnets defined inside the Vnet.
Subnets Subnets `json:"subnets,omitempty"`

// APIServerLB is the Kubernetes api server load balancer.
// APIServerLB is the Kubernetes API server load balancer.
APIServerLB LoadBalancer `json:"apiServerLb,omitempty"`

// APIServerIP is the Kubernetes API server public IP address.
APIServerIP PublicIPAddress `json:"apiServerIp,omitempty"`
}

// Vnet defines an Azure Virtual Network.
Expand All @@ -109,6 +112,12 @@ type Subnet struct {
RouteTableID *string `json:"routeTableId"`
}

// PublicIPAddress defines an Azure public IP address.
type PublicIPAddress struct {
ID string `json:"id"`
IPAddress string `json:"ipAddress"`
}

/*
// TODO
// String returns a string representation of the subnet.
Expand Down
29 changes: 29 additions & 0 deletions pkg/apis/azureprovider/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 59 additions & 1 deletion pkg/cloud/azure/actuators/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,18 @@ import (
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-11-01/network"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources"
"github.com/Azure/go-autorest/autorest"
providerv1 "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1alpha1"
clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1"
)

// AzureClients contains all the azure clients used by the scopes.
// AzureClients contains all the Azure clients used by the scopes.
type AzureClients struct {
// TODO: Remove legacy clients once interfaces are reimplemented
Compute AzureComputeClient
Network AzureNetworkClient
Resources AzureResourcesClient

// Compute
VM compute.VirtualMachinesClient
Disks compute.DisksClient
Expand All @@ -40,3 +48,53 @@ type AzureClients struct {
Deployments resources.DeploymentsClient
Tags resources.TagsClient
}

// AzureComputeClient defines the operations that will interact with the Azure Compute API
type AzureComputeClient interface {
// Virtual Machines Operations
RunCommand(resoureGroup string, name string, cmd string) (compute.VirtualMachinesRunCommandFuture, error)
VMIfExists(resourceGroup string, name string) (*compute.VirtualMachine, error)
DeleteVM(resourceGroup string, name string) (compute.VirtualMachinesDeleteFuture, error)
WaitForVMRunCommandFuture(future compute.VirtualMachinesRunCommandFuture) error
WaitForVMDeletionFuture(future compute.VirtualMachinesDeleteFuture) error

// Disk Operations
DeleteManagedDisk(resourceGroup string, name string) (compute.DisksDeleteFuture, error)
WaitForDisksDeleteFuture(future compute.DisksDeleteFuture) error
}

// AzureNetworkClient defines the operations that will interact with the Azure Network API
type AzureNetworkClient interface {
// Network Interfaces Operations
DeleteNetworkInterface(resourceGroupName string, networkInterfaceName string) (network.InterfacesDeleteFuture, error)
WaitForNetworkInterfacesDeleteFuture(future network.InterfacesDeleteFuture) error

// Network Security Groups Operations
CreateOrUpdateNetworkSecurityGroup(resourceGroupName string, networkSecurityGroupName string, location string) (*network.SecurityGroupsCreateOrUpdateFuture, error)
NetworkSGIfExists(resourceGroupName string, networkSecurityGroupName string) (*network.SecurityGroup, error)
WaitForNetworkSGsCreateOrUpdateFuture(future network.SecurityGroupsCreateOrUpdateFuture) error

// Public Ip Address Operations
GetPublicIPAddress(resourceGroupName string, IPName string) (network.PublicIPAddress, error)
DeletePublicIPAddress(resourceGroup string, IPName string) (network.PublicIPAddressesDeleteFuture, error)
WaitForPublicIPAddressDeleteFuture(future network.PublicIPAddressesDeleteFuture) error

// Virtual Networks Operations
CreateOrUpdateVnet(resourceGroupName string, virtualNetworkName string, location string) (*network.VirtualNetworksCreateOrUpdateFuture, error)
WaitForVnetCreateOrUpdateFuture(future network.VirtualNetworksCreateOrUpdateFuture) error
}

// AzureResourcesClient defines the operations that will interact with the Azure Resources API
type AzureResourcesClient interface {
// Resource Groups Operations
CreateOrUpdateGroup(resourceGroupName string, location string) (resources.Group, error)
DeleteGroup(resourceGroupName string) (resources.GroupsDeleteFuture, error)
CheckGroupExistence(rgName string) (autorest.Response, error)
WaitForGroupsDeleteFuture(future resources.GroupsDeleteFuture) error

// Deployment Operations
CreateOrUpdateDeployment(machine *clusterv1.Machine, clusterConfig *providerv1.AzureClusterProviderSpec, machineConfig *providerv1.AzureMachineProviderSpec) (*resources.DeploymentsCreateOrUpdateFuture, error)
GetDeploymentResult(future resources.DeploymentsCreateOrUpdateFuture) (de resources.DeploymentExtended, err error)
ValidateDeployment(machine *clusterv1.Machine, clusterConfig *providerv1.AzureClusterProviderSpec, machineConfig *providerv1.AzureMachineProviderSpec) error
WaitForDeploymentsCreateOrUpdateFuture(future resources.DeploymentsCreateOrUpdateFuture) error
}
Loading

0 comments on commit a14f123

Please sign in to comment.