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

2022-03-03

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

示例1:
admission_test.go开发语言: Go项目名称: kubernetes代码行数: 378
29	res := api.ResourceRequirements{}
30	res.Limits = api.ResourceList{}
31	if cpu != "" {
65	status := &api.ResourceQuotaStatus{
66		Hard: api.ResourceList{},
67		Used: api.ResourceList{},
100	status := &api.ResourceQuotaStatus{
101		Hard: api.ResourceList{},
102		Used: api.ResourceList{},
143	status := &api.ResourceQuotaStatus{
144		Hard: api.ResourceList{},
145		Used: api.ResourceList{},
178	status := &api.ResourceQuotaStatus{
179		Hard: api.ResourceList{},
180		Used: api.ResourceList{},
示例2:
resources_test.go开发语言: Go项目名称: kubernetes代码行数: 170
27	tests := []struct {
28		res      api.ResourceList
29		name     api.ResourceName
34		{
35			res:      api.ResourceList{},
36			name:     CPU,
41		{
42			res: api.ResourceList{
43				CPU: util.NewIntOrStringFromInt(2),
50		{
51			res: api.ResourceList{
52				Memory: util.NewIntOrStringFromInt(2),
59		{
60			res: api.ResourceList{
61				CPU: util.NewIntOrStringFromString("2"),
示例3:
limit_ranges_test.go开发语言: Go项目名称: kubernetes代码行数: 195
37					Type: api.LimitTypePod,
38					Max: api.ResourceList{
39						api.ResourceCPU:    resource.MustParse("100"),
41					},
42					Min: api.ResourceList{
43						api.ResourceCPU:    resource.MustParse("0"),
73					Type: api.LimitTypePod,
74					Max: api.ResourceList{
75						api.ResourceCPU:    resource.MustParse("100"),
77					},
78					Min: api.ResourceList{
79						api.ResourceCPU:    resource.MustParse("0"),
133					Type: api.LimitTypePod,
134					Max: api.ResourceList{
135						api.ResourceCPU:    resource.MustParse("100"),
示例4:
nodecontroller_test.go开发语言: Go项目名称: kubernetes代码行数: 970
302func TestCreateCloudNodes(t *testing.T) {
303	resourceList := api.ResourceList{
304		api.ResourceCPU:    *resource.NewMilliQuantity(1000, resource.DecimalSI),
示例5:
validation_test.go开发语言: Go项目名称: kubernetes代码行数: 2544
377
378func getResourceLimits(cpu, memory string) api.ResourceList {
379	res := api.ResourceList{}
408			Resources: api.ResourceRequirements{
409				Limits: api.ResourceList{
410					api.ResourceName(api.ResourceCPU):    resource.MustParse("10"),
489				Resources: api.ResourceRequirements{
490					Limits: api.ResourceList{
491						"disk": resource.MustParse("10G"),
584					Resources: api.ResourceRequirements{
585						Limits: api.ResourceList{
586							"cpu":    resource.MustParse("1"),
1955			Spec: api.NodeSpec{
1956				Capacity: api.ResourceList{
1957					api.ResourceCPU:    resource.MustParse("10000"),
示例6:
priorities_test.go开发语言: Go项目名称: kubernetes代码行数: 367
31		Spec: api.NodeSpec{
32			Capacity: api.ResourceList{
33				"cpu":    *resource.NewMilliQuantity(milliCPU, resource.DecimalSI),
61				Resources: api.ResourceRequirements{
62					Limits: api.ResourceList{
63						"cpu": resource.MustParse("1000m"),
68				Resources: api.ResourceRequirements{
69					Limits: api.ResourceList{
70						"cpu": resource.MustParse("2000m"),
79				Resources: api.ResourceRequirements{
80					Limits: api.ResourceList{
81						"cpu":    resource.MustParse("1000m"),
87				Resources: api.ResourceRequirements{
88					Limits: api.ResourceList{
89						"cpu":    resource.MustParse("2000m"),
示例7:
admission_test.go开发语言: Go项目名称: abhgupta代码行数: 837
329			pod:        validPod("pod-max-cpu-request-limit", 2, getResourceRequirements(getComputeResourceList("500m", ""), getComputeResourceList("1", ""))),
330			limitRange: createLimitRange(api.LimitTypePod, api.ResourceList{}, getComputeResourceList("2", ""), api.ResourceList{}, api.ResourceList{}, api.ResourceList{}),
331		},
637	limitRange := validLimitRange()
638	testPod := validPodInit(validPod("foo", 1, getResourceRequirements(api.ResourceList{}, api.ResourceList{})), getResourceRequirements(api.ResourceList{}, api.ResourceList{}))
639	err := PodMutateLimitFunc(&limitRange, &testPod)
796			pvc:        validPersistentVolumeClaim("pvc-is-min-storage-request", getResourceRequirements(getStorageResourceList("1Gi"), getStorageResourceList(""))),
797			limitRange: createLimitRange(api.LimitTypePersistentVolumeClaim, getStorageResourceList("1Gi"), api.ResourceList{}, api.ResourceList{}, api.ResourceList{}, api.ResourceList{}),
798		},
800			pvc:        validPersistentVolumeClaim("pvc-is-max-storage-request", getResourceRequirements(getStorageResourceList("1Gi"), getStorageResourceList(""))),
801			limitRange: createLimitRange(api.LimitTypePersistentVolumeClaim, api.ResourceList{}, getStorageResourceList("1Gi"), api.ResourceList{}, api.ResourceList{}, api.ResourceList{}),
802		},
822			pvc:        validPersistentVolumeClaim("pvc-below-min-storage-request", getResourceRequirements(getStorageResourceList("500Mi"), getStorageResourceList(""))),
823			limitRange: createLimitRange(api.LimitTypePersistentVolumeClaim, getStorageResourceList("1Gi"), api.ResourceList{}, api.ResourceList{}, api.ResourceList{}, api.ResourceList{}),
824		},
示例8:
admission_test.go开发语言: Go项目名称: amygdala代码行数: 554
245			pod:        validPod("ctr-max-cpu-limit", 1, getResourceRequirements(getResourceList("", ""), getResourceList("1", ""))),
246			limitRange: createLimitRange(api.LimitTypeContainer, api.ResourceList{}, getResourceList("2", ""), api.ResourceList{}, api.ResourceList{}, api.ResourceList{}),
247		},
375			pod:        validPod("pod-max-cpu-request-limit", 3, getResourceRequirements(getResourceList("500m", ""), getResourceList("1", ""))),
376			limitRange: createLimitRange(api.LimitTypePod, api.ResourceList{}, getResourceList("2", ""), api.ResourceList{}, api.ResourceList{}, api.ResourceList{}),
377		},
379			pod:        validPod("pod-max-cpu-limit", 3, getResourceRequirements(getResourceList("", ""), getResourceList("1", ""))),
380			limitRange: createLimitRange(api.LimitTypePod, api.ResourceList{}, getResourceList("2", ""), api.ResourceList{}, api.ResourceList{}, api.ResourceList{}),
381		},
383			pod:        validPod("pod-max-mem-request-limit", 3, getResourceRequirements(getResourceList("", "250Mi"), getResourceList("", "500Mi"))),
384			limitRange: createLimitRange(api.LimitTypePod, api.ResourceList{}, getResourceList("", "1Gi"), api.ResourceList{}, api.ResourceList{}, api.ResourceList{}),
385		},
387			pod:        validPod("pod-max-mem-limit", 3, getResourceRequirements(getResourceList("", ""), getResourceList("", "500Mi"))),
388			limitRange: createLimitRange(api.LimitTypePod, api.ResourceList{}, getResourceList("", "1Gi"), api.ResourceList{}, api.ResourceList{}, api.ResourceList{}),
389		},
示例9:
resource_quotas_test.go开发语言: Go项目名称: kubernetes代码行数: 178
34		Spec: api.ResourceQuotaSpec{
35			Hard: api.ResourceList{
36				api.ResourceCPU:                    resource.MustParse("100"),
66		Spec: api.ResourceQuotaSpec{
67			Hard: api.ResourceList{
68				api.ResourceCPU:                    resource.MustParse("100"),
122		Spec: api.ResourceQuotaSpec{
123			Hard: api.ResourceList{
124				api.ResourceCPU:                    resource.MustParse("100"),
148		Spec: api.ResourceQuotaSpec{
149			Hard: api.ResourceList{
150				api.ResourceCPU:                    resource.MustParse("100"),
示例10:
resources_test.go开发语言: Go项目名称: abhgupta代码行数: 316
27	testCases := map[string]struct {
28		a        api.ResourceList
29		b        api.ResourceList
32		"isEqual": {
33			a:        api.ResourceList{},
34			b:        api.ResourceList{},
37		"isEqualWithKeys": {
38			a: api.ResourceList{
39				api.ResourceCPU:    resource.MustParse("100m"),
41			},
42			b: api.ResourceList{
43				api.ResourceCPU:    resource.MustParse("100m"),
48		"isNotEqualSameKeys": {
49			a: api.ResourceList{
50				api.ResourceCPU:    resource.MustParse("200m"),

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