k8s

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TaskGroupName          = "yunikorn.apache.org/task-group-name"
	TaskGroups             = "yunikorn.apache.org/task-groups"
	PlaceHolder            = "yunikorn.apache.org/placeholder"
	SchedulingPolicyParams = "yunikorn.apache.org/schedulingPolicyParameters"

	MaxCPU = "yunikorn.apache.org/namespace.max.cpu"
	MaxMem = "yunikorn.apache.org/namespace.max.memory"
)

Variables

This section is empty.

Functions

func ApplyYamlWithKubectl

func ApplyYamlWithKubectl(path, namespace string) error

func DecoratePodForGangScheduling added in v1.1.0

func DecoratePodForGangScheduling(
	placeholderTimeout int,
	schedulingStyle string,
	taskGroupName string,
	taskGroups []*ykv1.TaskGroup,
	pod *v1.Pod) *v1.Pod

func GetConfigMapObj

func GetConfigMapObj(yamlPath string) (*v1.ConfigMap, error)

func GetPodObj

func GetPodObj(yamlPath string) (*v1.Pod, error)

func GetPodsTotalRequests added in v1.2.0

func GetPodsTotalRequests(podList *v1.PodList) (reqs v1.ResourceList)

Sums up current resource usage in a list of pods. Non-running pods are filtered out.

func GetSecretObj

func GetSecretObj(yamlPath string) (*v1.Secret, error)

func GetWorkerNodes added in v1.2.0

func GetWorkerNodes(nodes v1.NodeList) []v1.Node

func InitJobConfig added in v1.1.0

func InitJobConfig(conf JobConfig) (*batchv1.Job, error)

func InitSleepPod added in v1.1.0

func InitSleepPod(conf SleepPodConfig) (*v1.Pod, error)

TestPodConfig template for sleepPods

func InitTaskGroups added in v1.1.0

func InitTaskGroups(conf SleepPodConfig, mainTaskGroupName, secondTaskGroupName string, parallelism int) []*ykv1.TaskGroup

func InitTestJob added in v1.1.0

func InitTestJob(jobName string, parallelism, completions int32, pod *v1.Pod) *batchv1.Job

func InitTestPod added in v1.1.0

func InitTestPod(conf TestPodConfig) (*v1.Pod, error)

func LogNamespaceInfo added in v1.2.0

func LogNamespaceInfo(ns string) error

func ObserveEventAfterAction

func ObserveEventAfterAction(c clientset.Interface, ns string, eventPredicate func(*v1.Event) bool, action Action) (bool, error)

observeEventAfterAction returns true if an event matching the predicate was emitted from the system after performing the supplied action.

func PodAnnotationToMap added in v1.1.0

func PodAnnotationToMap(annotations *PodAnnotation) (map[string]string, error)

Pod.ObjectMeta.Annotations expect map[string]string. Converts struct to map[string]string

func ScheduleFailureEvent

func ScheduleFailureEvent(podName string) func(*v1.Event) bool

func ScheduleSuccessEvent

func ScheduleSuccessEvent(ns, podName, nodeName string) func(*v1.Event) bool

func SetPortForwarder

func SetPortForwarder(req PortForwardAPodRequest, dialer httpstream.Dialer, ports []string) error

Types

type Action

type Action func() error

Action is a function to be performed by the system.

type JobConfig added in v1.1.0

type JobConfig struct {
	Parallelism int32
	Name        string
	Namespace   string
	PodConfig   TestPodConfig
}

type KubeCtl

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

func (*KubeCtl) ConfigMapExists added in v1.2.0

func (k *KubeCtl) ConfigMapExists(name string, namespace string) (bool, error)

func (*KubeCtl) CreateClusterRoleBinding

func (k *KubeCtl) CreateClusterRoleBinding(
	roleName string,
	role string,
	namespace string,
	serviceAccount string) (*authv1.ClusterRoleBinding, error)

func (*KubeCtl) CreateConfigMap

func (k *KubeCtl) CreateConfigMap(cMap *v1.ConfigMap, namespace string) (*v1.ConfigMap, error)

func (*KubeCtl) CreateConfigMaps

func (k *KubeCtl) CreateConfigMaps(namespace string, cMap *v1.ConfigMap) (*v1.ConfigMap, error)

func (*KubeCtl) CreateDeployment added in v1.2.0

func (k *KubeCtl) CreateDeployment(deployment *appsv1.Deployment, namespace string) (*appsv1.Deployment, error)

func (*KubeCtl) CreateJob added in v1.1.0

func (k *KubeCtl) CreateJob(job *batchv1.Job, namespace string) (*batchv1.Job, error)

func (*KubeCtl) CreateNamespace

func (k *KubeCtl) CreateNamespace(namespace string, annotations map[string]string) (*v1.Namespace, error)

Func to create a namespace provided a name

func (*KubeCtl) CreatePod

func (k *KubeCtl) CreatePod(pod *v1.Pod, namespace string) (*v1.Pod, error)

func (*KubeCtl) CreatePriorityClass added in v1.2.0

func (k *KubeCtl) CreatePriorityClass(pc *schedulingv1.PriorityClass) (*schedulingv1.PriorityClass, error)

func (*KubeCtl) CreateSecret

func (k *KubeCtl) CreateSecret(secret *v1.Secret, namespace string) (*v1.Secret, error)

func (*KubeCtl) CreateServiceAccount

func (k *KubeCtl) CreateServiceAccount(accountName string, namespace string) (*v1.ServiceAccount, error)

func (*KubeCtl) CreateTestPodAction

func (k *KubeCtl) CreateTestPodAction(pod *v1.Pod, namespace string) Action

CreateTestPodAction returns a closure that creates a pause pod upon invocation.

func (*KubeCtl) DeleteClusterRoleBindings

func (k *KubeCtl) DeleteClusterRoleBindings(roleName string) error

func (*KubeCtl) DeleteConfigMap

func (k *KubeCtl) DeleteConfigMap(cName string, namespace string) error

func (*KubeCtl) DeleteConfigMaps

func (k *KubeCtl) DeleteConfigMaps(namespace string, cMapName string) error

func (*KubeCtl) DeleteDeployment added in v1.2.0

func (k *KubeCtl) DeleteDeployment(name, namespace string) error

func (*KubeCtl) DeleteJob added in v1.2.0

func (k *KubeCtl) DeleteJob(jobName string, namespace string) error

func (*KubeCtl) DeleteNamespace

func (k *KubeCtl) DeleteNamespace(namespace string) error

func (*KubeCtl) DeletePod

func (k *KubeCtl) DeletePod(podName string, namespace string) error

func (*KubeCtl) DeletePodAnnotation

func (k *KubeCtl) DeletePodAnnotation(pod *v1.Pod, namespace, annotation string) (*v1.Pod, error)

func (*KubeCtl) DeletePodGracefully

func (k *KubeCtl) DeletePodGracefully(podName string, namespace string) error

func (*KubeCtl) DeletePriorityClass added in v1.2.0

func (k *KubeCtl) DeletePriorityClass(priorityClassName string) error

func (*KubeCtl) DeleteServiceAccount

func (k *KubeCtl) DeleteServiceAccount(accountName string, namespace string) error

func (*KubeCtl) DescribeNode added in v1.2.0

func (k *KubeCtl) DescribeNode(node v1.Node) error

DescribeNode Describe Node

func (*KubeCtl) GetClient

func (k *KubeCtl) GetClient() *kubernetes.Clientset

func (*KubeCtl) GetConfigMap

func (k *KubeCtl) GetConfigMap(name string, namespace string) (*v1.ConfigMap, error)

func (*KubeCtl) GetConfigMaps

func (k *KubeCtl) GetConfigMaps(namespace string, cMapName string) (*v1.ConfigMap, error)

func (*KubeCtl) GetDeployment added in v1.2.0

func (k *KubeCtl) GetDeployment(name, namespace string) (*appsv1.Deployment, error)

func (*KubeCtl) GetEvents

func (k *KubeCtl) GetEvents(namespace string) (*v1.EventList, error)

func (*KubeCtl) GetJobNamesFromNS added in v1.2.0

func (k *KubeCtl) GetJobNamesFromNS(namespace string) ([]string, error)

func (*KubeCtl) GetJobs added in v1.2.0

func (k *KubeCtl) GetJobs(namespace string) (*batchv1.JobList, error)

func (*KubeCtl) GetKubeConfig

func (k *KubeCtl) GetKubeConfig() (*rest.Config, error)

func (*KubeCtl) GetNodes added in v1.1.0

func (k *KubeCtl) GetNodes() (*v1.NodeList, error)

func (*KubeCtl) GetNodesAvailRes added in v1.2.0

func (k *KubeCtl) GetNodesAvailRes(nodes v1.NodeList) map[string]v1.ResourceList

GetNodesAvailRes Returns map of nodeName to list of available resource (memory and cpu only) amounts.

func (*KubeCtl) GetPod

func (k *KubeCtl) GetPod(name, namespace string) (*v1.Pod, error)

func (*KubeCtl) GetPodLogs added in v1.2.0

func (k *KubeCtl) GetPodLogs(podName string, namespace string, containerName string) ([]byte, error)

func (*KubeCtl) GetPodNamesFromNS

func (k *KubeCtl) GetPodNamesFromNS(namespace string) ([]string, error)

func (*KubeCtl) GetPods

func (k *KubeCtl) GetPods(namespace string) (*v1.PodList, error)

func (*KubeCtl) GetPodsByOptions added in v1.2.0

func (k *KubeCtl) GetPodsByOptions(options metav1.ListOptions) (*v1.PodList, error)

func (*KubeCtl) GetSchedulerPod

func (k *KubeCtl) GetSchedulerPod() (string, error)

func (*KubeCtl) GetService

func (k *KubeCtl) GetService(serviceName string, namespace string) (*v1.Service, error)

func (*KubeCtl) KillPortForwardProcess

func (k *KubeCtl) KillPortForwardProcess()

func (*KubeCtl) ListPods

func (k *KubeCtl) ListPods(namespace string, selector string) (*v1.PodList, error)

Returns the list of currently scheduled or running pods in `namespace` with the given selector

func (*KubeCtl) ListPodsByFieldSelector added in v1.2.0

func (k *KubeCtl) ListPodsByFieldSelector(namespace string, selector string) (*v1.PodList, error)

Returns the list of currently scheduled or running pods in `namespace` with the given selector

func (*KubeCtl) PodScheduled

func (k *KubeCtl) PodScheduled(podNamespace, podName string) wait.ConditionFunc

PodScheduled checks if the pod has been scheduled

func (*KubeCtl) PodUnschedulable

func (k *KubeCtl) PodUnschedulable(podNamespace, podName string) wait.ConditionFunc

PodUnschedulable returns a condition function that returns true if the given pod gets unschedulable status.

func (*KubeCtl) PortForwardPod

func (k *KubeCtl) PortForwardPod(req PortForwardAPodRequest) error

func (*KubeCtl) PortForwardYkSchedulerPod

func (k *KubeCtl) PortForwardYkSchedulerPod() error

func (*KubeCtl) RemoveYunikornSchedulerPodAnnotation

func (k *KubeCtl) RemoveYunikornSchedulerPodAnnotation(annotation string) error

func (*KubeCtl) SetClient

func (k *KubeCtl) SetClient() error

func (*KubeCtl) StartConfigMapInformer added in v1.2.0

func (k *KubeCtl) StartConfigMapInformer(namespace string, stopChan <-chan struct{}, eventHandler cache.ResourceEventHandler) error

func (*KubeCtl) TearDownNamespace

func (k *KubeCtl) TearDownNamespace(namespace string) error

func (*KubeCtl) UpdateConfigMap

func (k *KubeCtl) UpdateConfigMap(cMap *v1.ConfigMap, namespace string) (*v1.ConfigMap, error)

func (*KubeCtl) UpdateConfigMaps

func (k *KubeCtl) UpdateConfigMaps(namespace string, cMap *v1.ConfigMap) (*v1.ConfigMap, error)

func (*KubeCtl) UpdatePodWithAnnotation

func (k *KubeCtl) UpdatePodWithAnnotation(pod *v1.Pod, namespace, annotationKey, annotationVal string) (*v1.Pod, error)

func (*KubeCtl) UpdateYunikornSchedulerPodAnnotation

func (k *KubeCtl) UpdateYunikornSchedulerPodAnnotation(annotation string) error

func (*KubeCtl) WaitForJobPods added in v1.2.0

func (k *KubeCtl) WaitForJobPods(namespace string, jobName string, numPods int, timeout time.Duration) error

func (*KubeCtl) WaitForJobPodsCreated added in v1.1.0

func (k *KubeCtl) WaitForJobPodsCreated(namespace string, jobName string, numPods int, timeout time.Duration) error

func (*KubeCtl) WaitForJobPodsRunning added in v1.1.0

func (k *KubeCtl) WaitForJobPodsRunning(namespace string, jobName string, numPods int, timeout time.Duration) error

func (*KubeCtl) WaitForJobPodsSucceeded added in v1.1.0

func (k *KubeCtl) WaitForJobPodsSucceeded(namespace string, jobName string, numPods int, timeout time.Duration) error

func (*KubeCtl) WaitForJobTerminated added in v1.2.0

func (k *KubeCtl) WaitForJobTerminated(namespace string, jobName string, timeout time.Duration) error

func (*KubeCtl) WaitForPlaceholders added in v1.1.0

func (k *KubeCtl) WaitForPlaceholders(namespace string, podPrefix string, numPods int, timeout time.Duration, podPhase v1.PodPhase) error

func (*KubeCtl) WaitForPodBySelector added in v1.2.0

func (k *KubeCtl) WaitForPodBySelector(namespace string, selector string, timeout time.Duration) error

Wait up to timeout seconds for a pod in 'namespace' with given 'selector' to exist

func (*KubeCtl) WaitForPodBySelectorRunning

func (k *KubeCtl) WaitForPodBySelectorRunning(namespace string, selector string, timeout int) error

Wait up to timeout seconds for all pods in 'namespace' with given 'selector' to enter running state. Returns an error if no pods are found or not all discovered pods enter running state.

func (*KubeCtl) WaitForPodCount added in v1.2.0

func (k *KubeCtl) WaitForPodCount(namespace string, wanted int, timeout time.Duration) error

func (*KubeCtl) WaitForPodEvent added in v1.1.0

func (k *KubeCtl) WaitForPodEvent(namespace string, podName string, expectedReason string, timeout time.Duration) error

func (*KubeCtl) WaitForPodFailed

func (k *KubeCtl) WaitForPodFailed(namespace string, podName string, timeout time.Duration) error

func (*KubeCtl) WaitForPodPending

func (k *KubeCtl) WaitForPodPending(namespace string, podName string, timeout time.Duration) error

func (*KubeCtl) WaitForPodRunning

func (k *KubeCtl) WaitForPodRunning(namespace string, podName string, timeout time.Duration) error

Poll up to timeout seconds for pod to enter running state. Returns an error if the pod never enters the running state.

func (*KubeCtl) WaitForPodScheduled

func (k *KubeCtl) WaitForPodScheduled(namespace string, podName string, timeout time.Duration) error

func (*KubeCtl) WaitForPodSucceeded

func (k *KubeCtl) WaitForPodSucceeded(namespace string, podName string, timeout time.Duration) error

func (*KubeCtl) WaitForPodTerminated

func (k *KubeCtl) WaitForPodTerminated(namespace string, podName string, timeout time.Duration) error

func (*KubeCtl) WaitForPodUnschedulable

func (k *KubeCtl) WaitForPodUnschedulable(pod *v1.Pod, timeout time.Duration) error

WaitForPodUnschedulable waits for a pod to fail scheduling and returns an error if it does not become unschedulable within the given timeout.

func (*KubeCtl) WaitForSchedulerAfterAction

func (k *KubeCtl) WaitForSchedulerAfterAction(action Action, ns, podName string, expectSuccess bool) (bool, error)

WaitForSchedulerAfterAction performs the provided action and then waits for scheduler to act on the given pod.

func (*KubeCtl) WaitForServiceAccountPresent

func (k *KubeCtl) WaitForServiceAccountPresent(namespace string, svcAcctName string, timeout time.Duration) error

type PodAnnotation added in v1.1.0

type PodAnnotation struct {
	TaskGroupName          string               `json:"yunikorn.apache.org/task-group-name,omitempty"`
	TaskGroups             []v1alpha1.TaskGroup `json:"-"`
	SchedulingPolicyParams string               `json:"yunikorn.apache.org/schedulingPolicyParameters,omitempty"`
	Other                  map[string]string    `json:"-"`
}

type PortForwardAPodRequest

type PortForwardAPodRequest struct {
	// Kube config
	RestConfig *rest.Config
	// Pod to port-forward traffic for
	Pod v1.Pod
	// Local port to expose traffic to pod's target port
	LocalPort int
	// Target port for the pod
	PodPort int
	// Streams to configure where to read/write input and output
	Streams genericclioptions.IOStreams
	// StopCh is the channel used to stop the port forward process
	StopCh <-chan struct{}
	// ReadyCh communicates when the tunnel is ready to receive traffic
	ReadyCh chan struct{}
}

type SleepPodConfig added in v1.1.0

type SleepPodConfig struct {
	Name         string
	NS           string
	AppID        string
	Time         int
	CPU          int64
	Mem          int64
	RequiredNode string
	Optedout     bool
	UID          types.UID
}

type TestJobConfig added in v1.1.0

type TestJobConfig struct {
	JobName     string
	Parallelism int32
	Completions int32
}

type TestPodConfig added in v1.1.0

type TestPodConfig struct {
	Name                       string
	Namespace                  string
	Affinity                   *v1.Affinity
	Annotations                *PodAnnotation
	Labels, NodeSelector       map[string]string
	Resources                  *v1.ResourceRequirements
	RuntimeClassHandler        *string
	Tolerations                []v1.Toleration
	NodeName                   string
	Ports                      []v1.ContainerPort
	OwnerReferences            []metav1.OwnerReference
	PriorityClassName          string
	DeletionGracePeriodSeconds *int64
	TopologySpreadConstraints  []v1.TopologySpreadConstraint
	Image                      string
	RestartPolicy              v1.RestartPolicy
	Command                    []string
	InitContainerSleepSecs     int
}

Jump to

Keyboard shortcuts

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