Documentation ¶
Index ¶
- Constants
- Variables
- func CreateKubeClientSet() (clientset.Interface, error)
- func CreateLoadBalancerServiceManifest(c clientset.Interface, name string, annotation map[string]string, ...) *v1.Service
- func CreatePod(cs clientset.Interface, ns string, manifest *v1.Pod) error
- func CreateTestResourceGroup(tc *AzureTestClient) (*resources.Group, func(string))
- func CreateTestingNamespace(baseName string, cs clientset.Interface) (*v1.Namespace, error)
- func DeleteNamespace(cs clientset.Interface, namespace string) error
- func DeleteNodes(cs clientset.Interface, names []string) error
- func DeletePIPWithRetry(azureTestClient *AzureTestClient, ipName, rgName string) error
- func DeletePod(cs clientset.Interface, ns string, podName string) error
- func DeletePodsInNamespace(cs clientset.Interface, ns string) error
- func DeleteService(cs clientset.Interface, ns string, serviceName string) error
- func DeleteServiceIfExists(cs clientset.Interface, ns string, serviceName string) error
- func DockerLogin(registryName string) (err error)
- func DockerLogout() (err error)
- func ExtractDNSPrefix() string
- func FindTestVMSS(tc *AzureTestClient, rgName string) (*azcompute.VirtualMachineScaleSet, error)
- func GetAgentNodes(cs clientset.Interface) ([]v1.Node, error)
- func GetAllNodes(cs clientset.Interface) ([]v1.Node, error)
- func GetAvailableNodeCapacity(cs clientset.Interface) (resource.Quantity, error)
- func GetMaster(cs clientset.Interface) (*v1.Node, error)
- func GetNICByID(nicID string, nicList *[]network.Interface) (*network.Interface, error)
- func GetNextSubnetCIDR(vnet aznetwork.VirtualNetwork) (string, error)
- func GetNicIDsFromVM(vm *compute.VirtualMachine) (map[string]interface{}, error)
- func GetNicIDsFromVMSSVM(vm *compute.VirtualMachineScaleSetVM) (map[string]interface{}, error)
- func GetNode(cs clientset.Interface, nodeName string) (*v1.Node, error)
- func GetNodeResourceGroup(node *v1.Node) (string, error)
- func GetNodesInRouteTable(routeTable *aznetwork.RouteTable) (map[string]interface{}, error)
- func GetPodLogs(cs clientset.Interface, ns, podName string, opts *v1.PodLogOptions) ([]byte, error)
- func GetPodOutboundIP(cs clientset.Interface, podTemplate *v1.Pod, nsName string) (string, error)
- func GetServiceDomainName(prefix string) (ret string)
- func GetTargetNICFromList(list *[]network.Interface, targetVMNamePrefix string) (*network.Interface, error)
- func GetVMComputerName(vm *compute.VirtualMachine) (string, error)
- func GetVMSSVMComputerName(vm *azcompute.VirtualMachineScaleSetVM) (string, error)
- func HandleVMNotFoundErr(err error) bool
- func HandleVMSSNotFoundErr(err error) bool
- func IsMasterNode(node *v1.Node) bool
- func IsNodeInVMSS(tc *AzureTestClient, nodeName, vmssName string) (bool, error)
- func IsRetryableAPIError(err error) bool
- func ListNICs(tc *AzureTestClient, rgName string) (*[]network.Interface, error)
- func ListRouteTables(tc *AzureTestClient) (*[]aznetwork.RouteTable, error)
- func ListVMSSNICs(tc *AzureTestClient, vmssName string) (*[]network.Interface, error)
- func ListVMSSVMs(tc *AzureTestClient, vmssName string) (*[]azcompute.VirtualMachineScaleSetVM, error)
- func ListVMSSes(tc *AzureTestClient) (*[]azcompute.VirtualMachineScaleSet, error)
- func ListVMs(tc *AzureTestClient) (*[]compute.VirtualMachine, error)
- func LogPodStatus(cs clientset.Interface, ns string) error
- func Logf(format string, args ...interface{})
- func PushImageToACR(registryName, image string) (tag string, err error)
- func ScaleVMSS(tc *AzureTestClient, vmssName, rgName string, instanceCount int64) (err error)
- func SelectAvailablePrivateIP(tc *AzureTestClient) (string, error)
- func ValidateIPInCIDR(ip, cidr string) (bool, error)
- func ValidateVMSSNodeLabels(tc *AzureTestClient, vmss *azcompute.VirtualMachineScaleSet, key string) error
- func WaitAutoScaleNodes(cs clientset.Interface, targetNodeCount int) error
- func WaitCreateNewPIP(azureTestClient *AzureTestClient, ipName, rgName string, ...) (aznetwork.PublicIPAddress, error)
- func WaitCreatePIP(azureTestClient *AzureTestClient, ipName string, ...) (aznetwork.PublicIPAddress, error)
- func WaitForDeleteResourceGroupCompletion(gc *resources.GroupsClient, future resources.GroupsDeleteFuture, rgName string) error
- func WaitGetPIP(azureTestClient *AzureTestClient, ipName string) (err error)
- func WaitPodTo(phase v1.PodPhase, cs clientset.Interface, podTemplate *v1.Pod, nsName string) (result bool, err error)
- func WaitServiceExposure(cs clientset.Interface, namespace string, name string) (string, error)
- func WaitUpdateServiceExposure(cs clientset.Interface, namespace string, name string, targetIP string, ...) error
- type AzureAuthConfig
- type AzureTestClient
- func (tc *AzureTestClient) AssignRoleToACR(registryName, roleDefinitionID string) (err error)
- func (tc *AzureTestClient) CreateContainerRegistry() (registry acr.Registry, err error)
- func (tc *AzureTestClient) CreateSecurityGroupsClient() *aznetwork.SecurityGroupsClient
- func (azureTestClient *AzureTestClient) CreateSubnet(vnet aznetwork.VirtualNetwork, subnetName *string, prefix *string) error
- func (tc *AzureTestClient) DeleteContainerRegistry(registryName string) (err error)
- func (azureTestClient *AzureTestClient) DeleteSubnet(vnetName string, subnetName string) error
- func (tc *AzureTestClient) GetAuthConfig() AzureAuthConfig
- func (azureTestClient *AzureTestClient) GetClusterSecurityGroup() (ret *aznetwork.SecurityGroup, err error)
- func (azureTestClient *AzureTestClient) GetClusterVirtualNetwork() (virtualNetwork aznetwork.VirtualNetwork, err error)
- func (azureTestClient *AzureTestClient) GetLoadBalancer(resourceGroupName, lbName string) (aznetwork.LoadBalancer, error)
- func (tc *AzureTestClient) GetLocation() string
- func (tc *AzureTestClient) GetResourceGroup() string
- func (azureTestClient *AzureTestClient) ListPublicIPs(resourceGroupName string) ([]aznetwork.PublicIPAddress, error)
Constants ¶
const ( TenantIDEnv = "K8S_AZURE_TENANTID" SubscriptionEnv = "K8S_AZURE_SUBSID" ServicePrincipleIDEnv = "K8S_AZURE_SPID" ServicePrincipleSecretEnv = "K8S_AZURE_SPSEC" ClusterLocationEnv = "K8S_AZURE_LOCATION" ClusterEnvironment = "K8S_AZURE_ENVIRONMENT" LoadBalancerSkuEnv = "K8S_AZURE_LOADBALANCE_SKU" )
Environmental variables for validating Azure resource status.
Variables ¶
var PodIPRE = regexp.MustCompile(`\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}`)
PodIPRE tests if there's a valid IP in a easy way
Functions ¶
func CreateKubeClientSet ¶
CreateKubeClientSet obtains the client set interface from Kubeconfig
func CreateLoadBalancerServiceManifest ¶ added in v0.4.0
func CreateLoadBalancerServiceManifest(c clientset.Interface, name string, annotation map[string]string, labels map[string]string, namespace string, ports []v1.ServicePort) *v1.Service
CreateLoadBalancerServiceManifest return the specific service to be created
func CreateTestResourceGroup ¶ added in v0.4.0
func CreateTestResourceGroup(tc *AzureTestClient) (*resources.Group, func(string))
CreateTestResourceGroup create a test rg
func CreateTestingNamespace ¶
CreateTestingNamespace builds namespace for each test baseName and labels determine name of the space
func DeleteNamespace ¶
DeleteNamespace deletes the provided namespace, waits for it to be completely deleted, and then checks whether there are any pods remaining in a non-terminating state.
func DeleteNodes ¶
DeleteNodes ensures a list of nodes to be deleted
func DeletePIPWithRetry ¶ added in v0.4.0
func DeletePIPWithRetry(azureTestClient *AzureTestClient, ipName, rgName string) error
DeletePIPWithRetry tries to delete a pulic ip resourc
func DeletePodsInNamespace ¶
DeletePodsInNamespace deletes all pods in the namespace
func DeleteService ¶
DeleteService deletes a service
func DeleteServiceIfExists ¶
DeleteServiceIfExists deletes a service if it exists, return nil if not exists
func DockerLogin ¶ added in v0.4.0
DockerLogin execute the `docker login` if docker is available
func DockerLogout ¶ added in v0.4.0
func DockerLogout() (err error)
DockerLogout execute the `docker logout` if docker is available
func ExtractDNSPrefix ¶
func ExtractDNSPrefix() string
ExtractDNSPrefix obtains the cluster DNS prefix
func FindTestVMSS ¶ added in v0.4.0
func FindTestVMSS(tc *AzureTestClient, rgName string) (*azcompute.VirtualMachineScaleSet, error)
FindTestVMSS returns the first VMSS in the resource group, assume the VMSS is in the cluster
func GetAgentNodes ¶
GetAgentNodes obtains the list of agent nodes
func GetAllNodes ¶ added in v0.4.0
GetAllNodes obtains the list of all nodes include master
func GetAvailableNodeCapacity ¶
GetAvailableNodeCapacity will calculate the overall quantity of cpu requested by all running pods in all namespaces
func GetNICByID ¶ added in v0.4.0
GetNICByID returns the network interface with the input ID among the list
func GetNextSubnetCIDR ¶
func GetNextSubnetCIDR(vnet aznetwork.VirtualNetwork) (string, error)
GetNextSubnetCIDR obtains a new ip address which has no overlapping with other subnet
func GetNicIDsFromVM ¶ added in v0.4.0
func GetNicIDsFromVM(vm *compute.VirtualMachine) (map[string]interface{}, error)
GetNicIDsFromVM returns the NIC ID in the VM
func GetNicIDsFromVMSSVM ¶ added in v0.4.0
func GetNicIDsFromVMSSVM(vm *compute.VirtualMachineScaleSetVM) (map[string]interface{}, error)
GetNicIDsFromVMSSVM returns the NIC ID in the VMSS VM
func GetNodeResourceGroup ¶ added in v0.4.0
GetNodeResourceGroup returns the resource group of the given node
func GetNodesInRouteTable ¶ added in v0.4.0
func GetNodesInRouteTable(routeTable *aznetwork.RouteTable) (map[string]interface{}, error)
GetNodesInRouteTable returns all the nodes in the route table
func GetPodLogs ¶ added in v0.4.0
GetPodLogs gets the log of the given pods
func GetPodOutboundIP ¶ added in v0.4.0
GetPodOutboundIP returns the outbound IP of the given pod
func GetServiceDomainName ¶
GetServiceDomainName cat prefix and azure suffix
func GetTargetNICFromList ¶ added in v0.4.0
func GetTargetNICFromList(list *[]network.Interface, targetVMNamePrefix string) (*network.Interface, error)
GetTargetNICFromList pick the target virtual machine's NIC from the given NIC list
func GetVMComputerName ¶ added in v0.4.0
func GetVMComputerName(vm *compute.VirtualMachine) (string, error)
GetVMComputerName returns the corresponding node name of the VM
func GetVMSSVMComputerName ¶ added in v0.4.0
func GetVMSSVMComputerName(vm *azcompute.VirtualMachineScaleSetVM) (string, error)
GetVMSSVMComputerName returns the corresponding node name of the VMSS VM
func HandleVMNotFoundErr ¶ added in v0.4.0
HandleVMNotFoundErr returns true if the input error is errVMNotFound or nil
func HandleVMSSNotFoundErr ¶ added in v0.4.0
HandleVMSSNotFoundErr returns true if the input error is errVMSSNotFound or nil
func IsMasterNode ¶ added in v0.4.0
IsMasterNode returns true if the node has a master role label. The master role is determined by looking for: * a kubernetes.io/role="master" label
func IsNodeInVMSS ¶ added in v0.4.0
func IsNodeInVMSS(tc *AzureTestClient, nodeName, vmssName string) (bool, error)
IsNodeInVMSS defines whether the node is the instance of the VMSS
func IsRetryableAPIError ¶
IsRetryableAPIError will judge whether an error retrable or not
func ListNICs ¶ added in v0.4.0
func ListNICs(tc *AzureTestClient, rgName string) (*[]network.Interface, error)
ListNICs returns the NIC list in the given resource group
func ListRouteTables ¶ added in v0.4.0
func ListRouteTables(tc *AzureTestClient) (*[]aznetwork.RouteTable, error)
ListRouteTables returns the list of all route tables in the resource group
func ListVMSSNICs ¶ added in v0.4.0
func ListVMSSNICs(tc *AzureTestClient, vmssName string) (*[]network.Interface, error)
ListVMSSNICs returns the NIC list in the VMSS
func ListVMSSVMs ¶ added in v0.4.0
func ListVMSSVMs(tc *AzureTestClient, vmssName string) (*[]azcompute.VirtualMachineScaleSetVM, error)
ListVMSSVMs returns the VM list of the given VMSS
func ListVMSSes ¶ added in v0.4.0
func ListVMSSes(tc *AzureTestClient) (*[]azcompute.VirtualMachineScaleSet, error)
ListVMSSes returns the list of scale sets
func ListVMs ¶ added in v0.4.0
func ListVMs(tc *AzureTestClient) (*[]compute.VirtualMachine, error)
ListVMs returns all VMs in the resource group
func LogPodStatus ¶
LogPodStatus logs the rate of pending
func PushImageToACR ¶ added in v0.4.0
PushImageToACR pull an image from Docker Hub and push it to the given azure container registry
func ScaleVMSS ¶ added in v0.4.0
func ScaleVMSS(tc *AzureTestClient, vmssName, rgName string, instanceCount int64) (err error)
ScaleVMSS scales the given VMSS
func SelectAvailablePrivateIP ¶ added in v0.4.0
func SelectAvailablePrivateIP(tc *AzureTestClient) (string, error)
SelectAvailablePrivateIP selects a private IP address in Azure subnet.
func ValidateIPInCIDR ¶
ValidateIPInCIDR validates whether certain ip fits CIDR
func ValidateVMSSNodeLabels ¶ added in v0.4.0
func ValidateVMSSNodeLabels(tc *AzureTestClient, vmss *azcompute.VirtualMachineScaleSet, key string) error
ValidateVMSSNodeLabels gets the label of VMs in VMSS with retry
func WaitAutoScaleNodes ¶
WaitAutoScaleNodes returns nodes count after autoscaling in 30 minutes
func WaitCreateNewPIP ¶ added in v0.4.0
func WaitCreateNewPIP(azureTestClient *AzureTestClient, ipName, rgName string, ipParameter aznetwork.PublicIPAddress) (aznetwork.PublicIPAddress, error)
WaitCreateNewPIP waits to create a public ip resource in a specific resource group
func WaitCreatePIP ¶ added in v0.4.0
func WaitCreatePIP(azureTestClient *AzureTestClient, ipName string, ipParameter aznetwork.PublicIPAddress) (aznetwork.PublicIPAddress, error)
WaitCreatePIP waits to create a public ip resource
func WaitForDeleteResourceGroupCompletion ¶ added in v0.4.0
func WaitForDeleteResourceGroupCompletion(gc *resources.GroupsClient, future resources.GroupsDeleteFuture, rgName string) error
WaitForDeleteResourceGroupCompletion waits for delete group operations to finish
func WaitGetPIP ¶ added in v0.4.0
func WaitGetPIP(azureTestClient *AzureTestClient, ipName string) (err error)
WaitGetPIP waits to get a specific public ip resource
func WaitPodTo ¶ added in v0.4.0
func WaitPodTo(phase v1.PodPhase, cs clientset.Interface, podTemplate *v1.Pod, nsName string) (result bool, err error)
WaitPodTo returns True if pod is in the specific phase during a short period of time
func WaitServiceExposure ¶
WaitServiceExposure returns ip of ingress
Types ¶
type AzureAuthConfig ¶
type AzureAuthConfig struct { // The AAD Tenant ID for the Subscription that the cluster is deployed in TenantID string // The ClientID for an AAD application with RBAC access to talk to Azure RM APIs AADClientID string // The ClientSecret for an AAD application with RBAC access to talk to Azure RM APIs AADClientSecret string // The ID of the Azure Subscription that the cluster is deployed in SubscriptionID string // The Environment represents a set of endpoints for each of Azure's Clouds. Environment azure.Environment }
AzureAuthConfig holds auth related part of cloud config Only consider servicePrinciple now
type AzureTestClient ¶
type AzureTestClient struct {
// contains filtered or unexported fields
}
AzureTestClient configs Azure specific clients
func CreateAzureTestClient ¶
func CreateAzureTestClient() (*AzureTestClient, error)
CreateAzureTestClient makes a new AzureTestClient Only consider PublicCloud Environment
func (*AzureTestClient) AssignRoleToACR ¶ added in v0.4.0
func (tc *AzureTestClient) AssignRoleToACR(registryName, roleDefinitionID string) (err error)
AssignRoleToACR assigns the role to acr by roleDefinitionID
func (*AzureTestClient) CreateContainerRegistry ¶ added in v0.4.0
func (tc *AzureTestClient) CreateContainerRegistry() (registry acr.Registry, err error)
CreateContainerRegistry creates a test acr
func (*AzureTestClient) CreateSecurityGroupsClient ¶
func (tc *AzureTestClient) CreateSecurityGroupsClient() *aznetwork.SecurityGroupsClient
CreateSecurityGroupsClient generates security group client with the same baseclient as azure test client
func (*AzureTestClient) CreateSubnet ¶
func (azureTestClient *AzureTestClient) CreateSubnet(vnet aznetwork.VirtualNetwork, subnetName *string, prefix *string) error
CreateSubnet will create a new subnet in certain virtual network
func (*AzureTestClient) DeleteContainerRegistry ¶ added in v0.4.0
func (tc *AzureTestClient) DeleteContainerRegistry(registryName string) (err error)
DeleteContainerRegistry deletes an existing acr
func (*AzureTestClient) DeleteSubnet ¶
func (azureTestClient *AzureTestClient) DeleteSubnet(vnetName string, subnetName string) error
DeleteSubnet delete a subnet with retry
func (*AzureTestClient) GetAuthConfig ¶ added in v0.4.0
func (tc *AzureTestClient) GetAuthConfig() AzureAuthConfig
GetAuthConfig gets the authorization configuration information
func (*AzureTestClient) GetClusterSecurityGroup ¶
func (azureTestClient *AzureTestClient) GetClusterSecurityGroup() (ret *aznetwork.SecurityGroup, err error)
GetClusterSecurityGroup gets the only vnet of the cluster
func (*AzureTestClient) GetClusterVirtualNetwork ¶
func (azureTestClient *AzureTestClient) GetClusterVirtualNetwork() (virtualNetwork aznetwork.VirtualNetwork, err error)
GetClusterVirtualNetwork gets the only vnet of the cluster
func (*AzureTestClient) GetLoadBalancer ¶ added in v0.4.0
func (azureTestClient *AzureTestClient) GetLoadBalancer(resourceGroupName, lbName string) (aznetwork.LoadBalancer, error)
GetLoadBalancer gets aznetwork.LoadBalancer by loadBalancer name.
func (*AzureTestClient) GetLocation ¶ added in v0.4.0
func (tc *AzureTestClient) GetLocation() string
GetLocation get location which is same of cluster name as definite in k8s-azure
func (*AzureTestClient) GetResourceGroup ¶ added in v0.4.0
func (tc *AzureTestClient) GetResourceGroup() string
GetResourceGroup get RG name which is same of cluster name as definite in k8s-azure
func (*AzureTestClient) ListPublicIPs ¶ added in v0.4.0
func (azureTestClient *AzureTestClient) ListPublicIPs(resourceGroupName string) ([]aznetwork.PublicIPAddress, error)
ListPublicIPs lists all the publicIP addresses active