当前位置: 首页>>代码示例>>Golang>>正文


Golang Interface.Nodes方法代码示例

本文整理汇总了Golang中k8s/io/kubernetes/pkg/client/unversioned.Interface.Nodes方法的典型用法代码示例。如果您正苦于以下问题:Golang Interface.Nodes方法的具体用法?Golang Interface.Nodes怎么用?Golang Interface.Nodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在k8s/io/kubernetes/pkg/client/unversioned.Interface的用法示例。


在下文中一共展示了Interface.Nodes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: makeNNodes

func makeNNodes(c client.Interface, N int) {
	baseNode := &api.Node{
		ObjectMeta: api.ObjectMeta{
			GenerateName: "scheduler-test-node-",
		},
		Spec: api.NodeSpec{
			ExternalID: "foobar",
		},
		Status: api.NodeStatus{
			Capacity: api.ResourceList{
				api.ResourcePods:   *resource.NewQuantity(32, resource.DecimalSI),
				api.ResourceCPU:    resource.MustParse("4"),
				api.ResourceMemory: resource.MustParse("32Gi"),
			},
			Phase: api.NodeRunning,
			Conditions: []api.NodeCondition{
				{Type: api.NodeReady, Status: api.ConditionTrue},
			},
		},
	}
	for i := 0; i < N; i++ {
		if _, err := c.Nodes().Create(baseNode); err != nil {
			panic("error creating node: " + err.Error())
		}
	}
}
开发者ID:rrouf,项目名称:kubernetes,代码行数:26,代码来源:scheduler_test.go

示例2: unloadNodeLabel

func unloadNodeLabel(client kclient.Interface, application *api.Application, labelSelector labels.Selector) error {

	resourceList, _ := client.Nodes().List(kapi.ListOptions{LabelSelector: labelSelector, FieldSelector: fields.Everything()})
	errs := []error{}
	for _, resource := range resourceList.Items {
		if !hasItem(application.Spec.Items, api.Item{Kind: "Node", Name: resource.Name}) {
			delete(resource.Labels, fmt.Sprintf("%s.application.%s", application.Namespace, application.Name))
			if _, err := client.Nodes().Update(&resource); err != nil {
				errs = append(errs, err)
			}
		}
	}

	return nil
}
开发者ID:asiainfoLDP,项目名称:datafactory,代码行数:15,代码来源:controller_label.go

示例3: GetNodeDetail

// GetNodeDetail gets node details.
func GetNodeDetail(client k8sClient.Interface, heapsterClient client.HeapsterClient, name string) (*NodeDetail, error) {
	log.Printf("Getting details of %s node", name)

	node, err := client.Nodes().Get(name)
	if err != nil {
		return nil, err
	}

	// Download standard metrics. Currently metrics are hard coded, but it is possible to replace
	// dataselect.StdMetricsDataSelect with data select provided in the request.
	_, metricPromises := dataselect.GenericDataSelectWithMetrics(toCells([]api.Node{*node}),
		dataselect.StdMetricsDataSelect,
		dataselect.NoResourceCache, &heapsterClient)

	pods, err := getNodePods(client, *node)
	if err != nil {
		return nil, err
	}

	podList, err := GetNodePods(client, heapsterClient, dataselect.DefaultDataSelect, name)

	eventList, err := event.GetNodeEvents(client, dataselect.DefaultDataSelect, node.Name)
	if err != nil {
		return nil, err
	}

	allocatedResources, err := getNodeAllocatedResources(*node, pods)
	if err != nil {
		return nil, err
	}

	metrics, _ := metricPromises.GetMetrics()
	nodeDetails := toNodeDetail(*node, podList, eventList, allocatedResources, metrics)
	return &nodeDetails, nil
}
开发者ID:digitalfishpond,项目名称:dashboard,代码行数:36,代码来源:nodedetail.go

示例4: GetNodeDetail

// GetNodeDetail gets node details.
func GetNodeDetail(client k8sClient.Interface, heapsterClient client.HeapsterClient, name string) (
	*NodeDetail, error) {
	log.Printf("Getting details of %s node", name)

	node, err := client.Nodes().Get(name)
	if err != nil {
		return nil, err
	}

	pods, err := getNodePods(client, *node)
	if err != nil {
		return nil, err
	}

	podList := pod.CreatePodList(pods.Items, heapsterClient)

	events, err := event.GetNodeEvents(client, node.Name)
	if err != nil {
		return nil, err
	}

	allocatedResources, err := getNodeAllocatedResources(*node, pods)
	if err != nil {
		return nil, err
	}

	nodeDetails := toNodeDetail(*node, podList, events, allocatedResources)
	return &nodeDetails, nil
}
开发者ID:FujitsuEnablingSoftwareTechnologyGmbH,项目名称:dashboard,代码行数:30,代码来源:nodedetail.go

示例5: GetNodeList

// GetNodeList returns a list of all Nodes in the cluster.
func GetNodeList(client client.Interface) (*NodeList, error) {
	log.Printf("Getting list of all nodes in the cluster")

	nodes, err := client.Nodes().List(api.ListOptions{
		LabelSelector: labels.Everything(),
		FieldSelector: fields.Everything(),
	})

	if err != nil {
		return nil, err
	}

	return toNodeList(nodes.Items), nil
}
开发者ID:FujitsuEnablingSoftwareTechnologyGmbH,项目名称:dashboard,代码行数:15,代码来源:nodelist.go

示例6: GetNodePods

func GetNodePods(client k8sClient.Interface, heapsterClient client.HeapsterClient, dsQuery *dataselect.DataSelectQuery, name string) (*pod.PodList, error) {
	node, err := client.Nodes().Get(name)
	if err != nil {
		return nil, err
	}

	pods, err := getNodePods(client, *node)
	if err != nil {
		return nil, err
	}

	podList := pod.CreatePodList(pods.Items, dsQuery, heapsterClient)
	return &podList, nil
}
开发者ID:digitalfishpond,项目名称:dashboard,代码行数:14,代码来源:nodedetail.go

示例7: GetNodeEvents

// GetNodeEvents gets events associated to node with given name.
func GetNodeEvents(client client.Interface, dsQuery *dataselect.DataSelectQuery, nodeName string) (*common.EventList, error) {
	var eventList common.EventList

	mc := client.Nodes()
	node, _ := mc.Get(nodeName)
	if ref, err := api.GetReference(node); err == nil {
		ref.UID = types.UID(ref.Name)
		events, _ := client.Events(api.NamespaceAll).Search(ref)
		eventList = CreateEventList(events.Items, dsQuery)
	} else {
		log.Print(err)
	}

	return &eventList, nil
}
开发者ID:digitalfishpond,项目名称:dashboard,代码行数:16,代码来源:eventcommon.go

示例8: GetNodeEvents

// GetNodeEvents gets events associated to node with given name.
func GetNodeEvents(client client.Interface, nodeName string) (common.EventList, error) {
	eventList := common.EventList{
		Namespace: api.NamespaceAll,
		Events:    make([]common.Event, 0),
	}

	mc := client.Nodes()
	node, _ := mc.Get(nodeName)
	if ref, err := api.GetReference(node); err == nil {
		ref.UID = types.UID(ref.Name)
		events, _ := client.Events(api.NamespaceAll).Search(ref)
		AppendEvents(events.Items, eventList)
	} else {
		log.Print(err)
	}

	return eventList, nil
}
开发者ID:FujitsuEnablingSoftwareTechnologyGmbH,项目名称:dashboard,代码行数:19,代码来源:eventcommon.go

示例9: GetReplicationControllerDetail

// GetReplicationControllerDetail returns detailed information about the given replication
// controller in the given namespace.
func GetReplicationControllerDetail(client client.Interface, heapsterClient HeapsterClient,
	namespace, name string) (*ReplicationControllerDetail, error) {
	log.Printf("Getting details of %s replication controller in %s namespace", name, namespace)

	replicationControllerWithPods, err := getRawReplicationControllerWithPods(client, namespace, name)
	if err != nil {
		return nil, err
	}
	replicationController := replicationControllerWithPods.ReplicationController
	pods := replicationControllerWithPods.Pods

	replicationControllerMetricsByPod, err := getReplicationControllerPodsMetrics(pods, heapsterClient, namespace, name)
	if err != nil {
		log.Printf("Skipping Heapster metrics because of error: %s\n", err)
	}

	services, err := client.Services(namespace).List(api.ListOptions{
		LabelSelector: labels.Everything(),
		FieldSelector: fields.Everything(),
	})

	if err != nil {
		return nil, err
	}

	replicationControllerDetail := &ReplicationControllerDetail{
		Name:          replicationController.Name,
		Namespace:     replicationController.Namespace,
		Labels:        replicationController.ObjectMeta.Labels,
		LabelSelector: replicationController.Spec.Selector,
		PodInfo:       getReplicationControllerPodInfo(replicationController, pods.Items),
	}

	matchingServices := getMatchingServices(services.Items, replicationController)

	// Anonymous callback function to get nodes by their names.
	getNodeFn := func(nodeName string) (*api.Node, error) {
		return client.Nodes().Get(nodeName)
	}

	for _, service := range matchingServices {
		replicationControllerDetail.Services = append(replicationControllerDetail.Services,
			getServiceDetail(service, *replicationController, pods.Items, getNodeFn))
	}

	for _, container := range replicationController.Spec.Template.Spec.Containers {
		replicationControllerDetail.ContainerImages = append(replicationControllerDetail.ContainerImages,
			container.Image)
	}

	for _, pod := range pods.Items {
		podDetail := ReplicationControllerPod{
			Name:         pod.Name,
			PodPhase:     pod.Status.Phase,
			StartTime:    pod.CreationTimestamp,
			PodIP:        pod.Status.PodIP,
			NodeName:     pod.Spec.NodeName,
			RestartCount: getRestartCount(pod),
		}
		if replicationControllerMetricsByPod != nil {
			metric := replicationControllerMetricsByPod.MetricsMap[pod.Name]
			podDetail.Metrics = &metric
			replicationControllerDetail.HasMetrics = true
		}
		replicationControllerDetail.Pods = append(replicationControllerDetail.Pods, podDetail)
	}

	return replicationControllerDetail, nil
}
开发者ID:batikanu,项目名称:dashboard,代码行数:71,代码来源:replicationcontrollerdetail.go


注:本文中的k8s/io/kubernetes/pkg/client/unversioned.Interface.Nodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。