k8s/io/kubernetes/pkg/api.NodeCondition 示例代码

2022-03-03

以下示例是关于golang中包含api.NodeCondition用法的示例代码,想了解api.NodeCondition的具体用法?api.NodeCondition怎么用?api.NodeCondition使用的例子?那么可以参考以下10个相关示例代码来学习它的具体使用方法。

示例1:
nodecontroller_test.go开发语言: Go项目名称: kubernetes代码行数: 970
525		fakeKubeletClient  *FakeKubeletClient
526		expectedConditions []api.NodeCondition
527	}{
533			},
534			expectedConditions: []api.NodeCondition{
535				{
547			},
548			expectedConditions: []api.NodeCondition{
549				{
561			},
562			expectedConditions: []api.NodeCondition{
563				{
638						Status: api.NodeStatus{
639							Conditions: []api.NodeCondition{
640								{
示例2:
factory_test.go开发语言: Go项目名称: kubernetes代码行数: 362
58					Status: api.NodeStatus{
59						Conditions: []api.NodeCondition{
60							{Type: api.NodeReady, Status: api.ConditionFull},
66					Status: api.NodeStatus{
67						Conditions: []api.NodeCondition{
68							{Type: api.NodeReachable, Status: api.ConditionFull},
74					Status: api.NodeStatus{
75						Conditions: []api.NodeCondition{
76							{Type: api.NodeReady, Status: api.ConditionFull},
83					Status: api.NodeStatus{
84						Conditions: []api.NodeCondition{
85							{Type: api.NodeReady, Status: api.ConditionFull},
97					Status: api.NodeStatus{
98						Conditions: []api.NodeCondition{
99							{Type: api.NodeReady, Status: api.ConditionFull},
示例3:
nodecontroller.go开发语言: Go项目名称: kubernetes代码行数: 417
271func (s *NodeController) DoCheck(node *api.Node) []api.NodeCondition {
272	var conditions []api.NodeCondition
273
301// checkNodeReady checks raw node ready condition, without transition timestamp set.
302func (s *NodeController) checkNodeReady(node *api.Node) *api.NodeCondition {
303	switch status, err := s.kubeletClient.HealthCheck(node.Name); {
305		glog.V(2).Infof("NodeController: node %s health check error: %v", node.Name, err)
306		return &api.NodeCondition{
307			Type:          api.NodeReady,
312	case status == probe.Failure:
313		return &api.NodeCondition{
314			Type:          api.NodeReady,
408// type, nil if the condition is not set.
409func (s *NodeController) getCondition(node *api.Node, conditionType api.NodeConditionType) *api.NodeCondition {
410	for i := range node.Status.Conditions {
示例4:
resource_printer_test.go开发语言: Go项目名称: kubernetes代码行数: 592
526				ObjectMeta: api.ObjectMeta{Name: "foo1"},
527				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionFull}}},
528			},
533				ObjectMeta: api.ObjectMeta{Name: "foo2"},
534				Status: api.NodeStatus{Conditions: []api.NodeCondition{
535					{Type: api.NodeReady, Status: api.ConditionFull},
542				ObjectMeta: api.ObjectMeta{Name: "foo3"},
543				Status: api.NodeStatus{Conditions: []api.NodeCondition{
544					{Type: api.NodeReady, Status: api.ConditionFull},
551				ObjectMeta: api.ObjectMeta{Name: "foo4"},
552				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionNone}}},
553			},
558				ObjectMeta: api.ObjectMeta{Name: "foo5"},
559				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: "InvalidValue", Status: api.ConditionFull}}},
560			},
示例5:
nodecontroller_test.go开发语言: Go项目名称: amygdala代码行数: 1188
203						Status: api.NodeStatus{
204							Conditions: []api.NodeCondition{
205								{
219			newNodeStatus: api.NodeStatus{
220				Conditions: []api.NodeCondition{
221					{
242						Status: api.NodeStatus{
243							Conditions: []api.NodeCondition{
244								{
285			newNodeStatus: api.NodeStatus{
286				Conditions: []api.NodeCondition{
287					{
308						Status: api.NodeStatus{
309							Conditions: []api.NodeCondition{
310								{
示例6:
printers_test.go开发语言: Go项目名称: detiber代码行数: 2598
640				ObjectMeta: metav1.ObjectMeta{Name: "foo1"},
641				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionTrue}}},
642			},
648				Spec:       api.NodeSpec{Unschedulable: true},
649				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionTrue}}},
650			},
655				ObjectMeta: metav1.ObjectMeta{Name: "foo3"},
656				Status: api.NodeStatus{Conditions: []api.NodeCondition{
657					{Type: api.NodeReady, Status: api.ConditionTrue},
664				ObjectMeta: metav1.ObjectMeta{Name: "foo4"},
665				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionFalse}}},
666			},
672				Spec:       api.NodeSpec{Unschedulable: true},
673				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionFalse}}},
674			},
示例7:
printers_test.go开发语言: Go项目名称: ddysher代码行数: 2826
761				ObjectMeta: metav1.ObjectMeta{Name: "foo1"},
762				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionTrue}}},
763			},
769				Spec:       api.NodeSpec{Unschedulable: true},
770				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionTrue}}},
771			},
776				ObjectMeta: metav1.ObjectMeta{Name: "foo3"},
777				Status: api.NodeStatus{Conditions: []api.NodeCondition{
778					{Type: api.NodeReady, Status: api.ConditionTrue},
785				ObjectMeta: metav1.ObjectMeta{Name: "foo4"},
786				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionFalse}}},
787			},
793				Spec:       api.NodeSpec{Unschedulable: true},
794				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionFalse}}},
795			},
示例8:
printers_test.go开发语言: Go项目名称: abhgupta代码行数: 3206
775				ObjectMeta: metav1.ObjectMeta{Name: "foo1"},
776				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionTrue}}},
777			},
783				Spec:       api.NodeSpec{Unschedulable: true},
784				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionTrue}}},
785			},
790				ObjectMeta: metav1.ObjectMeta{Name: "foo3"},
791				Status: api.NodeStatus{Conditions: []api.NodeCondition{
792					{Type: api.NodeReady, Status: api.ConditionTrue},
799				ObjectMeta: metav1.ObjectMeta{Name: "foo4"},
800				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionFalse}}},
801			},
807				Spec:       api.NodeSpec{Unschedulable: true},
808				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionFalse}}},
809			},
示例9:
nodecontroller.go开发语言: Go项目名称: amygdala代码行数: 939
306// type, nil if the condition is not set.
307func (nc *NodeController) getCondition(status *api.NodeStatus, conditionType api.NodeConditionType) *api.NodeCondition {
308	if status == nil {
443		var gracePeriod time.Duration
444		var lastReadyCondition api.NodeCondition
445		var readyCondition *api.NodeCondition
621// is entitled, state of current and last observed Ready Condition, and an error if it occurred.
622func (nc *NodeController) tryUpdateNodeStatus(node *api.Node) (time.Duration, api.NodeCondition, *api.NodeCondition, error) {
623	var err error
624	var gracePeriod time.Duration
625	var lastReadyCondition api.NodeCondition
626	readyCondition := nc.getCondition(&node.Status, api.NodeReady)
630		// to node.CreationTimestamp to avoid handle the corner case.
631		lastReadyCondition = api.NodeCondition{
632			Type:               api.NodeReady,
示例10:
resource_printer_test.go开发语言: Go项目名称: amygdala代码行数: 1449
555				ObjectMeta: api.ObjectMeta{Name: "foo1"},
556				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionTrue}}},
557			},
563				Spec:       api.NodeSpec{Unschedulable: true},
564				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionTrue}}},
565			},
570				ObjectMeta: api.ObjectMeta{Name: "foo3"},
571				Status: api.NodeStatus{Conditions: []api.NodeCondition{
572					{Type: api.NodeReady, Status: api.ConditionTrue},
579				ObjectMeta: api.ObjectMeta{Name: "foo4"},
580				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionFalse}}},
581			},
587				Spec:       api.NodeSpec{Unschedulable: true},
588				Status:     api.NodeStatus{Conditions: []api.NodeCondition{{Type: api.NodeReady, Status: api.ConditionFalse}}},
589			},

本文地址:https://www.itbaoku.cn/snippets/415657.html