k8s

package
v1.9.5-rc.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JobSelectorKey = "job"
	// Poll is how often to Poll pods, nodes and claims.
	PollInterval = 2 * time.Second
	PollTimeout  = 15 * time.Minute
)

Variables

This section is empty.

Functions

func AddLabelToPod added in v1.9.0

func AddLabelToPod(ctx context.Context, podName, namespace, label string) error

func AddLabelToPv added in v1.9.0

func AddLabelToPv(ctx context.Context, pv, label string) error

func AddLabelToPvc added in v1.9.0

func AddLabelToPvc(ctx context.Context, pvc, namespace, label string) error

func CleanupClusterRole

func CleanupClusterRole(ctx context.Context, client TestClient, nsBaseName string) error

func CleanupClusterRoleBinding

func CleanupClusterRoleBinding(ctx context.Context, client TestClient, nsBaseName string) error

func CleanupNamespaces

func CleanupNamespaces(ctx context.Context, client TestClient, nsBaseName string) error

func CleanupNamespacesWithPoll

func CleanupNamespacesWithPoll(ctx context.Context, client TestClient, nsBaseName string) error

func CreateConfigMap

func CreateConfigMap(c clientset.Interface, ns, name string, data map[string]string) (*v1.ConfigMap, error)

func CreateDeployment

func CreateDeployment(c clientset.Interface, ns string, deployment *apps.Deployment) (*apps.Deployment, error)

func CreateNamespace

func CreateNamespace(ctx context.Context, client TestClient, namespace string) error

func CreateNamespaceWithAnnotation

func CreateNamespaceWithAnnotation(ctx context.Context, client TestClient, namespace string, annotation map[string]string) error

func CreateNamespaceWithLabel

func CreateNamespaceWithLabel(ctx context.Context, client TestClient, namespace string, label map[string]string) error

func CreateRBACWithBindingSA

func CreateRBACWithBindingSA(ctx context.Context, client TestClient, namespace string, serviceaccount string, clusterrole string, clusterrolebinding string) error

func CreateSecret

func CreateSecret(c clientset.Interface, ns, name string, labels map[string]string) (*v1.Secret, error)

func CreateSecretFromFiles

func CreateSecretFromFiles(ctx context.Context, client TestClient, namespace string, name string, files map[string]string) error

func CreateServiceAccount

func CreateServiceAccount(ctx context.Context, client TestClient, namespace string, serviceaccount string) error

func CreateVCCredentialSecret

func CreateVCCredentialSecret(c clientset.Interface, veleroNamespace string) error

CreateVCCredentialSecret refer to https://github.com/vmware-tanzu/velero-plugin-for-vsphere/blob/v1.3.0/docs/vanilla.md

func DeleteNamespace

func DeleteNamespace(ctx context.Context, client TestClient, namespace string, wait bool) error

func EnsureClusterExists

func EnsureClusterExists(ctx context.Context) error

ensureClusterExists returns whether or not a kubernetes cluster exists for tests to be run on.

func GetClusterRole

func GetClusterRole(ctx context.Context, client TestClient, role string) (*v1.ClusterRole, error)

func GetClusterRoleBinding

func GetClusterRoleBinding(ctx context.Context, client TestClient, rolebinding string) (*v1.ClusterRoleBinding, error)

func GetConfigmap

func GetConfigmap(c clientset.Interface, ns, secretName string) (*v1.ConfigMap, error)

func GetDeployment

func GetDeployment(c clientset.Interface, ns, name string) (*apps.Deployment, error)

func GetNamespace

func GetNamespace(ctx context.Context, client TestClient, namespace string) (*corev1api.Namespace, error)

func GetPersistentVolume added in v1.9.0

func GetPersistentVolume(ctx context.Context, client TestClient, namespace string, persistentVolume string) (*corev1.PersistentVolume, error)

func GetPvByPvc added in v1.9.0

func GetPvByPvc(ctx context.Context, namespace, pvc string) ([]string, error)

func GetPvcByPodName added in v1.9.0

func GetPvcByPodName(ctx context.Context, namespace, podName string) ([]string, error)

func GetSecret

func GetSecret(c clientset.Interface, ns, secretName string) (*v1.Secret, error)

func GetServiceAccount

func GetServiceAccount(ctx context.Context, client TestClient, namespace string, serviceAccount string) (*corev1.ServiceAccount, error)

func KubectlApplyByFile added in v1.9.0

func KubectlApplyByFile(ctx context.Context, file string) error

func NewDeployment

func NewDeployment(name, ns string, replicas int32, labels map[string]string) *apps.Deployment

newDeployment returns a RollingUpdate Deployment with a fake container image

func PatchServiceAccountWithImagePullSecret

func PatchServiceAccountWithImagePullSecret(ctx context.Context, client TestClient, namespace, serviceAccount, dockerCredentialFile string) error

func WaitAllSelectedNSDeleted

func WaitAllSelectedNSDeleted(ctx context.Context, client TestClient, label string) error

func WaitForConfigMapComplete

func WaitForConfigMapComplete(c clientset.Interface, ns, configmapName string) error

WaitForConfigMapComplete uses c to wait for completions to complete for the Job jobName in namespace ns.

func WaitForConfigmapDelete

func WaitForConfigmapDelete(c clientset.Interface, ns, name string) error

func WaitForPods

func WaitForPods(ctx context.Context, client TestClient, namespace string, pods []string) error

WaitForPods waits until all of the pods have gone to PodRunning state

func WaitForReadyDeployment

func WaitForReadyDeployment(c clientset.Interface, ns, name string) error

WaitForReadyDeployment waits for number of ready replicas to equal number of replicas.

func WaitForSecretDelete

func WaitForSecretDelete(c clientset.Interface, ns, name string) error

func WaitForSecretsComplete

func WaitForSecretsComplete(c clientset.Interface, ns, secretName string) error

WaitForSecretsComplete uses c to wait for completions to complete for the Job jobName in namespace ns.

func WaitUntilServiceAccountCreated

func WaitUntilServiceAccountCreated(ctx context.Context, client TestClient, namespace, serviceAccount string, timeout time.Duration) error

Types

type TestClient

type TestClient struct {
	Kubebuilder kbclient.Client

	// clientGo returns a client-go API client.
	//
	// Deprecated, TODO(2.0): presuming all controllers and resources are converted to the
	// controller runtime framework by v2.0, it is the intent to remove all
	// client-go API clients. Please use the controller runtime to make API calls for tests.
	ClientGo kubernetes.Interface
	// contains filtered or unexported fields
}

func InitTestClient

func InitTestClient() (TestClient, error)

NewTestClient returns a set of ready-to-use API clients.

func NewTestClient

func NewTestClient() (TestClient, error)

Jump to

Keyboard shortcuts

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