本文整理汇总了Golang中k8s/io/kubernetes/pkg/client/unversioned.Interface.Batch方法的典型用法代码示例。如果您正苦于以下问题:Golang Interface.Batch方法的具体用法?Golang Interface.Batch怎么用?Golang Interface.Batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/client/unversioned.Interface
的用法示例。
在下文中一共展示了Interface.Batch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ScalerFor
func ScalerFor(kind unversioned.GroupKind, c client.Interface) (Scaler, error) {
switch kind {
case api.Kind("ReplicationController"):
return &ReplicationControllerScaler{c}, nil
case extensions.Kind("ReplicaSet"):
return &ReplicaSetScaler{c.Extensions()}, nil
case extensions.Kind("Job"), batch.Kind("Job"):
return &JobScaler{c.Batch()}, nil // Either kind of job can be scaled with Batch interface.
case extensions.Kind("Deployment"):
return &DeploymentScaler{c.Extensions()}, nil
}
return nil, fmt.Errorf("no scaler has been implemented for %q", kind)
}
示例2: getRawJobPods
// Returns array of api pods targeting job with given name.
func getRawJobPods(client k8sClient.Interface, petSetName, namespace string) ([]api.Pod, error) {
replicaSet, err := client.Batch().Jobs(namespace).Get(petSetName)
if err != nil {
return nil, err
}
labelSelector := labels.SelectorFromSet(replicaSet.Spec.Selector.MatchLabels)
channels := &common.ResourceChannels{
PodList: common.GetPodListChannelWithOptions(client, common.NewSameNamespaceQuery(namespace),
api.ListOptions{
LabelSelector: labelSelector,
FieldSelector: fields.Everything(),
}, 1),
}
podList := <-channels.PodList.List
if err := <-channels.PodList.Error; err != nil {
return nil, err
}
return podList.Items, nil
}