azure

package
v0.0.0-...-386b7fa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2019 License: Apache-2.0 Imports: 45 Imported by: 0

README

Cluster Autoscaler on Azure

The cluster autoscaler on Azure scales worker nodes within any specified autoscaling group. It will run as a Kubernetes deployment in your cluster. This README will go over some of the necessary steps required to get the cluster autoscaler up and running.

Kubernetes Version

Kubernetes v1.10.X and Cluster autoscaler v1.2+ are required to run on Azure.

Cluster autoscaler supports four VM types with Azure cloud provider:

  • vmss: For kubernetes cluster running on VMSS instances. Azure cloud provider's vmType parameter must be configured as 'vmss'. It requires Kubernetes with Azure VMSS support (kubernetes#43287).
  • standard: For kubernetes cluster running on VMAS instances. Azure cloud provider's vmType parameter must be configured as 'standard' or left as empty string. It only supports Kubernetes cluster deployed via acs-engine.
  • aks: Managed Container Service(AKS)
  • acs: Container service(ACS)

Only vmss vmType supports scaling to zero nodes.

CA Version

You need to replace a placeholder, '{{ ca_version }}' in manifests with CA Version such as v1.2.2.

Permissions

Get azure credentials by running the following command

# replace <subscription-id> with yours.
az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/<subscription-id>" --output json

Deployment manifests

VMSS deployment

Pre-requirements:

  • Get credentials from above permissions step.
  • Get the scale set name which is used for nodes scaling.
  • Encode each data with base64.

Fill the values of cluster-autoscaler-azure secret in cluster-autoscaler-vmss.yaml, including

  • ClientID: <base64-encoded-client-id>
  • ClientSecret: <base64-encoded-client-secret>
  • ResourceGroup: <base64-encoded-resource-group>
  • SubscriptionID: <base64-encode-subscription-id>
  • TenantID: <base64-encoded-tenant-id>

Note that all data above should be encoded with base64.

And fill the vmss name in container command by --nodes, e.g.

        - --nodes=1:10:vmss1

or multiple vm scale sets:

        - --nodes=1:10:vmss1
        - --nodes=1:10:vmss2

Some aks notes: ResourceGroup will be the rg created by aks (usually MC__) ratehr than the group the aks resource is in. The vm scale set names will be aks---vmss. Where the function that computes that hash is under flux

Then deploy cluster-autoscaler by running

kubectl create -f examples/cluster-autoscaler-vmss.yaml

To run a CA pod in master node - CA deployment should tolerate the master taint and nodeSelector should be used to schedule the pods in master node.

kubectl create -f examples/cluster-autoscaler-vmss-master.yaml

To run a CA pod with Azure managed service identity (MSI), use cluster-autoscaler-vmss-msi.yaml instead:

kubectl create -f examples/cluster-autoscaler-vmss-msi.yaml
Standard deployment

Pre-requirements:

  • Get credentials from above permissions step.
  • Get the initial Azure deployment name from azure portal. If you have multiple deployments (e.g. have run acs-engine scale command), make sure to get the first one.
  • Get a node pool name for nodes scaling from acs-engine deployment manifests
  • Encode each data with base64.

Fill the values of cluster-autoscaler-azure secret in cluster-autoscaler-standard-master.yaml, including

  • ClientID: <base64-encoded-client-id>
  • ClientSecret: <base64-encoded-client-secret>
  • ResourceGroup: <base64-encoded-resource-group>
  • SubscriptionID: <base64-encode-subscription-id>
  • TenantID: <base64-encoded-tenant-id>
  • Deployment: <base64-encoded-azure-initial-deploy-name>

Note that all data above should be encoded with base64.

And fill the node groups in container command by --nodes, e.g.

        - --nodes=1:10:agentpool1

or multiple node groups:

        - --nodes=1:10:agentpool1
        - --nodes=1:10:agentpool2

Create Azure deploy parameters secret cluster-autoscaler-azure-deploy-parameters by running

kubectl -n kube-system create secret generic cluster-autoscaler-azure-deploy-parameters --from-file=deploy-parameters=./_output/<your-output-path>/azuredeploy.parameters.json

Then deploy cluster-autoscaler by running

kubectl create -f cluster-autoscaler-standard-master.yaml

To run a CA pod with Azure managed service identity (MSI), use cluster-autoscaler-standard-msi.yaml instead:

kubectl create -f examples/cluster-autoscaler-standard-msi.yaml

WARNING: Cluster autoscaler depends on user provided deployment parameters to provision new nodes. It should be redeployed with new parameters after upgrading Kubernetes cluster (e.g. upgraded by acs-engine upgrade command), or else new nodes will be provisioned with old version.

ACS deployment

Pre-requirements:

  • Get credentials from above permissions step.

  • Get the cluster name using the following:

    • for ACS: az acs list
    • for AKS: az aks list
  • Get a node pool name by extracting the value of the label agentpool

    kubectl get nodes --show-labels
    
  • Encode each data with base64.

Fill the values of cluster-autoscaler-azure secret in cluster-autoscaler-containerservice, including

  • ClientID: <base64-encoded-client-id>
  • ClientSecret: <base64-encoded-client-secret>
  • ResourceGroup: <base64-encoded-resource-group> (Note: ResourceGroup is case-sensitive)
  • SubscriptionID: <base64-encode-subscription-id>
  • TenantID: <base64-encoded-tenant-id>
  • ClusterName: <base64-encoded-clustername>
  • VMType: <base64-encoded-vmtype>
  • NodeResourceGroup: <base64-encoded-node-resource-group> (only for AKS with VMAS)

Note that all data above should be encoded with base64.

And fill the node groups in container command by --nodes, with the range of nodes (minimum to be set as 3 which is the default cluster size) and node pool name obtained from pre-requirements steps above, e.g.

        - --nodes=3:10:nodepool1

The vmType param determines the kind of service we are interacting with:

# For ACS
$ echo -n ACS | base64
QUNT

# For AKS
$ echo -n AKS | base64
QUtT

The NodeResourceGroup param is only for AKS with VMAS, it should be in format MC_<resource-group>_<cluster-name>_<location>. Note the param is case sensitive and should be encoded with base64.

Then deploy cluster-autoscaler by running

kubectl create -f examples/cluster-autoscaler-containerservice.yaml
AKS deployment

AKS supports two types of nodes: virtual machine scale sets (VMSS) and availability sets (VMAS).

AKS with VMSS

Virtual machine scale sets is only supported from Kubernetes version 1.12.4, you can enable the cluster autoscaler when provisioning the cluster, e.g.

az aks create \
  --resource-group myResourceGroup \
  --name myAKSCluster \
  --kubernetes-version 1.12.4 \
  --node-count 1 \
  --enable-vmss \
  --enable-cluster-autoscaler \
  --min-count 1 \
  --max-count 3

Please take a look at https://docs.microsoft.com/en-us/azure/aks/autoscaler for full documentations.

AKS with VMAS

For virtual machine availability sets, please follow same steps in ACS deployment.

Documentation

Index

Constants

View Source
const (
	// ProviderName is the cloud provider name for Azure
	ProviderName = "azure"

	// GPULabel is the label added to nodes with GPU resource.
	GPULabel = "cloud.google.com/gke-accelerator"
)

Variables

View Source
var InstanceTypes = map[string]*instanceType{}/* 192 elements not displayed */

InstanceTypes is a map of azure resources

Functions

func BuildAzure

BuildAzure builds Azure cloud provider, manager etc.

func BuildAzureCloudProvider

func BuildAzureCloudProvider(azureManager *AzureManager, resourceLimiter *cloudprovider.ResourceLimiter) (cloudprovider.CloudProvider, error)

BuildAzureCloudProvider creates new AzureCloudProvider

func GetVMNameIndex

func GetVMNameIndex(osType compute.OperatingSystemTypes, vmName string) (int, error)

GetVMNameIndex return the index of VM in the node pools.

Types

type AccountsClient

type AccountsClient interface {
	ListKeys(ctx context.Context, resourceGroupName string, accountName string) (result storage.AccountListKeysResult, err error)
}

AccountsClient defines needed functions for azure storage.AccountsClient.

type AccountsClientMock

type AccountsClientMock struct {
	mock.Mock
}

AccountsClientMock mocks for AccountsClient.

func (*AccountsClientMock) ListKeys

func (m *AccountsClientMock) ListKeys(ctx context.Context, resourceGroupName string, accountName string) (result storage.AccountListKeysResult, err error)

ListKeys get a list of keys by accountName.

type AgentPool

type AgentPool struct {
	// contains filtered or unexported fields
}

AgentPool implements NodeGroup interface for agent pools deployed by acs-engine.

func NewAgentPool

func NewAgentPool(spec *dynamic.NodeGroupSpec, az *AzureManager) (*AgentPool, error)

NewAgentPool creates a new AgentPool.

func (*AgentPool) Autoprovisioned

func (as *AgentPool) Autoprovisioned() bool

Autoprovisioned returns true if the node group is autoprovisioned.

func (*AgentPool) Belongs

func (as *AgentPool) Belongs(node *apiv1.Node) (bool, error)

Belongs returns true if the given node belongs to the NodeGroup.

func (*AgentPool) Create

func (as *AgentPool) Create() (cloudprovider.NodeGroup, error)

Create creates the node group on the cloud provider side.

func (*AgentPool) Debug

func (as *AgentPool) Debug() string

Debug returns a debug string for the agent pool.

func (*AgentPool) DecreaseTargetSize

func (as *AgentPool) DecreaseTargetSize(delta int) error

DecreaseTargetSize decreases the target size of the node group. This function doesn't permit to delete any existing node and can be used only to reduce the request for new nodes that have not been yet fulfilled. Delta should be negative. It is assumed that cloud provider will not delete the existing nodes if the size when there is an option to just decrease the target.

func (*AgentPool) Delete

func (as *AgentPool) Delete() error

Delete deletes the node group on the cloud provider side. This will be executed only for autoprovisioned node groups, once their size drops to 0.

func (*AgentPool) DeleteInstances

func (as *AgentPool) DeleteInstances(instances []*azureRef) error

DeleteInstances deletes the given instances. All instances must be controlled by the same ASG.

func (*AgentPool) DeleteNodes

func (as *AgentPool) DeleteNodes(nodes []*apiv1.Node) error

DeleteNodes deletes the nodes from the group.

func (*AgentPool) Exist

func (as *AgentPool) Exist() bool

Exist checks if the node group really exists on the cloud provider side. Allows to tell the theoretical node group from the real one.

func (*AgentPool) GetKey

func (m *AgentPool) GetKey() string

GetKey returns key of the given azure reference.

func (*AgentPool) GetVMIndexes

func (as *AgentPool) GetVMIndexes() ([]int, map[int]string, error)

GetVMIndexes gets indexes of all virtual machines belonging to the agent pool.

func (*AgentPool) GetVirtualMachines

func (as *AgentPool) GetVirtualMachines() (instances []compute.VirtualMachine, err error)

GetVirtualMachines returns list of nodes for the given agent pool.

func (*AgentPool) Id

func (as *AgentPool) Id() string

Id returns AgentPool id.

func (*AgentPool) IncreaseSize

func (as *AgentPool) IncreaseSize(delta int) error

IncreaseSize increases agent pool size

func (*AgentPool) MaxSize

func (as *AgentPool) MaxSize() int

MaxSize returns maximum size of the node group.

func (*AgentPool) MinSize

func (as *AgentPool) MinSize() int

MinSize returns minimum size of the node group.

func (*AgentPool) Nodes

func (as *AgentPool) Nodes() ([]cloudprovider.Instance, error)

Nodes returns a list of all nodes that belong to this node group.

func (*AgentPool) String

func (m *AgentPool) String() string

String is represented by calling GetKey()

func (*AgentPool) TargetSize

func (as *AgentPool) TargetSize() (int, error)

TargetSize returns the current TARGET size of the node group. It is possible that the number is different from the number of nodes registered in Kubernetes.

func (*AgentPool) TemplateNodeInfo

func (as *AgentPool) TemplateNodeInfo() (*schedulernodeinfo.NodeInfo, error)

TemplateNodeInfo returns a node template for this agent pool.

type AzUtil

type AzUtil struct {
	// contains filtered or unexported fields
}

AzUtil consists of utility functions which utilizes clients to different services. Since they span across various clients they cannot be fitted into individual client structs so adding them here.

func (*AzUtil) DeleteBlob

func (util *AzUtil) DeleteBlob(accountName, vhdContainer, vhdBlob string) error

DeleteBlob deletes the blob using the storage client.

func (*AzUtil) DeleteVirtualMachine

func (util *AzUtil) DeleteVirtualMachine(rg string, name string) error

DeleteVirtualMachine deletes a VM and any associated OS disk

type AzureCloudProvider

type AzureCloudProvider struct {
	// contains filtered or unexported fields
}

AzureCloudProvider provides implementation of CloudProvider interface for Azure.

func (*AzureCloudProvider) Cleanup

func (azure *AzureCloudProvider) Cleanup() error

Cleanup stops the go routine that is handling the current view of the ASGs in the form of a cache

func (*AzureCloudProvider) GPULabel

func (azure *AzureCloudProvider) GPULabel() string

GPULabel returns the label added to nodes with GPU resource.

func (*AzureCloudProvider) GetAvailableGPUTypes

func (azure *AzureCloudProvider) GetAvailableGPUTypes() map[string]struct{}

GetAvailableGPUTypes return all available GPU types cloud provider supports

func (*AzureCloudProvider) GetAvailableMachineTypes

func (azure *AzureCloudProvider) GetAvailableMachineTypes() ([]string, error)

GetAvailableMachineTypes get all machine types that can be requested from the cloud provider.

func (*AzureCloudProvider) GetResourceLimiter

func (azure *AzureCloudProvider) GetResourceLimiter() (*cloudprovider.ResourceLimiter, error)

GetResourceLimiter returns struct containing limits (max, min) for resources (cores, memory etc.).

func (*AzureCloudProvider) Name

func (azure *AzureCloudProvider) Name() string

Name returns name of the cloud provider.

func (*AzureCloudProvider) NewNodeGroup

func (azure *AzureCloudProvider) NewNodeGroup(machineType string, labels map[string]string, systemLabels map[string]string,
	taints []apiv1.Taint, extraResources map[string]resource.Quantity) (cloudprovider.NodeGroup, error)

NewNodeGroup builds a theoretical node group based on the node definition provided. The node group is not automatically created on the cloud provider side. The node group is not returned by NodeGroups() until it is created.

func (*AzureCloudProvider) NodeGroupForNode

func (azure *AzureCloudProvider) NodeGroupForNode(node *apiv1.Node) (cloudprovider.NodeGroup, error)

NodeGroupForNode returns the node group for the given node.

func (*AzureCloudProvider) NodeGroups

func (azure *AzureCloudProvider) NodeGroups() []cloudprovider.NodeGroup

NodeGroups returns all node groups configured for this cloud provider.

func (*AzureCloudProvider) Pricing

Pricing returns pricing model for this cloud provider or error if not available.

func (*AzureCloudProvider) Refresh

func (azure *AzureCloudProvider) Refresh() error

Refresh is called before every main loop and can be used to dynamically update cloud provider state. In particular the list of node groups returned by NodeGroups can change as a result of CloudProvider.Refresh().

type AzureManager

type AzureManager struct {
	// contains filtered or unexported fields
}

AzureManager handles Azure communication and data caching.

func CreateAzureManager

func CreateAzureManager(configReader io.Reader, discoveryOpts cloudprovider.NodeGroupDiscoveryOptions) (*AzureManager, error)

CreateAzureManager creates Azure Manager object to work with Azure.

func (*AzureManager) Cleanup

func (m *AzureManager) Cleanup()

Cleanup the ASG cache.

func (*AzureManager) GetAsgForInstance

func (m *AzureManager) GetAsgForInstance(instance *azureRef) (cloudprovider.NodeGroup, error)

GetAsgForInstance returns AsgConfig of the given Instance

func (*AzureManager) Refresh

func (m *AzureManager) Refresh() error

Refresh is called before every main loop and can be used to dynamically update cloud provider state. In particular the list of node groups returned by NodeGroups can change as a result of CloudProvider.Refresh().

func (*AzureManager) RegisterAsg

func (m *AzureManager) RegisterAsg(asg cloudprovider.NodeGroup) bool

RegisterAsg registers an ASG.

func (*AzureManager) UnregisterAsg

func (m *AzureManager) UnregisterAsg(asg cloudprovider.NodeGroup) bool

UnregisterAsg unregisters an ASG.

type Config

type Config struct {
	Cloud          string `json:"cloud" yaml:"cloud"`
	TenantID       string `json:"tenantId" yaml:"tenantId"`
	SubscriptionID string `json:"subscriptionId" yaml:"subscriptionId"`
	ResourceGroup  string `json:"resourceGroup" yaml:"resourceGroup"`
	VMType         string `json:"vmType" yaml:"vmType"`

	AADClientID                 string `json:"aadClientId" yaml:"aadClientId"`
	AADClientSecret             string `json:"aadClientSecret" yaml:"aadClientSecret"`
	AADClientCertPath           string `json:"aadClientCertPath" yaml:"aadClientCertPath"`
	AADClientCertPassword       string `json:"aadClientCertPassword" yaml:"aadClientCertPassword"`
	UseManagedIdentityExtension bool   `json:"useManagedIdentityExtension" yaml:"useManagedIdentityExtension"`

	// Configs only for standard vmType (agent pools).
	Deployment           string                 `json:"deployment" yaml:"deployment"`
	DeploymentParameters map[string]interface{} `json:"deploymentParameters" yaml:"deploymentParameters"`

	//Configs only for ACS/AKS
	ClusterName string `json:"clusterName" yaml:"clusterName"`
	//Config only for AKS
	NodeResourceGroup string `json:"nodeResourceGroup" yaml:"nodeResourceGroup"`
}

Config holds the configuration parsed from the --cloud-config flag

func (*Config) TrimSpace

func (c *Config) TrimSpace()

TrimSpace removes all leading and trailing white spaces.

type ContainerServiceAgentPool

type ContainerServiceAgentPool struct {
	// contains filtered or unexported fields
}

ContainerServiceAgentPool implements NodeGroup interface for agent pool deployed in ACS/AKS

func NewContainerServiceAgentPool

func NewContainerServiceAgentPool(spec *dynamic.NodeGroupSpec, am *AzureManager) (*ContainerServiceAgentPool, error)

NewContainerServiceAgentPool constructs ContainerServiceAgentPool from the --node param and azure manager

func (*ContainerServiceAgentPool) Autoprovisioned

func (agentPool *ContainerServiceAgentPool) Autoprovisioned() bool

Autoprovisioned is set to false to indicate that this code does not create agentPools by itself.

func (*ContainerServiceAgentPool) Create

func (agentPool *ContainerServiceAgentPool) Create() (cloudprovider.NodeGroup, error)

Create is returns already exists since we don't support the agent pool creation.

func (*ContainerServiceAgentPool) Debug

func (agentPool *ContainerServiceAgentPool) Debug() string

Debug returns a string with basic details of the agentPool

func (*ContainerServiceAgentPool) DecreaseTargetSize

func (agentPool *ContainerServiceAgentPool) DecreaseTargetSize(delta int) error

DecreaseTargetSize requests the underlying service to decrease the node count.

func (*ContainerServiceAgentPool) Delete

func (agentPool *ContainerServiceAgentPool) Delete() error

Delete is not implemented since we don't support agent pool deletion.

func (*ContainerServiceAgentPool) DeleteNodes

func (agentPool *ContainerServiceAgentPool) DeleteNodes(nodes []*apiv1.Node) error

DeleteNodes extracts the providerIDs from the node spec and calls into the internal delete method.

func (*ContainerServiceAgentPool) Exist

func (agentPool *ContainerServiceAgentPool) Exist() bool

Exist is always true since we are initialized with an existing agentpool

func (*ContainerServiceAgentPool) GetACSAgentPool

func (agentPool *ContainerServiceAgentPool) GetACSAgentPool(agentProfiles *[]containerservice.AgentPoolProfile) (ret *containerservice.AgentPoolProfile)

GetACSAgentPool is an internal function which figures out AgentPoolProfile from the list based on the pool name provided in the --node parameter passed to the autoscaler main

func (*ContainerServiceAgentPool) GetAKSAgentPool

GetAKSAgentPool is an internal function which figures out ManagedClusterAgentPoolProfile from the list based on the pool name provided in the --node parameter passed to the autoscaler main

func (*ContainerServiceAgentPool) GetKey

func (m *ContainerServiceAgentPool) GetKey() string

GetKey returns key of the given azure reference.

func (*ContainerServiceAgentPool) GetName

func (agentPool *ContainerServiceAgentPool) GetName(providerID string) (string, error)

GetName extracts the name of the node (a format which underlying cloud service understands) from the cloud providerID (format which kubernetes understands)

func (*ContainerServiceAgentPool) GetNodeCount

func (agentPool *ContainerServiceAgentPool) GetNodeCount() (count int, err error)

GetNodeCount returns the count of nodes from the managed agent pool profile

func (*ContainerServiceAgentPool) GetNodes

func (agentPool *ContainerServiceAgentPool) GetNodes() ([]string, error)

GetNodes extracts the node list from the underlying vm service and returns back equivalent providerIDs as list.

func (*ContainerServiceAgentPool) GetProviderID

func (agentPool *ContainerServiceAgentPool) GetProviderID(name string) string

GetProviderID converts the name of a node into the form that kubernetes cloud provider id is presented in.

func (*ContainerServiceAgentPool) Id

func (agentPool *ContainerServiceAgentPool) Id() string

Id returns the name of the agentPool

func (*ContainerServiceAgentPool) IncreaseSize

func (agentPool *ContainerServiceAgentPool) IncreaseSize(delta int) error

IncreaseSize calls in the underlying SetSize to increase the size in response to a scale up. It calculates the expected size based on a delta provided as parameter

func (*ContainerServiceAgentPool) IsContainerServiceNode

func (agentPool *ContainerServiceAgentPool) IsContainerServiceNode(tags map[string]*string) bool

IsContainerServiceNode checks if the tag from the vm matches the agentPool name

func (*ContainerServiceAgentPool) MaxSize

func (agentPool *ContainerServiceAgentPool) MaxSize() int

MaxSize returns the maximum size scale limit provided by --node parameter to the autoscaler main

func (*ContainerServiceAgentPool) MinSize

func (agentPool *ContainerServiceAgentPool) MinSize() int

MinSize returns the minimum size the cluster is allowed to scaled down to as provided by the node spec in --node parameter.

func (*ContainerServiceAgentPool) Nodes

func (agentPool *ContainerServiceAgentPool) Nodes() ([]cloudprovider.Instance, error)

Nodes returns the list of nodes in the agentPool.

func (*ContainerServiceAgentPool) SetNodeCount

func (agentPool *ContainerServiceAgentPool) SetNodeCount(count int) (err error)

SetNodeCount sets the count of nodes in the in memory pool profile

func (*ContainerServiceAgentPool) SetSize

func (agentPool *ContainerServiceAgentPool) SetSize(targetSize int) (err error)

SetSize contacts the underlying service and sets the size of the pool. This will be called when a scale up occurs and will be called just after a delete is performed from a scale down.

func (*ContainerServiceAgentPool) String

func (m *ContainerServiceAgentPool) String() string

String is represented by calling GetKey()

func (*ContainerServiceAgentPool) TargetSize

func (agentPool *ContainerServiceAgentPool) TargetSize() (int, error)

TargetSize gathers the target node count set for the cluster by querying the underlying service.

func (*ContainerServiceAgentPool) TemplateNodeInfo

func (agentPool *ContainerServiceAgentPool) TemplateNodeInfo() (*schedulernodeinfo.NodeInfo, error)

TemplateNodeInfo is not implemented.

type DeploymentsClient

type DeploymentsClient interface {
	Get(ctx context.Context, resourceGroupName string, deploymentName string) (result resources.DeploymentExtended, err error)
	ExportTemplate(ctx context.Context, resourceGroupName string, deploymentName string) (result resources.DeploymentExportResult, err error)
	CreateOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, parameters resources.Deployment) (resp *http.Response, err error)
}

DeploymentsClient defines needed functions for azure network.DeploymentsClient.

type DeploymentsClientMock

type DeploymentsClientMock struct {
	mock.Mock

	FakeStore map[string]resources.DeploymentExtended
	// contains filtered or unexported fields
}

DeploymentsClientMock mocks for DeploymentsClient.

func (*DeploymentsClientMock) CreateOrUpdate

func (m *DeploymentsClientMock) CreateOrUpdate(ctx context.Context, resourceGroupName string, deploymentName string, parameters resources.Deployment) (resp *http.Response, err error)

CreateOrUpdate creates or updates the Deployment.

func (*DeploymentsClientMock) ExportTemplate

func (m *DeploymentsClientMock) ExportTemplate(ctx context.Context, resourceGroupName string, deploymentName string) (result resources.DeploymentExportResult, err error)

ExportTemplate exports the deployment's template.

func (*DeploymentsClientMock) Get

func (m *DeploymentsClientMock) Get(ctx context.Context, resourceGroupName string, deploymentName string) (result resources.DeploymentExtended, err error)

Get gets the DeploymentExtended by deploymentName.

type DisksClient

type DisksClient interface {
	Delete(ctx context.Context, resourceGroupName string, diskName string) (resp *http.Response, err error)
}

DisksClient defines needed functions for azure disk.DisksClient.

type DisksClientMock

type DisksClientMock struct {
	mock.Mock
}

DisksClientMock mocks for DisksClient.

func (*DisksClientMock) Delete

func (m *DisksClientMock) Delete(ctx context.Context, resourceGroupName string, diskName string) (resp *http.Response, err error)

Delete deletes the disk by diskName.

type InterfacesClient

type InterfacesClient interface {
	Delete(ctx context.Context, resourceGroupName string, networkInterfaceName string) (resp *http.Response, err error)
}

InterfacesClient defines needed functions for azure network.InterfacesClient.

type InterfacesClientMock

type InterfacesClientMock struct {
	mock.Mock
}

InterfacesClientMock mocks for InterfacesClient.

func (*InterfacesClientMock) Delete

func (m *InterfacesClientMock) Delete(ctx context.Context, resourceGroupName string, networkInterfaceName string) (resp *http.Response, err error)

Delete deletes the interface by networkInterfaceName.

type ScaleSet

type ScaleSet struct {
	// contains filtered or unexported fields
}

ScaleSet implements NodeGroup interface.

func NewScaleSet

func NewScaleSet(spec *dynamic.NodeGroupSpec, az *AzureManager) (*ScaleSet, error)

NewScaleSet creates a new NewScaleSet.

func (*ScaleSet) Autoprovisioned

func (scaleSet *ScaleSet) Autoprovisioned() bool

Autoprovisioned returns true if the node group is autoprovisioned.

func (*ScaleSet) Belongs

func (scaleSet *ScaleSet) Belongs(node *apiv1.Node) (bool, error)

Belongs returns true if the given node belongs to the NodeGroup.

func (*ScaleSet) Create

func (scaleSet *ScaleSet) Create() (cloudprovider.NodeGroup, error)

Create creates the node group on the cloud provider side.

func (*ScaleSet) Debug

func (scaleSet *ScaleSet) Debug() string

Debug returns a debug string for the Scale Set.

func (*ScaleSet) DecreaseTargetSize

func (scaleSet *ScaleSet) DecreaseTargetSize(delta int) error

DecreaseTargetSize decreases the target size of the node group. This function doesn't permit to delete any existing node and can be used only to reduce the request for new nodes that have not been yet fulfilled. Delta should be negative. It is assumed that cloud provider will not delete the existing nodes if the size when there is an option to just decrease the target.

func (*ScaleSet) Delete

func (scaleSet *ScaleSet) Delete() error

Delete deletes the node group on the cloud provider side. This will be executed only for autoprovisioned node groups, once their size drops to 0.

func (*ScaleSet) DeleteInstances

func (scaleSet *ScaleSet) DeleteInstances(instances []*azureRef) error

DeleteInstances deletes the given instances. All instances must be controlled by the same ASG.

func (*ScaleSet) DeleteNodes

func (scaleSet *ScaleSet) DeleteNodes(nodes []*apiv1.Node) error

DeleteNodes deletes the nodes from the group.

func (*ScaleSet) Exist

func (scaleSet *ScaleSet) Exist() bool

Exist checks if the node group really exists on the cloud provider side. Allows to tell the theoretical node group from the real one.

func (*ScaleSet) GetKey

func (m *ScaleSet) GetKey() string

GetKey returns key of the given azure reference.

func (*ScaleSet) GetScaleSetSize

func (scaleSet *ScaleSet) GetScaleSetSize() (int64, error)

GetScaleSetSize gets Scale Set size.

func (*ScaleSet) GetScaleSetVms

func (scaleSet *ScaleSet) GetScaleSetVms() ([]string, error)

GetScaleSetVms returns list of nodes for the given scale set. Note that the list results is not used directly because their resource ID format is not consistent with Get results.

func (*ScaleSet) Id

func (scaleSet *ScaleSet) Id() string

Id returns ScaleSet id.

func (*ScaleSet) IncreaseSize

func (scaleSet *ScaleSet) IncreaseSize(delta int) error

IncreaseSize increases Scale Set size

func (*ScaleSet) MaxSize

func (scaleSet *ScaleSet) MaxSize() int

MaxSize returns maximum size of the node group.

func (*ScaleSet) MinSize

func (scaleSet *ScaleSet) MinSize() int

MinSize returns minimum size of the node group.

func (*ScaleSet) Nodes

func (scaleSet *ScaleSet) Nodes() ([]cloudprovider.Instance, error)

Nodes returns a list of all nodes that belong to this node group.

func (*ScaleSet) SetScaleSetSize

func (scaleSet *ScaleSet) SetScaleSetSize(size int64) error

SetScaleSetSize sets ScaleSet size.

func (*ScaleSet) String

func (m *ScaleSet) String() string

String is represented by calling GetKey()

func (*ScaleSet) TargetSize

func (scaleSet *ScaleSet) TargetSize() (int, error)

TargetSize returns the current TARGET size of the node group. It is possible that the number is different from the number of nodes registered in Kubernetes.

func (*ScaleSet) TemplateNodeInfo

func (scaleSet *ScaleSet) TemplateNodeInfo() (*schedulernodeinfo.NodeInfo, error)

TemplateNodeInfo returns a node template for this scale set.

type VirtualMachineScaleSetVMsClient

type VirtualMachineScaleSetVMsClient interface {
	Get(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result compute.VirtualMachineScaleSetVM, err error)
	List(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, filter string, selectParameter string, expand string) (result []compute.VirtualMachineScaleSetVM, err error)
}

VirtualMachineScaleSetVMsClient defines needed functions for azure compute.VirtualMachineScaleSetVMsClient.

type VirtualMachineScaleSetVMsClientMock

type VirtualMachineScaleSetVMsClientMock struct {
	mock.Mock
}

VirtualMachineScaleSetVMsClientMock mocks for VirtualMachineScaleSetVMsClient.

func (*VirtualMachineScaleSetVMsClientMock) Get

func (m *VirtualMachineScaleSetVMsClientMock) Get(ctx context.Context, resourceGroupName string, VMScaleSetName string, instanceID string) (result compute.VirtualMachineScaleSetVM, err error)

Get gets a VirtualMachineScaleSetVM by VMScaleSetName and instanceID.

func (*VirtualMachineScaleSetVMsClientMock) List

func (m *VirtualMachineScaleSetVMsClientMock) List(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, filter string, selectParameter string, expand string) (result []compute.VirtualMachineScaleSetVM, err error)

List gets a list of VirtualMachineScaleSetVMs.

type VirtualMachineScaleSetsClient

type VirtualMachineScaleSetsClient interface {
	Get(ctx context.Context, resourceGroupName string, vmScaleSetName string) (result compute.VirtualMachineScaleSet, err error)
	CreateOrUpdate(ctx context.Context, resourceGroupName string, name string, parameters compute.VirtualMachineScaleSet) (resp *http.Response, err error)
	DeleteInstances(ctx context.Context, resourceGroupName string, vmScaleSetName string, vmInstanceIDs compute.VirtualMachineScaleSetVMInstanceRequiredIDs) (resp *http.Response, err error)
	List(ctx context.Context, resourceGroupName string) (result []compute.VirtualMachineScaleSet, err error)
}

VirtualMachineScaleSetsClient defines needed functions for azure compute.VirtualMachineScaleSetsClient.

type VirtualMachineScaleSetsClientMock

type VirtualMachineScaleSetsClientMock struct {
	mock.Mock

	FakeStore map[string]map[string]compute.VirtualMachineScaleSet
	// contains filtered or unexported fields
}

VirtualMachineScaleSetsClientMock mocks for VirtualMachineScaleSetsClient.

func (*VirtualMachineScaleSetsClientMock) CreateOrUpdate

func (client *VirtualMachineScaleSetsClientMock) CreateOrUpdate(ctx context.Context, resourceGroupName string, VMScaleSetName string, parameters compute.VirtualMachineScaleSet) (resp *http.Response, err error)

CreateOrUpdate creates or updates the VirtualMachineScaleSet.

func (*VirtualMachineScaleSetsClientMock) DeleteInstances

func (client *VirtualMachineScaleSetsClientMock) DeleteInstances(ctx context.Context, resourceGroupName string, vmScaleSetName string, vmInstanceIDs compute.VirtualMachineScaleSetVMInstanceRequiredIDs) (resp *http.Response, err error)

DeleteInstances deletes a set of instances for specified VirtualMachineScaleSet.

func (*VirtualMachineScaleSetsClientMock) Get

func (client *VirtualMachineScaleSetsClientMock) Get(ctx context.Context, resourceGroupName string, vmScaleSetName string) (result compute.VirtualMachineScaleSet, err error)

Get gets the VirtualMachineScaleSet by vmScaleSetName.

func (*VirtualMachineScaleSetsClientMock) List

func (client *VirtualMachineScaleSetsClientMock) List(ctx context.Context, resourceGroupName string) (result []compute.VirtualMachineScaleSet, err error)

List gets a list of VirtualMachineScaleSets.

type VirtualMachinesClient

type VirtualMachinesClient interface {
	Get(ctx context.Context, resourceGroupName string, VMName string, expand compute.InstanceViewTypes) (result compute.VirtualMachine, err error)
	Delete(ctx context.Context, resourceGroupName string, VMName string) (resp *http.Response, err error)
	List(ctx context.Context, resourceGroupName string) (result []compute.VirtualMachine, err error)
}

VirtualMachinesClient defines needed functions for azure compute.VirtualMachinesClient.

type VirtualMachinesClientMock

type VirtualMachinesClientMock struct {
	mock.Mock

	FakeStore map[string]map[string]compute.VirtualMachine
	// contains filtered or unexported fields
}

VirtualMachinesClientMock mocks for VirtualMachinesClient.

func (*VirtualMachinesClientMock) Delete

func (m *VirtualMachinesClientMock) Delete(ctx context.Context, resourceGroupName string, VMName string) (resp *http.Response, err error)

Delete deletes the VirtualMachine by VMName.

func (*VirtualMachinesClientMock) Get

func (m *VirtualMachinesClientMock) Get(ctx context.Context, resourceGroupName string, VMName string, expand compute.InstanceViewTypes) (result compute.VirtualMachine, err error)

Get gets the VirtualMachine by VMName.

func (*VirtualMachinesClientMock) List

func (m *VirtualMachinesClientMock) List(ctx context.Context, resourceGroupName string) (result []compute.VirtualMachine, err error)

List gets a lit of VirtualMachine inside the resource group.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL