k8sutils

package
v1.5.6-hotfix.v20230901 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: MIT Imports: 29 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 = 30
	RetryDelay    = 30 * time.Second
)

Variables

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 ExecCmdOnPod

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

func ExportLogsByLabelSelector

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

func GetImageString

func GetImageString(image, version string) 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 Int32ToPtr

func Int32ToPtr(i int32) *int32

func MustCreateDaemonset

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

func MustCreateDeployment

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

func MustCreateNamespace

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

func MustCreateOrUpdatePod

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

func MustDeleteNamespace

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

func MustDeletePod

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

func MustGetClientset

func MustGetClientset() (*kubernetes.Clientset, error)

func MustGetRestConfig

func MustGetRestConfig(t *testing.T) *rest.Config

func MustLabelSwiftNodes

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

func MustParseDaemonSet

func MustParseDaemonSet(path string) (appsv1.DaemonSet, error)

func MustParseDeployment

func MustParseDeployment(path string) (appsv1.Deployment, error)

func MustParsePod

func MustParsePod(path string) (corev1.Pod, error)

ParsePod parses a corev1.Pod from the provided yaml or json file path.

func MustScaleDeployment

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

func MustSetUpClusterRBAC

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

func MustSetUpRBAC

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

func MustSetupConfigMap

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

func MustUpdateReplica

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

func NamespaceExists

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

func ParseImageString

func ParseImageString(s string) (image, version string)

func WaitForPodDeployment

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

func WaitForPodsRunning

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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