Skip to content

Commit

Permalink
Update configurations and package logic to enable builds from master (#…
Browse files Browse the repository at this point in the history
…99)

* Disable cloud provider config

Signed-off-by: Stephen Augustus <saugustus@vmware.com>

* Update deployment template (API versions + PIP parameters)

Signed-off-by: Stephen Augustus <saugustus@vmware.com>

* apis: Update PublicIP type (add DNSName) and regenerate CRDs

Signed-off-by: Stephen Augustus <saugustus@vmware.com>

* Wire APIServerIP.DNSName

Signed-off-by: Stephen Augustus <saugustus@vmware.com>

* Update machine naming and existence logic

Signed-off-by: Stephen Augustus <saugustus@vmware.com>

* lb: Update LB types, add backend pool logic

Signed-off-by: Stephen Augustus <saugustus@vmware.com>

* resources: Dedupe cluster name in GetVMName

Signed-off-by: Stephen Augustus <saugustus@vmware.com>

* network: Add/update NIC methods

Signed-off-by: Stephen Augustus <saugustus@vmware.com>

* actuators: Update machine actuator requeues

Signed-off-by: Stephen Augustus <saugustus@vmware.com>

* services: Update Azure client calls

Signed-off-by: Stephen Augustus <saugustus@vmware.com>

* network: Add NSG attach logic to subnet create/update

Signed-off-by: Stephen Augustus <saugustus@vmware.com>

* network: Move VM public IP creation to network package

Signed-off-by: Stephen Augustus <saugustus@vmware.com>

* vm: Update scripts to set k8s version and return successfully

Signed-off-by: Stephen Augustus <saugustus@vmware.com>

* cluster/examples: Add Weave CNI to addons.yaml.template

Signed-off-by: Stephen Augustus <saugustus@vmware.com>

* config: Update RBAC

Signed-off-by: Stephen Augustus <saugustus@vmware.com>

* network/interfaces: Improve NIC attach logic

Signed-off-by: Stephen Augustus <saugustus@vmware.com>

* tokens: Update copyright date

Signed-off-by: Stephen Augustus <saugustus@vmware.com>
  • Loading branch information
justaugustus authored and k8s-ci-robot committed Mar 5, 2019
1 parent 9e84860 commit a6c7122
Show file tree
Hide file tree
Showing 27 changed files with 754 additions and 1,075 deletions.
574 changes: 0 additions & 574 deletions cmd/clusterctl/examples/azure/addons.yaml

This file was deleted.

439 changes: 241 additions & 198 deletions cmd/clusterctl/examples/azure/addons.yaml.template

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cmd/clusterctl/examples/azure/machines.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ items:
- apiVersion: "cluster.k8s.io/v1alpha1"
kind: Machine
metadata:
name: controlplane-0
name: ${CLUSTER_NAME}-controlplane-0
labels:
cluster.k8s.io/cluster-name: ${CLUSTER_NAME}
set: controlplane
Expand Down Expand Up @@ -35,7 +35,7 @@ items:
- apiVersion: "cluster.k8s.io/v1alpha1"
kind: Machine
metadata:
generateName: node-
generateName: ${CLUSTER_NAME}-node-
labels:
cluster.k8s.io/cluster-name: ${CLUSTER_NAME}
set: node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ items:
- apiVersion: "cluster.k8s.io/v1alpha1"
kind: Machine
metadata:
name: controlplane-0
name: ${CLUSTER_NAME}-controlplane-0
labels:
cluster.k8s.io/cluster-name: ${CLUSTER_NAME}
set: controlplane
Expand Down
16 changes: 10 additions & 6 deletions config/crds/azureprovider_v1alpha1_azureclusterproviderstatus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,27 @@ spec:
network:
properties:
apiServerIp:
description: 'APIServerIP is the Kubernetes API server public IP address.
TODO: Remove once load balancer is implemented.'
description: APIServerIP is the Kubernetes API server public IP address.
properties:
dnsName:
type: string
id:
type: string
ipAddress:
type: string
name:
type: string
required:
- id
- name
- ipAddress
type: object
apiServerLb:
description: APIServerLB is the Kubernetes API server load balancer.
properties:
backendPool:
properties:
id:
type: string
name:
type: string
type: object
frontendIpConfig:
type: object
id:
Expand Down
28 changes: 21 additions & 7 deletions config/rbac/rbac_role.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: manager-role
rules:
- apiGroups:
Expand All @@ -17,10 +18,10 @@ rules:
- patch
- delete
- apiGroups:
- azureprovider.k8s.io
- cluster.k8s.io
resources:
- azuremachineproviderconfigs
- azuremachineproviderstatuses
- clusters
- clusters/status
verbs:
- get
- list
Expand All @@ -30,15 +31,19 @@ rules:
- patch
- delete
- apiGroups:
- cluster.k8s.io
- azureprovider.k8s.io
resources:
- clusters
- clusters/status
- azuremachineproviderconfigs
- azuremachineproviderstatuses
verbs:
- get
- list
- watch
- apigroups:
- create
- update
- patch
- delete
- apiGroups:
- cluster.k8s.io
resources:
- machines
Expand All @@ -56,6 +61,15 @@ rules:
- update
- patch
- delete
- apiGroups:
- cluster.k8s.io
resources:
- clusters
- clusters/status
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
Expand Down
14 changes: 10 additions & 4 deletions pkg/apis/azureprovider/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ type Network struct {
APIServerLB LoadBalancer `json:"apiServerLb,omitempty"`

// APIServerIP is the Kubernetes API server public IP address.
// TODO: Remove once load balancer is implemented.
APIServerIP PublicIP `json:"apiServerIp,omitempty"`
}

Expand Down Expand Up @@ -227,9 +226,10 @@ func (i IngressRules) Difference(o IngressRules) (out IngressRules) {
// PublicIP defines an Azure public IP address.
// TODO: Remove once load balancer is implemented.
type PublicIP struct {
ID string `json:"id"`
Name string `json:"name"`
IPAddress string `json:"ipAddress"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
IPAddress string `json:"ipAddress,omitempty"`
DNSName string `json:"dnsName,omitempty"`
}

// TODO
Expand All @@ -239,6 +239,7 @@ type LoadBalancer struct {
Name string `json:"name,omitempty"`
SKU SKU `json:"sku,omitempty"`
FrontendIPConfig FrontendIPConfig `json:"frontendIpConfig,omitempty"`
BackendPool BackendPool `json:"backendPool,omitempty"`
Tags Tags `json:"tags,omitempty"`
/*
// FrontendIPConfigurations - Object representing the frontend IPs to be used for the load balancer
Expand Down Expand Up @@ -285,6 +286,11 @@ type FrontendIPConfig struct {
*/
}

type BackendPool struct {
Name string `json:"name,omitempty"`
ID string `json:"id,omitempty"`
}

// TODO
// LoadBalancerProtocol defines listener protocols for a load balancer.
type LoadBalancerProtocol string
Expand Down
17 changes: 17 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.

65 changes: 50 additions & 15 deletions pkg/cloud/azure/actuators/machine/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (a *Actuator) isNodeJoin(controlPlaneMachines []*clusterv1.Machine, newMach
case "node":
return true, nil
case "controlplane":
contolPlaneExists := false
controlPlaneExists := false
for _, cm := range controlPlaneMachines {
m, err := actuators.NewMachineScope(actuators.MachineScopeParams{
Machine: cm,
Expand All @@ -107,17 +107,17 @@ func (a *Actuator) isNodeJoin(controlPlaneMachines []*clusterv1.Machine, newMach
}

computeSvc := compute.NewService(m.Scope)
contolPlaneExists, err = computeSvc.MachineExists(m)
controlPlaneExists, err = computeSvc.MachineExists(m)
if err != nil {
return false, errors.Wrapf(err, "failed to verify existence of machine %q", m.Name())
}
if contolPlaneExists {
if controlPlaneExists {
break
}
}

klog.V(2).Infof("Machine %q should join the controlplane: %t", newMachine.Name, contolPlaneExists)
return contolPlaneExists, nil
klog.V(2).Infof("Machine %q should join the controlplane: %t", newMachine.Name, controlPlaneExists)
return controlPlaneExists, nil
default:
errMsg := fmt.Sprintf("Unknown value %q for label \"set\" on machine %q, skipping machine creation", newMachine.ObjectMeta.Labels["set"], newMachine.Name)
klog.Errorf(errMsg)
Expand All @@ -138,6 +138,7 @@ func (a *Actuator) Create(ctx context.Context, cluster *clusterv1.Cluster, machi
defer scope.Close()

computeSvc := compute.NewService(scope.Scope)
networkSvc := network.NewService(scope.Scope)

clusterMachines, err := scope.MachineClient.List(v1.ListOptions{})
if err != nil {
Expand Down Expand Up @@ -166,14 +167,51 @@ func (a *Actuator) Create(ctx context.Context, cluster *clusterv1.Cluster, machi
}
}

nic, err := networkSvc.CreateDefaultVMNetworkInterface(scope.ClusterConfig.ResourceGroup, scope.Machine)
if err != nil {
klog.Errorf("Unable to create VM network interface: %+v", err)
return &controllerError.RequeueAfterError{
RequeueAfter: time.Second * 30,
}
}

if scope.Network().APIServerLB.BackendPool.ID == "" {
klog.Errorf("Unable to find backend pool ID. Retrying...")
return &controllerError.RequeueAfterError{
RequeueAfter: time.Second * 15,
}
}

err = networkSvc.ReconcileNICBackendPool(*nic.Name, scope.Network().APIServerLB.BackendPool.ID)
if err != nil {
klog.Errorf("Unable to reconcile backend pool attachment: %+v", err)
return &controllerError.RequeueAfterError{
RequeueAfter: time.Second * 30,
}
}

pip, err := networkSvc.CreateOrUpdatePublicIPAddress(scope.ClusterConfig.ResourceGroup, scope.Machine.Name, networkSvc.GetDefaultPublicIPZone())
if err != nil {
klog.Errorf("Unable to create public IP: %+v", err)
return &controllerError.RequeueAfterError{
RequeueAfter: time.Second * 30,
}
}

err = networkSvc.ReconcileNICPublicIP(*nic.Name, pip)
if err != nil {
klog.Errorf("Unable to reconcile public IP attachment: %+v", err)
return &controllerError.RequeueAfterError{
RequeueAfter: time.Second * 30,
}
}

i, err := computeSvc.CreateOrGetMachine(scope, bootstrapToken, kubeConfig)
if err != nil {
klog.Errorf("network not ready to launch instances yet: %+v", err)
return &controllerError.RequeueAfterError{
RequeueAfter: time.Minute,
}

//return errors.Errorf("failed to create or get machine: %+v", err)
}

scope.MachineStatus.VMID = &i.ID
Expand All @@ -184,11 +222,11 @@ func (a *Actuator) Create(ctx context.Context, cluster *clusterv1.Cluster, machi
// TODO: update once machine controllers have a way to indicate a machine has been provisoned. https://github.com/kubernetes-sigs/cluster-api/issues/253
// Seeing a node cannot be purely relied upon because the provisioned control plane will not be registering with
// the stack that provisions it.
if scope.MachineStatus.Annotations == nil {
scope.MachineStatus.Annotations = map[string]string{}
if machine.Annotations == nil {
machine.Annotations = map[string]string{}
}

scope.MachineStatus.Annotations["cluster-api-provider-azure"] = "true"
machine.Annotations["cluster-api-provider-azure"] = "true"

return nil
}
Expand Down Expand Up @@ -295,14 +333,11 @@ func (a *Actuator) Delete(ctx context.Context, cluster *clusterv1.Cluster, machi
}

// delete public ip address associated with the VM
publicIPAddressDeleteFuture, err := networkSvc.DeletePublicIPAddress(scope.ClusterConfig.ResourceGroup, resourcesSvc.GetPublicIPName(machine))
err = networkSvc.DeletePublicIPAddress(scope.ClusterConfig.ResourceGroup, networkSvc.GetPublicIPName(machine))
if err != nil {
return fmt.Errorf("error deleting public IP address: %v", err)
}
err = networkSvc.WaitForPublicIPAddressDeleteFuture(publicIPAddressDeleteFuture)
if err != nil {
return fmt.Errorf("error waiting for public ip address deletion: %v", err)
}

return nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cloud/azure/services/compute/disks.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (

// DeleteManagedDisk deletes a managed disk resource.
func (s *Service) DeleteManagedDisk(resourceGroup string, name string) (compute.DisksDeleteFuture, error) {
return s.scope.AzureClients.Disks.Delete(s.scope.Context, resourceGroup, name)
return s.scope.Disks.Delete(s.scope.Context, resourceGroup, name)
}

// WaitForDisksDeleteFuture returns when the DeleteManagedDisk operation completes.
func (s *Service) WaitForDisksDeleteFuture(future compute.DisksDeleteFuture) error {
return future.Future.WaitForCompletionRef(s.scope.Context, s.scope.AzureClients.Disks.Client)
return future.Future.WaitForCompletionRef(s.scope.Context, s.scope.Disks.Client)
}
Loading

0 comments on commit a6c7122

Please sign in to comment.