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

2022-03-03

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

示例1:
validation_test.go开发语言: Go项目名称: kubernetes代码行数: 2544
647func TestValidatePodSpec(t *testing.T) {
648	successCases := []api.PodSpec{
649		{ // Populate basic fields, leave defaults for most.
673
674	failureCases := map[string]api.PodSpec{
675		"bad volume": {
704			ObjectMeta: api.ObjectMeta{Name: "123", Namespace: "ns"},
705			Spec: api.PodSpec{
706				Volumes:       []api.Volume{{Name: "vol", Source: api.VolumeSource{EmptyDir: &api.EmptyDirVolumeSource{}}}},
713			ObjectMeta: api.ObjectMeta{Name: "abc.123.do-re-mi", Namespace: "ns"},
714			Spec: api.PodSpec{
715				Volumes: []api.Volume{
736			ObjectMeta: api.ObjectMeta{Name: "", Namespace: "ns"},
737			Spec: api.PodSpec{
738				RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
示例2:
kubelet_test.go开发语言: Go项目名称: kubernetes代码行数: 3084
399			},
400			Spec: api.PodSpec{
401				Containers: []api.Container{
429			},
430			Spec: api.PodSpec{
431				Containers: []api.Container{
488			},
489			Spec: api.PodSpec{
490				Containers: []api.Container{
538			},
539			Spec: api.PodSpec{
540				Containers: []api.Container{
585			},
586			Spec: api.PodSpec{
587				Containers: []api.Container{
示例3:
etcd_test.go开发语言: Go项目名称: kubernetes代码行数: 1437
80		},
81		Spec: api.PodSpec{
82			RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
123		&api.Pod{
124			Spec: api.PodSpec{
125				Containers: []api.Container{},
580				ObjectMeta: api.ObjectMeta{Name: "foo"},
581				Spec: api.PodSpec{
582					Containers: []api.Container{
592				ObjectMeta: api.ObjectMeta{Name: "foo"},
593				Spec: api.PodSpec{
594					Containers: []api.Container{
604				ObjectMeta: api.ObjectMeta{Name: "foo"},
605				Spec: api.PodSpec{
606					Containers: []api.Container{
示例4:
admission_test.go开发语言: Go项目名称: kubernetes代码行数: 378
56					ObjectMeta: api.ObjectMeta{Name: "123", Namespace: namespace},
57					Spec: api.PodSpec{
58						Volumes:    []api.Volume{{Name: "vol"}},
91					ObjectMeta: api.ObjectMeta{Name: "123", Namespace: namespace},
92					Spec: api.PodSpec{
93						Volumes:    []api.Volume{{Name: "vol"}},
109		ObjectMeta: api.ObjectMeta{Name: "123", Namespace: namespace},
110		Spec: api.PodSpec{
111			Volumes:    []api.Volume{{Name: "vol"}},
134					ObjectMeta: api.ObjectMeta{Name: "123", Namespace: namespace},
135					Spec: api.PodSpec{
136						Volumes:    []api.Volume{{Name: "vol"}},
152		ObjectMeta: api.ObjectMeta{Name: "123", Namespace: namespace},
153		Spec: api.PodSpec{
154			Volumes:    []api.Volume{{Name: "vol"}},
示例5:
predicates_test.go开发语言: Go项目名称: kubernetes代码行数: 577
67	return api.Pod{
68		Spec: api.PodSpec{
69			Containers: containers,
150			pod: api.Pod{
151				Spec: api.PodSpec{
152					Host: "foo",
160			pod: api.Pod{
161				Spec: api.PodSpec{
162					Host: "bar",
275func TestDiskConflicts(t *testing.T) {
276	volState := api.PodSpec{
277		Volumes: []api.Volume{
286	}
287	volState2 := api.PodSpec{
288		Volumes: []api.Volume{
示例6:
etcd_tools_test.go开发语言: Go项目名称: kubernetes代码行数: 611
105				ObjectMeta: api.ObjectMeta{Name: "bar", ResourceVersion: "2"},
106				Spec: api.PodSpec{
107					RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
112				ObjectMeta: api.ObjectMeta{Name: "baz", ResourceVersion: "3"},
113				Spec: api.PodSpec{
114					RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
119				ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
120				Spec: api.PodSpec{
121					RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
188				ObjectMeta: api.ObjectMeta{Name: "baz", ResourceVersion: "1"},
189				Spec: api.PodSpec{
190					RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
195				ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
196				Spec: api.PodSpec{
197					RestartPolicy: api.RestartPolicy{Always: &api.RestartPolicyAlways{}},
示例7:
admission_test.go开发语言: Go项目名称: kubernetes代码行数: 222
62			ObjectMeta: api.ObjectMeta{Name: "foo"},
63			Spec: api.PodSpec{
64				Containers: []api.Container{
77			ObjectMeta: api.ObjectMeta{Name: "bar"},
78			Spec: api.PodSpec{
79				Containers: []api.Container{
91			ObjectMeta: api.ObjectMeta{Name: "foo"},
92			Spec: api.PodSpec{
93				Containers: []api.Container{
102			ObjectMeta: api.ObjectMeta{Name: "foo"},
103			Spec: api.PodSpec{
104				Containers: []api.Container{
113			ObjectMeta: api.ObjectMeta{Name: "foo"},
114			Spec: api.PodSpec{
115				Containers: []api.Container{
示例8:
pods.go开发语言: Go项目名称: kubernetes代码行数: 631
131			},
132			Spec: api.PodSpec{
133				Containers: []api.Container{
155			},
156			Spec: api.PodSpec{
157				Containers: []api.Container{
255			},
256			Spec: api.PodSpec{
257				Containers: []api.Container{
325			},
326			Spec: api.PodSpec{
327				Containers: []api.Container{
380			},
381			Spec: api.PodSpec{
382				Containers: []api.Container{
示例9:
pods.go开发语言: Go项目名称: kubernetes代码行数: 585
105			},
106			Spec: api.PodSpec{
107				Containers: []api.Container{
162			},
163			Spec: api.PodSpec{
164				Containers: []api.Container{
233			},
234			Spec: api.PodSpec{
235				Containers: []api.Container{
288			},
289			Spec: api.PodSpec{
290				Containers: []api.Container{
363			},
364			Spec: api.PodSpec{
365				Containers: []api.Container{
示例10:
apiserver_test.go开发语言: Go项目名称: kubernetes代码行数: 205
48		ObjectMeta: api.ObjectMeta{Name: "p"},
49		Spec:       api.PodSpec{Containers: []api.Container{{Image: "image/one"}}}}
50	pod1v2 := api.Pod{
51		ObjectMeta: api.ObjectMeta{Name: "p"},
52		Spec:       api.PodSpec{Containers: []api.Container{{Image: "image/two"}}}}
53	pod2 := api.Pod{
54		ObjectMeta: api.ObjectMeta{Name: "q"},
55		Spec:       api.PodSpec{Containers: []api.Container{{Image: "image/blah"}}}}
56
58		ObjectMeta: api.ObjectMeta{Name: "p", SelfLink: "/api/v1beta1/boundPods/p"},
59		Spec:       api.PodSpec{Containers: []api.Container{{Image: "image/one"}}}}
60	expectedBoundPod1v2 := api.BoundPod{
61		ObjectMeta: api.ObjectMeta{Name: "p", SelfLink: "/api/v1beta1/boundPods/p"},
62		Spec:       api.PodSpec{Containers: []api.Container{{Image: "image/two"}}}}
63	expectedBoundPod2 := api.BoundPod{

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