kubernetes

package
v1.6.25 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DelegatedSubnetIDLabel = "kubernetes.azure.com/podnetwork-delegationguid"
	SubnetNameLabel        = "kubernetes.azure.com/podnetwork-subnet"

	// RetryAttempts is the number of times to retry a test.
	RetryAttempts           = 90
	RetryDelay              = 10 * time.Second
	DeleteRetryAttempts     = 12
	DeleteRetryDelay        = 5 * time.Second
	ShortRetryAttempts      = 8
	ShortRetryDelay         = 250 * time.Millisecond
	PrivilegedDaemonSetPath = "../manifests/load/privileged-daemonset-windows.yaml"
	PrivilegedLabelSelector = "app=privileged-daemonset"
	PrivilegedNamespace     = "kube-system"
)
View Source
const (
	EnvInstallCNS = "INSTALL_CNS"
)

Variables

View Source
var (
	ErrUnsupportedCNSScenario = errors.New("unsupported CNS scenario")
	ErrPathNotFound           = errors.New("failed to get the absolute path to directory")
	ErrNoCNSScenarioDefined   = errors.New("no CNSScenario set to true as env var")
)
View Source
var Kubeconfig = flag.String("test-kubeconfig", filepath.Join(homedir.HomeDir(), ".kube", "config"), "(optional) absolute path to the kubeconfig file")

Functions

func AddNodeLabels

func AddNodeLabels(ctx context.Context, nodes corev1.NodeInterface, nodeName string, labels map[string]string) (*apiv1.Node, error)

AddNodeLabels adds or replaces labels on a node.

func CreateLabelSelector

func CreateLabelSelector(key string, selector *string) string

return a label selector

func DeploymentExists added in v1.5.18

func DeploymentExists(ctx context.Context, deploymentsClient typedappsv1.DeploymentInterface, deploymentName string) (bool, error)

func ExecCmdOnPod

func ExecCmdOnPod(ctx context.Context, clientset *kubernetes.Clientset, namespace, podName, containerName string, cmd []string, config *rest.Config, doRetry bool) ([]byte, []byte, error)

ExecCmdOnPod runs the specified command on a particular pod and retries the command on failure if doRetry is set to true The function returns the standard output, standard error, and error (if any) in that order

func ExportLogsByLabelSelector

func ExportLogsByLabelSelector(ctx context.Context, clientset *kubernetes.Clientset, namespace, labelselector, logDir string) error

func GetConfigmap added in v1.6.23

func GetConfigmap(ctx context.Context, clientset *kubernetes.Clientset, namespace, name string) (*corev1.ConfigMap, error)

func GetDeploymentAvailableReplicas added in v1.5.18

func GetDeploymentAvailableReplicas(ctx context.Context, deploymentsClient typedappsv1.DeploymentInterface, deploymentName string) (int32, error)

func GetKubeconfig added in v1.5.29

func GetKubeconfig() *string

func GetNodeList

func GetNodeList(ctx context.Context, clientset *kubernetes.Clientset) (*corev1.NodeList, error)

func GetNodeListByLabelSelector

func GetNodeListByLabelSelector(ctx context.Context, clientset *kubernetes.Clientset, labelSelector string) (*corev1.NodeList, error)

func GetPodsByNode

func GetPodsByNode(ctx context.Context, clientset *kubernetes.Clientset, namespace, labelselector, nodeName string) (*corev1.PodList, error)

func GetPodsIpsByNode

func GetPodsIpsByNode(ctx context.Context, clientset *kubernetes.Clientset, namespace, labelselector, nodeName string) ([]string, error)

func GetRESTClientForMultitenantCRD added in v1.5.29

func GetRESTClientForMultitenantCRD(kubeconfig string) (*rest.RESTClient, error)

func GetRESTClientForMultitenantCRDFromConfig added in v1.5.29

func GetRESTClientForMultitenantCRDFromConfig(config *rest.Config) (*rest.RESTClient, error)

func GetService added in v1.6.23

func GetService(ctx context.Context, clientset *kubernetes.Clientset, namespace, name string) (*corev1.Service, error)

func HasWindowsNodes

func HasWindowsNodes(ctx context.Context, clientset *kubernetes.Clientset) (bool, error)

func InstallCNSDaemonset

func InstallCNSDaemonset(ctx context.Context, clientset *kubernetes.Clientset, logDir string) (func() error, error)

func InstallIPMasqAgent

func InstallIPMasqAgent(ctx context.Context, clientset *kubernetes.Clientset) error

func Int32ToPtr

func Int32ToPtr(i int32) *int32

func MustCreateDaemonset

func MustCreateDaemonset(ctx context.Context, daemonsets typedappsv1.DaemonSetInterface, ds appsv1.DaemonSet)

func MustCreateDeployment

func MustCreateDeployment(ctx context.Context, deployments typedappsv1.DeploymentInterface, d appsv1.Deployment)

func MustCreateNamespace

func MustCreateNamespace(ctx context.Context, clienset *kubernetes.Clientset, namespace string)

func MustDeleteCiliumLocalRedirectPolicy added in v1.6.23

func MustDeleteCiliumLocalRedirectPolicy(ctx context.Context, lrpClient typedciliumv2.CiliumLocalRedirectPolicyInterface, clrp ciliumv2.CiliumLocalRedirectPolicy)

func MustDeleteCiliumNetworkPolicy added in v1.6.24

func MustDeleteCiliumNetworkPolicy(ctx context.Context, cnpClient typedciliumv2.CiliumNetworkPolicyInterface, cnp ciliumv2.CiliumNetworkPolicy)

func MustDeleteConfigMap added in v1.6.23

func MustDeleteConfigMap(ctx context.Context, configMaps typedcorev1.ConfigMapInterface, cm corev1.ConfigMap)

func MustDeleteDaemonset

func MustDeleteDaemonset(ctx context.Context, daemonsets typedappsv1.DaemonSetInterface, ds appsv1.DaemonSet)

func MustDeleteDeployment

func MustDeleteDeployment(ctx context.Context, deployments typedappsv1.DeploymentInterface, d appsv1.Deployment)

func MustDeleteNamespace

func MustDeleteNamespace(ctx context.Context, clienset *kubernetes.Clientset, namespace string)

func MustDeletePod

func MustDeletePod(ctx context.Context, podI typedcorev1.PodInterface, pod corev1.Pod)

func MustDeleteService added in v1.6.23

func MustDeleteService(ctx context.Context, services typedcorev1.ServiceInterface, svc corev1.Service)

func MustDeleteServiceAccount added in v1.6.23

func MustDeleteServiceAccount(ctx context.Context, serviceAccounts typedcorev1.ServiceAccountInterface, svcAcct corev1.ServiceAccount)

func MustGetClientset

func MustGetClientset() *kubernetes.Clientset

func MustGetRestConfig

func MustGetRestConfig() *rest.Config

func MustLabelSwiftNodes

func MustLabelSwiftNodes(ctx context.Context, clientset *kubernetes.Clientset, delegatedSubnetID, delegatedSubnetName string)

func MustParseDaemonSet

func MustParseDaemonSet(path string) appsv1.DaemonSet

func MustParseDeployment

func MustParseDeployment(path string) appsv1.Deployment

func MustRestartDaemonset

func MustRestartDaemonset(ctx context.Context, clientset *kubernetes.Clientset, namespace, daemonsetName string) error

func MustScaleDeployment

func MustScaleDeployment(ctx context.Context,
	deploymentsClient typedappsv1.DeploymentInterface,
	deployment appsv1.Deployment,
	clientset *kubernetes.Clientset,
	namespace,
	podLabelSelector string,
	replicas int,
	skipWait bool,
)

func MustSetUpClusterRBAC

func MustSetUpClusterRBAC(ctx context.Context, clientset *kubernetes.Clientset, clusterRolePath, clusterRoleBindingPath, serviceAccountPath string) func()

func MustSetUpRBAC

func MustSetUpRBAC(ctx context.Context, clientset *kubernetes.Clientset, rolePath, roleBindingPath string)

func MustSetupCNP added in v1.6.24

func MustSetupCNP(ctx context.Context, clientset *cilium.Clientset, cnpPath string) (ciliumv2.CiliumNetworkPolicy, func())

func MustSetupConfigMap

func MustSetupConfigMap(ctx context.Context, clientset *kubernetes.Clientset, configMapPath string) (corev1.ConfigMap, func())

func MustSetupDaemonset added in v1.6.23

func MustSetupDaemonset(ctx context.Context, clientset *kubernetes.Clientset, dsPath string) (appsv1.DaemonSet, func())

MustSetupDaemonset is a convenience function to directly apply the daemonset at dsPath to the cluster, returning the parsed daemonset struct and a cleanup function in the process

func MustSetupDeployment added in v1.6.23

func MustSetupDeployment(ctx context.Context, clientset *kubernetes.Clientset, depPath string) (appsv1.Deployment, func())

func MustSetupLRP added in v1.6.23

func MustSetupLRP(ctx context.Context, clientset *cilium.Clientset, lrpPath string) (ciliumv2.CiliumLocalRedirectPolicy, func())

func MustSetupService added in v1.6.23

func MustSetupService(ctx context.Context, clientset *kubernetes.Clientset, servicePath string) (corev1.Service, func())

func MustSetupServiceAccount added in v1.6.23

func MustSetupServiceAccount(ctx context.Context, clientset *kubernetes.Clientset, serviceAccountPath string) (corev1.ServiceAccount, func())

func MustUpdateReplica

func MustUpdateReplica(ctx context.Context, deploymentsClient typedappsv1.DeploymentInterface, deploymentName string, replicas int32)

func NamespaceExists

func NamespaceExists(ctx context.Context, clientset *kubernetes.Clientset, namespace string) (bool, error)

func RestartCNSDaemonset

func RestartCNSDaemonset(ctx context.Context, clientset *kubernetes.Clientset, waitForReady bool) error

func RestartKubeProxyService added in v1.5.20

func RestartKubeProxyService(ctx context.Context, clientset *kubernetes.Clientset, privilegedNamespace, privilegedLabelSelector string, config *rest.Config) error

Restarts kubeproxy on windows nodes from an existing privileged daemonset

func WaitForDeploymentToDelete

func WaitForDeploymentToDelete(ctx context.Context, deploymentsClient typedappsv1.DeploymentInterface, d appsv1.Deployment) error

func WaitForPodDaemonset

func WaitForPodDaemonset(ctx context.Context, clientset *kubernetes.Clientset, namespace, daemonsetName, podLabelSelector string) error

func WaitForPodDeployment

func WaitForPodDeployment(ctx context.Context, clientset *kubernetes.Clientset, namespace, deploymentName, podLabelSelector string, replicas int) error

func WaitForPodsDelete

func WaitForPodsDelete(ctx context.Context, clientset *kubernetes.Clientset, namespace, labelselector string) error

func WaitForPodsRunning

func WaitForPodsRunning(ctx context.Context, clientset *kubernetes.Clientset, namespace, labelselector string) error

Types

type CNSScenario

type CNSScenario string
const (
	EnvInstallAzilium            CNSScenario = "INSTALL_AZILIUM"
	EnvInstallAzureVnet          CNSScenario = "INSTALL_AZURE_VNET"
	EnvInstallAzureVnetStateless CNSScenario = "INSTALL_AZURE_VNET_STATELESS"
	EnvInstallOverlay            CNSScenario = "INSTALL_OVERLAY"
	EnvInstallAzureCNIOverlay    CNSScenario = "INSTALL_AZURE_CNI_OVERLAY"
	EnvInstallDualStackOverlay   CNSScenario = "INSTALL_DUALSTACK_OVERLAY"
	EnvInstallCNSNodeSubnet      CNSScenario = "INSTALL_CNS_NODESUBNET"
)

Jump to

Keyboard shortcuts

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